/* Rolling Plans — Legacy / Page-Specific Styles
   Core design system lives in design-system.css + components.css + layout.css */

/* ====== Login Page ====== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(10, 143, 82, 0.35) 0%, transparent 50%),
        linear-gradient(160deg, var(--color-primary-darker) 0%, var(--color-primary) 45%, var(--bg-sidebar) 100%);
    padding: var(--space-6);
}
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    width: 100%;
    max-width: 420px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.login-header {
    background: var(--bg-brand);
    color: var(--text-inverse);
    padding: var(--space-8) var(--space-6) var(--space-6);
    text-align: center;
}
.login-header__logo {
    height: 64px;
    width: auto;
    background: var(--bg-card);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    object-fit: contain;
}
.login-header h1 {
    font-size: var(--text-xl);
    margin-bottom: var(--space-2);
    font-weight: var(--font-semibold);
    color: var(--text-inverse);
    line-height: var(--leading-tight);
}
.login-header p {
    opacity: 0.9;
    font-size: var(--text-sm);
    margin: 0;
}
.login-body { padding: var(--space-6); }
.login-body .btn--primary { width: 100%; }
.login-divider {
    text-align: center;
    margin: var(--space-4) 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}
.login-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    text-decoration: none;
    color: var(--text-primary);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.login-google:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}
.login-google img { height: 20px; width: 20px; }
.login-hint {
    margin-top: var(--space-5);
    padding: var(--space-4);
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}
.login-hint code {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ====== Task Cards ====== */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 15px;
    margin-bottom: 15px;
    transition: all var(--transition-fast);
    cursor: pointer;
}
.task-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-title { font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.task-meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--text-sm); color: var(--text-muted); }
.task-type { background: var(--bg-muted); padding: 2px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 500; }

/* ====== Quarterly Grid ====== */
.quarters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}
.quarter-card {
    background: var(--bg-muted);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 15px;
    transition: all var(--transition-fast);
}
.quarter-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.quarter-title { font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; text-align: center; font-size: var(--text-sm); }
.quarter-target { background: var(--bg-card); padding: 8px; border-radius: var(--radius-sm); margin-bottom: 10px; border-left: 4px solid var(--color-primary); font-size: 13px; }
.quarter-progress { margin-top: 8px; }

/* ====== Comments (legacy aliases → design-system chips) ====== */
.comments-section { max-height: 420px; overflow-y: auto; }
.comment-author,
.comment-user { font-weight: 600; color: var(--text-primary); font-size: var(--text-sm); }
.comment-date,
.comment-time { font-size: var(--text-xs); color: var(--text-muted); }
.comment-text,
.comment-content { color: var(--text-primary); line-height: 1.6; }

/* ====== Organization Tree ====== */
.org-tree { margin: 0; padding: 0; list-style: none; }
.org-tree ul { margin-left: 20px; padding-left: 12px; border-left: 1px solid var(--border); }
.org-node { margin: 6px 0; }
.org-node .node-content {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border);
}
.org-node .node-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-muted); display: inline-block; flex-shrink: 0; }
.org-node .node-label { font-weight: 600; color: var(--text-primary); }
.org-node .node-meta { font-size: 12px; color: var(--text-muted); }
.org-node .node-actions { margin-left: auto; }
.org-node .toggle-btn { background: none; border: none; cursor: pointer; font-size: 14px; padding: 4px 8px; color: var(--color-primary); }
.org-children { margin-top: 8px; }
.org-children.collapsed { display: none; }

.card-node .node-content { display: block; text-align: center; padding: 12px; border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border); }
.card-node .node-avatar { margin: 0 auto 8px; }
.card-node .node-label { font-size: 16px; font-weight: 700; }
.card-node .node-meta { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.card-node .node-actions { margin-top: 10px; display: flex; gap: 8px; justify-content: center; }
.card-node .toggle-btn { position: absolute; left: 8px; top: 10px; }
.card-node { position: relative; }

/* ====== Performance Tree - Enhanced Layout ====== */
.perf-node .node-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.perf-node .node-content:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.perf-node .toggle-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.perf-node .toggle-btn:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.perf-node .toggle-spacer {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.perf-node .node-avatar-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.perf-node .node-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.perf-node .node-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.perf-node .node-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.perf-node .node-designation {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.perf-node .node-capsules {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.perf-node .node-capsules .capsule-tag {
    font-size: 10px;
    padding: 3px 8px;
    margin: 0;
}

.perf-node .node-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.perf-node .node-actions .btn {
    white-space: nowrap;
}

/* Tree visualization improvements */
.org-tree ul {
    margin-left: 24px;
    padding-left: 16px;
    border-left: 2px solid var(--border);
    position: relative;
}

.org-tree ul::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--color-primary-light, #e0e7ff), var(--border));
}

.org-node {
    margin: 8px 0;
    position: relative;
}

.org-node::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 24px;
    width: 16px;
    height: 2px;
    background: var(--border);
}

.org-children.collapsed {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .perf-node .node-content {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
    }
    
    .perf-node .node-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
    }
    
    .perf-node .node-capsules {
        gap: 3px;
    }
    
    .perf-node .node-capsules .capsule-tag {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* ====== Filter Panel ====== */
.filter-panel {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    padding: 18px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}
.filter-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; align-items: end; }
.filter-group { display: flex; flex-direction: column; }
.filter-label { font-size: 13px; margin-bottom: 6px; opacity: 0.95; }
.filter-select { padding: 10px 12px; border-radius: 6px; border: none; font-size: 14px; }
.filter-buttons { display: flex; gap: 10px; align-items: end; }
.btn-apply { background: var(--color-primary); color: var(--text-inverse); padding: 8px 12px; border-radius: var(--radius-md); border: none; cursor: pointer; }
.btn-apply:hover { background: var(--color-primary-dark); }
.btn-reset { background: rgba(255,255,255,0.15); color: white; padding: 8px 12px; border-radius: 6px; border: none; cursor: pointer; }

/* Choices.js inside filter panel - fix styling for green background */
.filter-panel .choices {
    margin-bottom: 0;
}

.filter-panel .choices__inner {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-height: 42px;
    padding: 4px 8px;
}

.filter-panel .choices.is-focused .choices__inner {
    background: #ffffff;
    border-color: rgba(255, 255, 255, 0.6);
}

.filter-panel .choices__list--dropdown,
.filter-panel .choices__list[aria-expanded] {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    z-index: 1060;
}

.filter-panel .choices__input {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.filter-panel .choices__input:focus {
    background: #ffffff;
    border-bottom-color: #3b82f6;
}

/* Ensure filter content has proper spacing when expanded */
.filter-content {
    padding-top: 12px;
}

/* Filter toggle hover effect */
.filter-toggle:hover {
    opacity: 0.9;
}

/* Ensure filter buttons have proper spacing */
.filter-panel .filter-buttons {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ====== Filter Chips ====== */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.4;
    transition: all var(--transition-fast);
}
.filter-chip:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}
.filter-chip__label {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: 10px;
}
.filter-chip__value {
    font-weight: 500;
}
.filter-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 2px;
    border-radius: 50%;
    background: var(--color-danger);
    color: white;
    text-decoration: none;
    font-size: 12px;
    line-height: 1;
    transition: all var(--transition-fast);
}
.filter-chip__remove:hover {
    background: var(--color-danger-dark);
    transform: scale(1.1);
}
.filter-chip-clear-all:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* AJAX loading state */
#usersTableContainer {
    transition: opacity 0.3s ease;
    position: relative;
}
#usersTableContainer.loading {
    opacity: 0.5;
    pointer-events: none;
}
#usersTableContainer.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ====== Form Floats ====== */
.form-floating { position: relative; margin-bottom: var(--space-5); }
.form-floating input, .form-floating select {
    padding: 14px 14px 10px 14px; border: 2px solid var(--border); border-radius: var(--radius-md);
    width: 100%; font-size: var(--text-sm); background: var(--bg-card); color: var(--text-primary);
    transition: border-color var(--transition-fast);
}
.form-floating label {
    position: absolute; top: 14px; left: 16px; color: var(--text-muted); font-size: var(--text-sm);
    transition: all var(--transition-fast); pointer-events: none; background: var(--bg-card); padding: 0 4px;
}
.form-floating input:focus, .form-floating select:focus { border-color: var(--color-primary); outline: none; box-shadow: var(--focus-ring); }
.form-floating input:focus + label,
.form-floating input:not(:placeholder-shown) + label,
.form-floating select:focus + label,
.form-floating.filled label,
.form-floating select.has-value + label {
    transform: translateY(-24px) scale(0.8); color: var(--color-primary); z-index: 1;
}

/* ====== User Management Legacy ====== */
.user-management-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white; padding: 30px; border-radius: var(--radius-lg); margin-bottom: 30px;
}
.user-table-wrapper { background: var(--bg-card); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.user-row { border-bottom: 1px solid var(--border); transition: background var(--transition-fast); }
.user-row:hover { background: var(--bg-muted); }
.user-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    display: flex; align-items: center; justify-content: center; color: white;
    font-weight: 600; margin-right: 12px;
}
.user-info { display: flex; align-items: center; }
.user-details h6 { margin: 0; color: var(--text-primary); font-weight: 600; }
.user-details small { color: var(--text-muted); }
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* ====== RBAC Page Legacy ====== */
.rbac-header {
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--bg-sidebar) 100%);
    color: #fff; padding: 30px; border-radius: var(--radius-lg); margin-bottom: 30px;
}
.rbac-header h1 { color: white; }
.rbac-header p { color: rgba(255,255,255,0.8); }
.role-row { border-bottom: 1px solid var(--border); transition: background var(--transition-fast); }
.role-row:hover { background: var(--bg-muted); }
.system-badge { background: var(--color-primary-dark); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: var(--radius-pill); }
.clone-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9999; justify-content: center; align-items: center; }
.clone-modal.show { display: flex; }
.clone-modal-content { background: var(--bg-card); border-radius: var(--radius-lg); padding: 24px; max-width: 440px; width: 90%; }

.perm-group { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 12px; overflow: hidden; }
.perm-group-header { background: var(--bg-muted); padding: 10px 16px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.perm-group-body { padding: 8px 16px 12px; }
.perm-item { display: flex; align-items: center; padding: 6px 0; gap: 8px; }
.perm-row { padding: 8px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.perm-row:last-child { border-bottom: none; }
.perm-row:hover { background: var(--bg-muted); }

.matrix-container { overflow-x: auto; }
.matrix-table { min-width: 800px; font-size: 13px; }
.matrix-table th { background: var(--bg-sidebar); color: #fff; white-space: nowrap; vertical-align: middle; text-align: center; padding: 10px 8px; }
.matrix-table th.perm-col { background: var(--color-primary-dark); min-width: 200px; text-align: left; }
.matrix-table td { vertical-align: middle; padding: 6px 8px; }
.matrix-table tbody tr:hover { background: var(--bg-muted); }
.group-header td { background: var(--bg-muted); font-weight: 700; padding: 10px 8px; }
.perm-check { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary); }
.sticky-form { position: sticky; bottom: 0; background: var(--bg-card); border-top: 2px solid var(--border); padding: 16px 0; z-index: 10; }

/* ====== Tab Nav ====== */
.nav-tabs {
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    list-style: none;
    padding: 0;
}
.nav-tabs .nav-item { margin-bottom: -2px; }
.nav-tabs .nav-link {
    display: block; padding: 12px 20px; text-decoration: none; color: var(--text-secondary);
    border: 2px solid transparent; border-bottom: none; border-radius: var(--radius-md) var(--radius-md) 0 0;
    transition: all var(--transition-fast); font-weight: 500;
}
.nav-tabs .nav-link:hover { border-color: var(--border); background: var(--bg-muted); }
.nav-tabs .nav-link.active {
    color: var(--color-primary); background: var(--bg-card);
    border-color: var(--border) var(--border) var(--bg-card); font-weight: 600;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ====== Misc Legacy ====== */
.table-header {
    background: var(--bg-muted); padding: 20px; border-bottom: 1px solid var(--border);
}
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-outline-danger { color: var(--color-danger); border: 1px solid var(--color-danger); background: transparent; cursor: pointer; }
.btn-outline-primary { color: var(--color-primary); border: 1px solid var(--color-primary); background: transparent; cursor: pointer; }
.btn-outline-secondary { color: var(--text-secondary); border: 1px solid var(--border-strong); background: transparent; cursor: pointer; }

.invalid-feedback { font-size: 12px; color: var(--color-danger); }

.d-flex { display: flex; }
.d-flex.gap-1 { gap: var(--space-2); }
.d-flex.gap-2 { gap: var(--space-3); }
.d-flex.gap-3 { gap: var(--space-4); }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted) !important; }
.text-info { color: var(--color-info) !important; }
.float-end { float: right; }
.ms-1 { margin-left: var(--space-2); }
.ms-2 { margin-left: var(--space-3); }
.me-1 { margin-right: var(--space-2); }
.me-2 { margin-right: var(--space-3); }
.mt-3 { margin-top: var(--space-4); }
.mt-4 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: var(--space-4); }
.mb-4 { margin-bottom: var(--space-6); }
.p-0 { padding: 0; }
.p-3 { padding: var(--space-4); }
.p-4 { padding: var(--space-6); }
.w-100 { width: 100%; }
.container-fluid { width: 100%; padding: 0 var(--space-4); }

.section-heading {
    font-size: var(--text-lg); font-weight: var(--font-semibold); color: var(--text-primary);
    margin: var(--space-5) 0 var(--space-4);
}

.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}
.grid-3col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
}
.grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
}

/* Bootstrap grid compat */
.row { display: flex; flex-wrap: wrap; margin: -10px; }
.col-md-3  { flex: 0 0 25%;        max-width: 25%;        padding: 10px; }
.col-md-4  { flex: 0 0 33.333333%; max-width: 33.333333%; padding: 10px; }
.col-md-6  { flex: 0 0 50%;        max-width: 50%;        padding: 10px; }
.col-md-8  { flex: 0 0 66.666667%; max-width: 66.666667%; padding: 10px; }
.col-md-12 { flex: 0 0 100%;       max-width: 100%;       padding: 10px; }

@media (max-width: 768px) {
    .row { flex-direction: column; }
    .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-12 { flex: 0 0 100%; max-width: 100%; }
    .quarters-grid { grid-template-columns: 1fr; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
