/* ==========================================================================
   SIDEBAR — Navigation, collapse sections, sidebar toggle, sidebar links
   Split from custom.css
   ========================================================================== */

.sidebar {
    background: linear-gradient(180deg, #0c1222 0%, #111827 100%);
    min-height: calc(100vh - 45px);
    height: calc(100vh - 45px);
    padding: 1.5rem 1rem 1rem 1rem;
    position: fixed;
    width: 250px;
    left: 0;
    top: 45px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-status-bottom {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0 0.5rem 0;
    margin-bottom: 0.25rem;
}

/* FinGNN Logo */
.gnn-logo {
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    color: white;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}

.gnn-logo-sm {
    width: 36px;
    height: 36px;
    font-size: 11px;
    border-radius: 8px;
}

.gnn-logo-md {
    width: 48px;
    height: 48px;
    font-size: 14px;
    border-radius: 10px;
}

.gnn-logo-lg {
    width: 64px;
    height: 64px;
    font-size: 18px;
    border-radius: 12px;
}

.sidebar-brand-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #10b981);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand-text {
    color: #f1f5f9;
    font-weight: 600;
    font-size: 0.9375rem;
}

.sidebar-brand-text-only {
    color: #f1f5f9;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Umbrella brand for multi-project site */
.umbrella-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.25rem 0;
}

.umbrella-brand-logo {
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.umbrella-brand-sub {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: 2px;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: #cbd5e1 !important;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 0.25rem;
    transition: all 0.15s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(96,165,250,0.06);
    color: #f1f5f9 !important;
}

.nav-link.active {
    background: rgba(96,165,250,0.15);
    color: #60a5fa !important;
    border: 1px solid rgba(96,165,250,0.3);
    box-shadow: 0 0 12px rgba(96,165,250,0.08);
}

/* Project section headers for multi-project sidebar */
.project-section {
    margin-bottom: 0.25rem;
}

.project-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

/* Collapsible section toggle */
.project-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0;
    cursor: pointer;
    border: none;
    background: none;
    transition: background 0.15s ease;
    border-radius: 6px;
    position: relative;
}

/* Make the link inside project-section-toggle cover the full row */
.project-section-toggle > a::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

.project-section-toggle:hover {
    background: rgba(255,255,255,0.04);
}

.project-section-toggle.active {
    background: rgba(59,130,246,0.08);
}

.project-section-toggle.active .project-badge {
    box-shadow: 0 0 0 1px rgba(59,130,246,0.3);
}

.project-section-chevron {
    color: #64748b;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

/* Rotate chevron when section is open -- uses Bootstrap .show on dbc.Collapse */
.project-section:has(.collapse.show) .project-section-chevron {
    transform: rotate(180deg);
}

.project-section .collapse,
.project-section .collapsing {
    transition: height 0.2s ease;
}

.project-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    background: rgba(100, 116, 139, 0.15);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

/* Remove underline from links wrapping project badges (e.g. blog footer) */
a:has(> .project-badge),
a:has(> div > .project-badge) {
    text-decoration: none;
}

/* Project badges -- monochrome (Linear/Notion style) */
.project-badge.quantengine { border: 1px solid rgba(148, 163, 184, 0.3); font-weight: 600; }
.project-badge.fingraph { border: 1px solid rgba(148, 163, 184, 0.3); font-weight: 600; }

/* Theme category headers */
.theme-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.75rem;
    margin-top: 0.6rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}
.theme-header:hover { background: rgba(255, 255, 255, 0.04); }
.theme-header.active {
    background: rgba(59, 130, 246, 0.08);
}
.theme-header.active .theme-header-label {
    color: #60a5fa !important;
}
.theme-header-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.theme-header-label::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #475569;
    flex-shrink: 0;
}
.theme-header-chevron {
    font-size: 0.55rem;
    color: #475569;
    transition: transform 0.3s;
}
/* Rotate chevron when theme group is open */
.theme-group:has(.collapse.show) > .theme-header > .theme-header-chevron {
    transform: rotate(180deg);
}
.theme-group { margin-bottom: 0.15rem; }
.theme-group .project-section { padding-left: 0.5rem; }

/* Theme dot colors -- subtle colored dots next to monochrome labels */
.theme-header.core .theme-header-label::before { background: #3b82f6; }
.theme-header.causal .theme-header-label::before { background: #f97316; }
.theme-header.modeling .theme-header-label::before { background: #10b981; }
.theme-header.robustness .theme-header-label::before { background: #ef4444; }
.theme-header.scalable .theme-header-label::before { background: #06b6d4; }
.theme-header.prod-ops .theme-header-label::before { background: #64748b; }
.theme-header.content .theme-header-label::before { background: #94a3b8; }
.theme-header.blog .theme-header-label::before { background: #f59e0b; }
.standalone-link .theme-header-label::before { display: none; }
.standalone-link { justify-content: flex-start; gap: 0; }

.project-section .nav-link {
    padding-left: 1.25rem;
    font-size: 0.875rem;
}

.section-divider {
    border-color: rgba(255,255,255,0.08);
    margin: 0.75rem 0;
}

.sidebar-sub-label {
    font-size: 0.65rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.6rem 1.25rem 0.15rem;
    font-weight: 600;
}

.sidebar-sub-label:first-child {
    padding-top: 0.25rem;
}

/* Status badges */
#sidebar-status-badges {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
    width: 100%;
}

#sidebar-status-badges .status-badge {
    display: flex;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    width: 100%;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-connected {
    background: rgba(16,185,129,0.12);
    color: #34d399;
}

.status-disconnected {
    background: rgba(239,68,68,0.12);
    color: #f87171;
}

/* Mobile menu button (hidden by default, shown on mobile - top right corner) */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    background: #1e1e2e;
    border: 1px solid #3b82f6;
    color: #60a5fa;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.mobile-menu-btn:hover {
    background: #2a2a3a;
    border-color: #60a5fa;
}

/* Preferences button */
.preferences-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #94a3b8;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.preferences-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Preferences panel sections */
.prefs-section {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Settings panel export buttons */
.settings-export-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    transition: all 0.2s ease;
}
.settings-export-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #f1f5f9;
}
.settings-export-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    color: #64748b;
}
body.theme-light .settings-export-btn {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #334155;
}
body.theme-light .settings-export-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
    color: #1e293b;
}
body.theme-light .settings-export-btn:disabled {
    opacity: 0.4;
    color: #6b7280;
}

/* Header settings */
.header-settings {
    margin-left: 0;
}

.header-settings-btn {
    background: rgba(255, 255, 255, 0.04);
    border: none;
    color: #64748b;
    padding: 0.4rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    gap: 0.35rem;
    width: 100%;
}

.header-settings-btn:hover {
    background: rgba(96, 165, 250, 0.1);
    color: #93c5fd;
}

/* Light sidebar in light mode */
body.theme-light .sidebar {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: #334155;
    border-right: 1px solid #e2e8f0;
}
body.theme-light .sidebar p,
body.theme-light .sidebar label,
body.theme-light .sidebar .project-section-toggle > span,
body.theme-light .sidebar .text-muted,
body.theme-light .sidebar .sidebar-brand-text,
body.theme-light .sidebar .sidebar-status-bottom {
    color: #475569 !important;
}
body.theme-light .sidebar .sidebar-brand-text-only {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.theme-light .sidebar a,
body.theme-light .sidebar .nav-link {
    color: #475569 !important;
}
body.theme-light .sidebar .nav-link:hover {
    background: rgba(37,99,235,0.06);
    color: #1e40af !important;
}
body.theme-light .sidebar .nav-link.active {
    background: rgba(37,99,235,0.10);
    color: #2563eb !important;
    border: 1px solid rgba(37,99,235,0.25);
    box-shadow: 0 0 8px rgba(37,99,235,0.06);
}
body.theme-light .sidebar .section-divider {
    border-color: #e2e8f0 !important;
}
body.theme-light .sidebar .sidebar-sub-label {
    color: #64748b !important;
}
body.theme-light .sidebar .gnn-logo {
    border-color: rgba(37,99,235,0.15);
}
body.theme-light .sidebar-status-bottom {
    border-top-color: #e2e8f0;
}
