﻿/* ===============================
   🌙 GLOBAL BASE STYLES
   =============================== */
body {
    background-color: #121212;
    color: #f5f5f5;
    font-family: system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #121212;
    color: #e4e6eb; /* slightly softer than pure white */
}

h1, h2, h3, .dashboard-title {
    color: #e8eaed; /* softer white, still clean */
}

.card {
    background-color: #18191b !important;
    color: #e4e6eb !important;
}

.dashboard-subtitle,
.metric-header,
.sub-item,
.exec-report {
    color: #b8bcc4 !important;
}

/* ===============================
   🌌 CONTENT AREA
   =============================== */
.content {
    margin-left: 260px;
    padding: 24px;
    transition: margin-left 0.3s ease;
}

    .content.collapsed-content {
        margin-left: 80px;
    }

/* ===============================
   💠 DASHBOARD CARDS & METRICS
   =============================== */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.card {
    background: #1e1e1e;
    color: #ffffff;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 1rem;
    margin: 0.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.metric-card {
    position: relative;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
}

/* Trend Badge */
.trend-badge {
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #111827;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease-in-out;
}

    .trend-badge:hover {
        background: #3b82f6;
        color: #fff;
        transform: scale(1.05);
    }

/* AI Badge */
.ai-badge {
    position: absolute;
    bottom: 10px;
    right: 12px;
    font-size: 1.1rem;
    color: #2563eb;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

    .ai-badge:hover {
        color: #3b82f6;
        transform: scale(1.2);
        text-shadow: 0 0 8px rgba(59, 130, 246, 0.7);
    }

/* ===============================
   🧠 AI INSIGHT PANEL
   =============================== */
.ai-insight-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.ai-insight-panel {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    width: 450px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.insight-text {
    white-space: pre-wrap;
    color: #333;
    font-size: 0.95rem;
}

/* ===============================
   📊 EXECUTIVE REPORT
   =============================== */
.exec-container {
    margin-top: 30px;
    padding: 20px;
}

.exec-report {
    white-space: pre-wrap;
    background: rgba(255,255,255,0.04);
    padding: 20px;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.5;
    border: 1px solid rgba(255,255,255,0.12);
}

/* Markdown tables (e.g. Section 9 Sector Benchmark Summary) */
.exec-report table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0 1.75rem;
    font-size: 0.95rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: 8px;
    overflow: hidden;
}

.exec-report thead {
    background: rgba(255,255,255,0.10);
}

.exec-report th,
.exec-report td {
    padding: 12px 22px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(255,255,255,0.20);
    border-right: 1px solid rgba(255,255,255,0.16);
}

.exec-report th:last-child,
.exec-report td:last-child {
    border-right: none;
}

.exec-report th {
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 2px solid rgba(255,255,255,0.32);
}

.exec-report tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.04);
}

.exec-report tbody tr:hover {
    background: rgba(255,255,255,0.07);
}

.exec-report tbody tr:last-child td {
    border-bottom: none;
}

.loading-box {
    padding: 40px;
    text-align: center;
    color: #ddd;
}

.error-box {
    padding: 20px;
    background: rgba(255, 60, 60, 0.1);
    border: 1px solid rgba(255, 60, 60, 0.3);
    color: #ff6a6a;
    border-radius: 8px;
}

/* ===============================
   🧩 SIDEBAR CORE
   =============================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 240px;
    background: #111315;
    border-right: 1px solid #1b1c20;
    color: #e5e7eb;
    padding: 1.25rem;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width 0.3s ease, padding 0.3s ease;
    overflow-x: hidden;
    height: 100vh;
}

    .sidebar a, .sidebar button {
        display: flex;
        align-items: center;
        color: #c9cad1;
        text-decoration: none;
        padding: 6px 10px;
        border-radius: 6px;
        transition: all 0.2s ease;
        white-space: nowrap;
    }

        .sidebar a:hover, .sidebar button:hover {
            color: #60a5fa;
            background-color: rgba(59, 130, 246, 0.08);
        }

        /* Active Link */
        .sidebar a.active {
            color: #60a5fa !important;
            position: relative;
            font-weight: 500;
        }

            .sidebar a.active::before {
                content: '';
                position: absolute;
                left: -10px;
                top: 25%;
                height: 50%;
                width: 3px;
                background-color: #3b82f6;
                border-radius: 3px;
                box-shadow: 0 0 6px #3b82f6;
            }

/* Section Headers */
.menu-section {
    margin-top: 1rem;
    margin-bottom: 0.75rem;
}

/* Pins the Settings group to the bottom of the sidebar with a divider
   above so admin/config nav reads as distinct from content nav. */
.menu-section-bottom {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.menu-header {
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.55);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: all 0.3s ease;
}

.sidebar.collapsed .menu-header {
    color: transparent;
    justify-content: center;
}

    .sidebar.collapsed .menu-header::before {
        content: attr(data-icon);
        color: #3b82f6;
        font-family: "Bootstrap Icons";
        font-size: 1.2rem;
    }

/* Submenu */
.submenu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

    .submenu .nav-link {
        font-size: 0.9rem;
    }

/* ===============================
   🌟 BRAND (LOGO + FX TOGGLE)
   =============================== */
/* === Brand / Logo Toggle === */
.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 0;
    position: relative;
    height: 64px;
    cursor: pointer;
    overflow: hidden;
    transition: background-color 0.2s ease;
}

    .brand:hover {
        background-color: rgba(59, 130, 246, 0.08);
    }

.brand-logo {
    height: 42px;
    width: auto;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: block;
}

.brand-short {
    display: none;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #60a5fa;
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Collapsed behavior */
.sidebar.collapsed .brand-logo {
    opacity: 0;
    transform: scale(0.85);
    visibility: hidden;
    pointer-events: none;
}

.sidebar.collapsed .brand-short {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    visibility: visible;
}


/* ===============================
   🔐 AUTH SECTION
   =============================== */
.auth-links {
    margin-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1rem;
}

    .auth-links a,
    .auth-links button {
        color: #9ca3af;
        text-decoration: none;
        display: block;
        padding: 0.4rem 0;
        font-size: 0.95rem;
        background: none;
        border: none;
        transition: color 0.2s ease;
    }

        .auth-links a:hover,
        .auth-links button:hover {
            color: #60a5fa;
        }

.user-info {
    font-size: 0.9rem;
    color: #bbb;
    margin-bottom: 0.5rem;
    text-align: left;
    transition: opacity 0.3s ease, height 0.3s ease;
}

.sidebar.collapsed .user-info {
    opacity: 0;
    height: 0;
    overflow: hidden;
}

/* ===============================
   🌙 COLLAPSED STATE
   =============================== */
.sidebar.collapsed {
    width: 72px;
    padding: 1rem 0.5rem;
}

    .sidebar.collapsed a span,
    .sidebar.collapsed button span {
        display: none;
    }

    .sidebar.collapsed a {
        justify-content: center;
    }

    .sidebar.collapsed i {
        margin-right: 0;
        font-size: 1.2rem;
    }

/* ===============================
   ✨ DASHBOARD HEADER STYLES
   =============================== */
.dashboard-header {
    margin-bottom: 2rem;
    padding-left: 0.75rem;
    border-left: 4px solid #2563eb;
}

.dashboard-title {
    font-size: 2.3rem;
    font-weight: 700;
    color: #f9fafb;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
}

.dashboard-subheader {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.dashboard-subtitle {
    font-size: 1.25rem;
    color: #d1d5db;
    font-weight: 400;
}

.period-pill {
    background: rgba(37,99,235,0.1);
    color: #60a5fa;
    border: 1px solid rgba(37,99,235,0.3);
    border-radius: 9999px;
    font-size: 0.9rem;
    padding: 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
}

    .period-pill i {
        font-size: 0.95rem;
        color: #60a5fa;
    }

/* Sync Button */
.sync-btn {
    background: transparent;
    color: #6b7280;
    border: 1px solid rgba(107,114,128,0.3);
    border-radius: 9999px;
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

    .sync-btn:hover:not(:disabled) {
        color: #60a5fa;
        background: rgba(37,99,235,0.1);
        border-color: rgba(37,99,235,0.3);
    }

    .sync-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    .sync-btn.syncing i {
        display: inline-block;
        animation: sync-spin 1s linear infinite;
    }

@keyframes sync-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* =============================
   🌟 TOPBAR & USER MENU
   ============================= */
.topbar {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    height: 56px;
    background: #0d0e10;
    border-bottom: 1px solid #1b1c20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 900;
    transition: left 0.3s ease;
}

.sidebar.collapsed ~ .topbar {
    left: 72px;
}

.topbar-org {
    color: #9aa0a6;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.user-menu {
    position: relative;
}

.user-avatar {
    color: #e5e7eb;
    font-size: 1.6rem;
    cursor: pointer;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

    .user-avatar:hover {
        color: #60a5fa;
    }

    .user-avatar .user-name {
        font-size: 0.9rem;
        color: #d1d5db;
        font-weight: 500;
    }

.user-dropdown {
    position: absolute;
    top: 48px;
    right: 0;
    background: #111315;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    min-width: 320px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    padding: 0.5rem 0;
}

    .user-dropdown .user-email {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        color: #aeb2b8;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

.dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    color: #d1d5db;
    padding: 0.5rem 1rem;
    text-align: left;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

    .dropdown-item:hover {
        background: rgba(59, 130, 246, 0.08);
        color: #60a5fa;
    }

/* Adjust content spacing for topbar */
.content {
    margin-top: 56px;
    min-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}
.content > :not(.fx-footer) {
    flex: 0 0 auto;
}

/* Help panel — slide-in drawer reused on every dashboard */
.fx-help-toggle {
    position: fixed;
    top: 70px;
    right: 16px;
    /* Must sit below .topbar (z-index 900, which creates a stacking context
       containing the user-dropdown). Otherwise the "?" bleeds through. */
    z-index: 100;
}
.fx-help-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #9aa2af;
    padding: 6px 10px;
    border-radius: 6px;
    line-height: 1;
    cursor: pointer;
    font-size: 1rem;
}
.fx-help-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }

.fx-help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1045;
    display: none;
}
.fx-help-overlay.open { display: block; }

.fx-help-panel {
    position: fixed;
    top: 0;
    right: -440px;
    width: 420px;
    max-width: 90vw;
    height: 100%;
    background: #111315;
    color: #e6e9ef;
    z-index: 1050;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.5);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}
.fx-help-panel.open { right: 0; }

.fx-help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #1f2937;
    font-weight: 600;
    font-size: 1rem;
}
.fx-help-close {
    background: none;
    border: 0;
    color: #9aa2af;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.fx-help-close:hover { color: #fff; }

.fx-help-body {
    padding: 16px 20px 24px;
    overflow-y: auto;
    flex: 1;
    font-size: 0.92rem;
    line-height: 1.5;
}
.fx-help-body h4 {
    color: #2563eb; /* dashboard accent blue (matches title-block left border) */
    font-size: 1rem;
    margin: 16px 0 6px 0;
}
.fx-help-body h4:first-child { margin-top: 0; }
.fx-help-body p { margin: 0 0 10px 0; color: #c8ccd2; }
.fx-help-body strong { color: #ffffff; }
.fx-help-body hr { border: 0; border-top: 1px solid #1f2937; margin: 14px 0; }
.fx-help-body .fx-help-note {
    color: #9aa2af;
    font-size: 0.85rem;
    font-style: italic;
    border-top: 1px dashed #1f2937;
    padding-top: 10px;
    margin-top: 14px;
}

/* Site footer (mirrors FusionX Lite) */
.fx-footer {
    margin-top: auto;
    padding: 12px 20px;
    border-top: 1px solid #1f2937;
    background-color: #0f1115;
    color: #9ca3af;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.fx-footer img {
    height: 1.6rem;
    vertical-align: middle;
    margin: 0 4px;
}
.fx-footer .fx-footer-right {
    margin-left: auto;
}
@media (max-width: 640.98px) {
    .fx-footer .fx-footer-right { display: none; }
}

/* Financial Health page */
.fx-health-composite {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 24px 0 32px;
}
.fx-composite-title {
    color: #e6e9ef;
    font-size: 1rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 6px;
}
.fx-solvency-pill {
    margin-top: 8px;
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.35);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
}
.fx-sector-notice {
    margin-top: 6px;
    color: #9aa2af;
    font-size: 0.78rem;
}
.fx-gauge-wrapper {
    position: relative;
    width: 180px;
    height: 110px;
    max-width: 100%;
}
.fx-gauge-wrapper canvas {
    max-width: 100%;
    height: auto !important;
}
.fx-gauge-large {
    width: 340px;
    height: 200px;
    aspect-ratio: 340 / 200;
    height: auto;
}
.fx-gauge-score {
    position: absolute;
    top: 55%;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1.9rem;
    font-weight: 700;
    color: #e6e9ef;
}
.fx-gauge-score-sm {
    position: absolute;
    top: 55%;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: #e6e9ef;
}
.fx-health-grid {
    /* Flex (not grid) so partial wrap-around rows centre themselves —
       grid auto-fit only collapses fully-empty tracks, leaving the last
       row left-aligned when the column is occupied above. */
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 24px;
    justify-content: center;
}
.fx-gauge-card {
    position: relative;
    background: #161b22;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 1 300px;
}
.fx-gauge-label {
    font-weight: 600;
    color: #e6e9ef;
    margin-top: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.85rem;
}
.fx-gauge-formula {
    color: #9aa2af;
    font-size: 0.72rem;
    margin-top: 2px;
    text-align: center;
}
.fx-gauge-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 8px;
}
.fx-gauge-value {
    color: #e6e9ef;
    font-weight: 600;
}
.fx-gauge-band {
    color: #60a5fa;
    font-size: 0.85rem;
}
.fx-gauge-bench {
    color: #9aa2af;
    font-size: 0.72rem;
    margin-top: 4px;
    text-align: center;
}
.fx-gauge-card .ai-badge {
    position: absolute;
    bottom: 8px;
    right: 10px;
    cursor: pointer;
    color: #60a5fa;
}

/* ===============================
   📱 AUTO-COLLAPSE SIDEBAR (narrow viewports)
   =============================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 72px;
        padding: 1rem 0.5rem;
    }
    .sidebar a span,
    .sidebar button span {
        display: none;
    }
    .sidebar a {
        justify-content: center;
    }
    .sidebar i {
        margin-right: 0;
        font-size: 1.2rem;
    }
    .sidebar .menu-header {
        color: transparent;
        justify-content: center;
    }
    .sidebar .menu-header::before {
        content: attr(data-icon);
        color: #3b82f6;
        font-family: "Bootstrap Icons";
        font-size: 1.2rem;
    }
    .sidebar .brand-logo {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
    .sidebar .brand-short {
        display: block;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    .sidebar .menu-section > div[style*="padding"] {
        display: none;
    }
    .content {
        margin-left: 80px;
    }
}
