/* ===================================
   DASHBOARD CSS — NigamaConnect Admin
   Cinematic Premium Redesign
   =================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    /* ── Luxury Brand Palette (Mapped to variables.css) ── */
    --brand-primary: var(--nc-brand-primary, #0FA3D9);
    --brand-primary-dark: #0B1933;
    --brand-primary-light: #38BDF8;
    --brand-secondary: var(--nc-brand-primary, #0FA3D9);
    --brand-accent: #38BDF8;
    --brand-gold: var(--nc-brand-gold, #F59E0B);
    --brand-indigo: #6366F1;
    --brand-violet: var(--nc-brand-purple, #8B5CF6);
    --brand-emerald: var(--nc-brand-secondary, #10B981);
    --brand-rose: var(--nc-brand-rose, #EC4899);

    /* ── Semantic Colors ── */
    --success-color: var(--nc-brand-secondary, #10B981);
    --error-color: var(--nc-brand-danger, #EF4444);
    --warning-color: var(--nc-brand-gold, #F59E0B);
    --info-color: var(--nc-brand-primary, #0FA3D9);

    /* ── High-Contrast Text System ── */
    --text-primary: var(--nc-text-primary, #F8FAFC);
    --text-secondary: var(--nc-text-secondary, #94A3B8);
    --text-light: var(--nc-text-muted, #64748B);
    --text-on-primary: #FFFFFF;

    /* ── Dark Cosmic Backgrounds & Glass Surfaces ── */
    --bg-primary: var(--nc-surface-card, #0B1528);
    --bg-secondary: var(--nc-bg-main, #020617);
    --bg-tertiary: rgba(255, 255, 255, 0.08);
    --bg-dark: #020617;
    --bg-hover: rgba(255, 255, 255, 0.06);

    /* ── Glass Tokens ── */
    --glass-bg: rgba(11, 21, 40, 0.78);
    --glass-border: var(--nc-border-glass, rgba(255, 255, 255, 0.12));
    --glass-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.6);

    /* ── Sidebar ── */
    --sidebar-width: 260px;
    --sidebar-collapsed: 76px;
    --sidebar-bg: var(--nc-surface-dock, rgba(11, 21, 40, 0.85));

    /* ── Shadows & Ambient Glows ── */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 25px 60px -12px rgba(0, 0, 0, 0.75);
    --shadow-glow-blue: 0 0 25px var(--nc-brand-primary-glow, rgba(15, 163, 217, 0.35));
    --shadow-glow-gold: 0 0 25px var(--nc-brand-gold-glow, rgba(245, 158, 11, 0.35));

    /* ── Transitions & Easings ── */
    --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-smooth: 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-elastic: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    /* ── Border Radius ── */
    --radius-sm: var(--nc-radius-sm, 8px);
    --radius-md: var(--nc-radius-md, 14px);
    --radius-lg: var(--nc-radius-lg, 20px);
    --radius-xl: var(--nc-radius-xl, 28px);
    --radius-2xl: 32px;
}

/* ──────────────────────────────────────
   RESET & BASE
   ────────────────────────────────────── */
*, *::before, *::after {
    margin: 0; padding: 0;
    box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ──────────────────────────────────────
   SIDEBAR — Cinematic Dark
   ────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--text-on-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    transition: width var(--transition-smooth);
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    border-right: 1px solid rgba(255,255,255,0.06);
    overflow: hidden;
}

/* Decorative shimmer strip at top */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--brand-secondary), var(--brand-gold), var(--brand-secondary), transparent);
    background-size: 200% 100%;
    animation: shimmerSlide 4s linear infinite;
    z-index: 2;
}

@keyframes shimmerSlide {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.sidebar-logo {
    width: 42px; height: 42px;
    border-radius: 10px;
    object-fit: contain;
    background: rgba(255,255,255,0.12);
    padding: 6px;
    border: 1px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
    transition: transform var(--transition-elastic);
}

.sidebar-logo:hover { transform: scale(1.08) rotate(-3deg); }

.sidebar-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    background: linear-gradient(135deg, #fff 0%, var(--brand-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-toggle {
    margin-left: auto;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
    flex-shrink: 0;
}
.sidebar-toggle:hover {
    background: rgba(255,255,255,0.18);
    transform: scale(1.05);
}
.sidebar-toggle svg { width: 18px; height: 18px; }

/* ── Navigation ── */
.sidebar-nav {
    flex: 1;
    min-height: 0; /* Fixes flexbox scrolling bug */
    padding: 16px 0 24px 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* Show scrollbar for better UX */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

/* Custom scrollbar for webkit browsers */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* Nav section label */
.nav-section-label {
    padding: 8px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all var(--transition-smooth);
    gap: 12px;
    margin: 2px 12px;
    border-radius: var(--radius-sm);
    position: relative;
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--brand-secondary);
    border-radius: 0 3px 3px 0;
    transform: scaleY(0);
    transition: transform var(--transition-smooth);
}

.nav-item:hover {
    background: rgba(255,255,255,0.09);
    color: white;
    transform: translateX(3px);
}
.nav-item:hover::before { transform: scaleY(1); }

.nav-item.active {
    background: linear-gradient(135deg, rgba(59,130,246,0.25), rgba(14,165,233,0.15));
    color: white;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.nav-item.active::before { transform: scaleY(1); }

.nav-icon {
    width: 20px; height: 20px;
    flex-shrink: 0;
    transition: transform var(--transition-smooth);
}
.nav-item:hover .nav-icon { transform: scale(1.15); }

.nav-text { white-space: nowrap; overflow: hidden; }

.nav-badge {
    position: absolute;
    right: 14px;
    background: linear-gradient(135deg, var(--brand-rose), #dc2626);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
    animation: badgePulse 2s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(244,63,94,0.5);
}

@keyframes badgePulse {
    0%,100% { transform: scale(1); box-shadow: 0 2px 8px rgba(244,63,94,0.5); }
    50% { transform: scale(1.1); box-shadow: 0 4px 14px rgba(244,63,94,0.7); }
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}
.sidebar-version {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.5px;
}

/* ──────────────────────────────────────
   MAIN CONTENT
   ────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-smooth);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-secondary);
}

/* ──────────────────────────────────────
   HEADER — Frosted Glass
   ────────────────────────────────────── */
.header {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 2px 16px rgba(30,58,138,0.06);
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.mobile-menu-btn:hover { background: var(--bg-tertiary); }
.mobile-menu-btn svg { width: 24px; height: 24px; }

.page-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.header-right { display: flex; align-items: center; gap: 20px; }

/* ── Date Time ── */
.datetime-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 7px 14px;
    background: linear-gradient(135deg, rgba(30,58,138,0.06), rgba(14,165,233,0.04));
    border-radius: var(--radius-md);
    border: 1px solid rgba(30,58,138,0.1);
    min-width: 160px;
}
.date-text { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.time-text { font-size: 11px; color: var(--text-secondary); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ── Notifications ── */
.notification-wrapper { position: relative; }
.notification-btn {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid rgba(30,58,138,0.1);
    cursor: pointer;
    padding: 9px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-smooth);
    display: flex;
    align-items: center;
}
.notification-btn:hover {
    background: var(--brand-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-blue);
}
.notification-btn svg { width: 20px; height: 20px; }

.notification-badge {
    position: absolute;
    top: 3px; right: 3px;
    background: var(--brand-rose);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 17px;
    text-align: center;
    border: 1.5px solid white;
}

.notification-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: 330px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: none;
    z-index: 1000;
    border: 1px solid rgba(30,58,138,0.08);
    overflow: hidden;
}
.notification-dropdown.show {
    display: block;
    animation: popIn 0.25s var(--transition-smooth) both;
}
@keyframes popIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.notification-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(30,58,138,0.03), rgba(14,165,233,0.02));
}
.notification-header h3 { font-size: 15px; font-weight: 700; }
.mark-read-btn {
    background: none; border: none;
    color: var(--brand-primary-light);
    font-size: 12px; cursor: pointer;
    font-weight: 600;
    transition: color var(--transition-fast);
}
.mark-read-btn:hover { color: var(--brand-primary); }
.notification-list { max-height: 380px; overflow-y: auto; }
.notification-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--bg-tertiary);
    display: flex;
    gap: 12px; cursor: pointer;
    transition: background var(--transition-fast);
}
.notification-item:hover { background: var(--bg-secondary); }
.notification-item.unread { background: rgba(59,130,246,0.04); }
.notification-icon { font-size: 22px; flex-shrink: 0; }
.notification-content { flex: 1; }
.notification-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.notification-time { font-size: 11px; color: var(--text-light); }

/* ── User Profile ── */
.user-profile { position: relative; }
.profile-btn {
    display: flex; align-items: center; gap: 10px;
    background: none; border: none;
    cursor: pointer;
    padding: 7px 12px;
    border-radius: var(--radius-xl);
    transition: all var(--transition-smooth);
    border: 1px solid transparent;
}
.profile-btn:hover {
    background: var(--bg-tertiary);
    border-color: rgba(30,58,138,0.1);
}
.profile-photo {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 2px solid var(--brand-primary-light);
    object-fit: cover;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.profile-info { display: flex; flex-direction: column; align-items: flex-start; }
.profile-name { font-size: 13px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.profile-role { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.profile-arrow { width: 14px; height: 14px; color: var(--text-light); transition: transform var(--transition-smooth); }
.profile-btn[aria-expanded="true"] .profile-arrow,
.profile-btn:hover .profile-arrow { transform: rotate(180deg); }

.profile-dropdown {
    position: absolute; right: 0; top: calc(100% + 10px);
    width: 220px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: none; z-index: 1000;
    border: 1px solid rgba(30,58,138,0.08);
    padding: 8px 0;
    overflow: hidden;
}
.profile-dropdown.show { display: block; animation: popIn 0.25s var(--transition-smooth) both; }

.dropdown-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 18px;
    color: var(--text-primary); text-decoration: none;
    transition: all var(--transition-fast);
    font-size: 13px; font-weight: 500;
}
.dropdown-item:hover { background: var(--bg-secondary); padding-left: 22px; }
.dropdown-item svg { width: 17px; height: 17px; color: var(--text-secondary); flex-shrink: 0; }
.dropdown-divider { height: 1px; background: var(--bg-tertiary); margin: 6px 0; }
.logout-item { color: var(--error-color); }
.logout-item svg { color: var(--error-color); }
.logout-item:hover { background: rgba(239,68,68,0.06); }

/* ──────────────────────────────────────
   DASHBOARD CONTENT
   ────────────────────────────────────── */
.dashboard-content {
    flex: 1;
    padding: 28px 32px 40px;
}

/* ── Period Toggle Row ── */
.dashboard-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.dashboard-greeting {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.dashboard-greeting span { 
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.period-toggle {
    display: flex;
    background: rgba(11, 21, 40, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-xl);
    padding: 4px;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.period-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-smooth);
}
.period-btn.active {
    background: linear-gradient(135deg, var(--nc-brand-primary, #0FA3D9), #0284C7);
    color: #FFFFFF;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 14px rgba(15, 163, 217, 0.35);
}
.period-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: rgba(11, 21, 40, 0.78);
    backdrop-filter: var(--nc-blur-card, blur(20px) saturate(160%));
    -webkit-backdrop-filter: var(--nc-blur-card, blur(20px) saturate(160%));
    border-radius: var(--radius-xl);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 18px;
    align-items: flex-start;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, border-color 0.28s ease;
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transform-style: preserve-3d;
    will-change: transform;
}

/* Specular top border shimmer */
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transition: opacity var(--transition-smooth);
    opacity: 0.85;
}
.stat-card.blue::after   { background: linear-gradient(90deg, #0FA3D9, #38BDF8); }
.stat-card.green::after  { background: linear-gradient(90deg, #10B981, #34D399); }
.stat-card.orange::after { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.stat-card.purple::after { background: linear-gradient(90deg, #8B5CF6, #A78BFA); }
.stat-card.cyan::after   { background: linear-gradient(90deg, #06B6D4, #38BDF8); }
.stat-card.teal::after   { background: linear-gradient(90deg, #0D9488, #2DD4BF); }
.stat-card.rose::after   { background: linear-gradient(90deg, #EC4899, #FB7185); }

/* Ambient category glows on hover */
.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.24);
}
.stat-card.blue:hover {
    box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.7), 0 0 32px rgba(15, 163, 217, 0.35);
    border-color: rgba(15, 163, 217, 0.45);
}
.stat-card.green:hover {
    box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.7), 0 0 32px rgba(16, 185, 129, 0.35);
    border-color: rgba(16, 185, 129, 0.45);
}
.stat-card.orange:hover {
    box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.7), 0 0 32px rgba(245, 158, 11, 0.35);
    border-color: rgba(245, 158, 11, 0.45);
}
.stat-card.purple:hover {
    box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.7), 0 0 32px rgba(139, 92, 246, 0.35);
    border-color: rgba(139, 92, 246, 0.45);
}
.stat-card.cyan:hover {
    box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.7), 0 0 32px rgba(6, 182, 212, 0.35);
    border-color: rgba(6, 182, 212, 0.45);
}
.stat-card.teal:hover {
    box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.7), 0 0 32px rgba(45, 212, 191, 0.35);
    border-color: rgba(45, 212, 191, 0.45);
}
.stat-card.rose:hover {
    box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.7), 0 0 32px rgba(236, 72, 153, 0.35);
    border-color: rgba(236, 72, 153, 0.45);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform var(--transition-elastic);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateZ(18px);
}
.stat-card:hover .stat-icon { transform: translateZ(24px) scale(1.1) rotate(-4deg); }
.stat-icon svg { width: 26px; height: 26px; }

.stat-card.blue .stat-icon   { background: rgba(15, 163, 217, 0.15);  color: #38BDF8; }
.stat-card.green .stat-icon  { background: rgba(16, 185, 129, 0.15); color: #34D399; }
.stat-card.orange .stat-icon { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.stat-card.purple .stat-icon { background: rgba(139, 92, 246, 0.15); color: #A78BFA; }
.stat-card.cyan .stat-icon   { background: rgba(6, 182, 212, 0.15);  color: #67E8F9; }
.stat-card.teal .stat-icon   { background: rgba(13, 148, 136, 0.15); color: #2DD4BF; }
.stat-card.rose .stat-icon   { background: rgba(236, 72, 153, 0.15); color: #F472B6; }

.stat-content { flex: 1; min-width: 0; }
.stat-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.stat-value {
    font-family: 'Outfit', -apple-system, sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
}

.stat-change {
    font-size: 12px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
}
.stat-change.positive { color: #34D399; background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.25); }
.stat-change.negative { color: #F87171; background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.25); }
.stat-change.neutral  { color: var(--text-secondary); background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }

/* ── Charts Grid ── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
}

.chart-card {
    background: rgba(11, 21, 40, 0.78);
    backdrop-filter: var(--nc-blur-card, blur(20px) saturate(160%));
    -webkit-backdrop-filter: var(--nc-blur-card, blur(20px) saturate(160%));
    border-radius: var(--radius-xl);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth), transform var(--transition-smooth);
}
.chart-card:hover {
    border-color: rgba(15, 163, 217, 0.3);
    box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.7), 0 0 25px rgba(15, 163, 217, 0.12);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.chart-title {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.chart-filter {
    padding: 7px 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-xl);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-primary);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    font-family: inherit;
}
.chart-filter:focus, .chart-filter:hover {
    border-color: var(--nc-brand-primary, #0FA3D9);
    box-shadow: 0 0 0 3px rgba(15, 163, 217, 0.2);
}

.chart-tabs { display: flex; gap: 6px; }
.tab-btn {
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
    font-family: inherit;
}
.tab-btn.active {
    background: linear-gradient(135deg, var(--nc-brand-primary, #0FA3D9), #0284C7);
    color: #FFFFFF;
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 10px rgba(15, 163, 217, 0.35);
}
.tab-btn:hover:not(.active) {
    border-color: rgba(15, 163, 217, 0.4);
    color: var(--text-primary);
}

.chart-container { position: relative; height: 280px; }

/* Chart Loading */
.chart-loading {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: rgba(11, 21, 40, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
    border-radius: var(--radius-md);
    gap: 12px;
}
.chart-loading.hidden { display: none; }

.spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--nc-brand-primary, #0FA3D9);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chart-loading p { color: var(--text-secondary); font-size: 13px; font-weight: 500; }

/* ── Stats Error Banner ── */
#statsError {
    border-radius: var(--radius-md);
    border-left: 4px solid var(--error-color);
    animation: slideDown 0.3s ease-out;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ──────────────────────────────────────
   RESPONSIVE
   ────────────────────────────────────── */
@media (max-width: 1200px) {
    .charts-grid { grid-template-columns: 1fr; }
    .datetime-display { display: none; }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
    }
    .sidebar.show { transform: translateX(0); box-shadow: 4px 0 30px rgba(0,0,0,0.3); }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: flex !important; align-items: center; justify-content: center; }

    /* Backdrop overlay */
    .sidebar.show::after {
        content: '';
        position: fixed;
        top: 0; left: var(--sidebar-width);
        width: calc(100vw - var(--sidebar-width));
        height: 100vh;
        background: rgba(0,0,0,0.45);
        backdrop-filter: blur(2px);
        z-index: -1;
    }
}

@media (max-width: 768px) {
    .header { padding: 14px 20px; }
    .dashboard-content { padding: 20px 16px 32px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .stat-value { font-size: 24px; }
    .page-title { font-size: 18px; }
    .dashboard-header-row { flex-direction: column; align-items: flex-start; }
    .period-toggle { align-self: stretch; justify-content: center; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 16px 18px; }
    .header-right { gap: 10px; }
}

/* ──────────────────────────────────────
   ACCESSIBILITY
   ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states */
.nav-item:focus-visible,
.notification-btn:focus-visible,
.profile-btn:focus-visible,
.period-btn:focus-visible,
.tab-btn:focus-visible {
    outline: 2px solid var(--brand-primary-light);
    outline-offset: 2px;
}

/* ──────────────────────────────────────
   SCROLL REVEAL ANIMATIONS
   ────────────────────────────────────── */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}
/* ── Nav Group Dropdown ── */
.nav-group {
    margin: 2px 10px;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.nav-group-header {
    margin: 0 !important;
}
.nav-group-header .chevron {
    transition: transform 0.3s;
}
.nav-group.expanded .nav-group-header .chevron {
    transform: rotate(180deg);
}
.nav-group.expanded .nav-group-header {
    background: rgba(255,255,255,0.05);
}
.nav-subitems {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: rgba(0,0,0,0.15);
}
.nav-group.expanded .nav-subitems {
    max-height: 500px;
}
.nav-subitem {
    display: block;
    padding: 10px 16px 10px 48px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}
.nav-subitem::before {
    content: '';
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    transition: background 0.2s;
}
.nav-subitem:hover {
    color: white;
    background: rgba(255,255,255,0.05);
}
.nav-subitem:hover::before {
    background: var(--brand-secondary);
}
.nav-subitem.active {
    color: white;
    font-weight: 600;
    background: rgba(59,130,246,0.15);
}
.nav-subitem.active::before {
    background: var(--brand-primary-light);
    box-shadow: 0 0 8px var(--brand-primary-light);
}

/* ── Nav Dropdown (Posts Management group) ──────────────── */
.nav-dropdown {
    display: flex;
    flex-direction: column;
}
.nav-dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    text-align: left;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s;
    position: relative;
    margin: 2px 12px;
}
.nav-dropdown-toggle::before {
    content: '';
    position: absolute;
    left: 0; top: 25%; bottom: 25%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-primary, #3b82f6);
    transform: scaleY(0);
    transition: transform 0.2s;
}
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.active {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}
.nav-dropdown-toggle:hover::before,
.nav-dropdown-toggle.active::before {
    transform: scaleY(1);
}
.nav-dropdown-menu {
    display: none;
    flex-direction: column;
    padding-left: 14px;
    margin-top: 2px;
    border-left: 2px solid rgba(59, 130, 246, 0.2);
    margin-left: 22px;
}
.nav-dropdown.open .nav-dropdown-menu {
    display: flex;
}
.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 2px;
}
.nav-sub-item:hover {
    background: rgba(59, 130, 246, 0.07);
    color: #3b82f6;
}
.nav-sub-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    font-weight: 600;
}
.nav-sub-item .nav-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}
.nav-dropdown-arrow {
    transition: transform 0.25s ease;
}

/* ──────────────────────────────────────
   DYNAMIC CHARTS — LIVE INDICATORS
   ────────────────────────────────────── */

/* ── Dashboard Actions Row (Live badge + Refresh) ── */
.dashboard-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Live Badge ── */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    color: #059669;
    letter-spacing: 0.3px;
    user-select: none;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    animation: livePulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.live-badge.offline {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: #dc2626;
}
.live-badge.offline .live-dot {
    background: #ef4444;
    animation: none;
    box-shadow: none;
}

/* ── Manual Refresh Button ── */
.refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(30, 58, 138, 0.12);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-smooth);
    font-family: inherit;
}

.refresh-btn:hover {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.25);
    transform: translateY(-1px);
}

.refresh-btn:active { transform: translateY(0); }

.refresh-btn.spinning .refresh-icon {
    animation: spinOnce 0.7s linear;
}

@keyframes spinOnce {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.refresh-icon {
    font-size: 13px;
    display: inline-block;
    line-height: 1;
}

/* ── Last Updated Timestamp ── */
.last-updated-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    min-height: 22px;
}

.last-updated-text {
    font-size: 11.5px;
    color: var(--text-light);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.last-updated-text .refresh-status {
    color: var(--brand-emerald);
    font-weight: 600;
}

/* ── Chart Empty Overlay ── */
.chart-empty-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(248, 250, 252, 0.92);
    backdrop-filter: blur(3px);
    z-index: 5;
    border-radius: var(--radius-sm);
    pointer-events: none;
}

.chart-empty-overlay .empty-icon {
    font-size: 28px;
    opacity: 0.45;
}

.chart-empty-overlay .empty-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.chart-empty-overlay .empty-sub {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 500;
}

/* ── Stat Card Refresh Shimmer ── */
.stat-value.refreshing {
    background: linear-gradient(90deg,
        rgba(30, 58, 138, 0.06) 0%,
        rgba(59, 130, 246, 0.12) 40%,
        rgba(30, 58, 138, 0.06) 80%);
    background-size: 200% 100%;
    animation: statShimmer 1.2s linear infinite;
    border-radius: 6px;
    color: transparent !important;
    min-width: 60px;
    min-height: 30px;
    display: inline-block;
}

@keyframes statShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Chart card live border flash on new data ── */
.chart-card.data-updated {
    animation: chartFlash 0.6s ease-out;
}

@keyframes chartFlash {
    0%   { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.5); }
    100% { box-shadow: var(--shadow-sm); }
}

/* ── Auto-refresh progress bar ── */
.refresh-progress {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(59, 130, 246, 0.12);
    z-index: 9999;
    display: none;
}

.refresh-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary), var(--brand-emerald));
    background-size: 200% 100%;
    transition: width linear;
    animation: progressGlow 2s ease-in-out infinite;
}

@keyframes progressGlow {
    0%, 100% { background-position: 0% 0; }
    50%      { background-position: 100% 0; }
}

/* ── Light Theme Overrides ───────────────────────────────────────────── */
:root[data-theme="light"] .stat-card,
:root[data-theme="light"] .chart-card,
:root[data-theme="light"] .quick-action-card,
:root[data-theme="light"] .recent-activity-card,
:root[data-theme="light"] .system-health-card {
    background: #FFFFFF !important;
    border: 1px solid rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05) !important;
}

:root[data-theme="light"] .stat-title,
:root[data-theme="light"] .chart-title {
    color: #0F172A !important;
}

:root[data-theme="light"] .chart-filter,
:root[data-theme="light"] .tab-btn {
    background: #F8FAFC !important;
    border: 1px solid rgba(15, 23, 42, 0.12) !important;
    color: #334155 !important;
}

:root[data-theme="light"] .chart-filter:hover,
:root[data-theme="light"] .tab-btn:hover {
    background: #FFFFFF !important;
    border-color: #0FA3D9 !important;
    color: #0284C7 !important;
}

:root[data-theme="light"] .tab-btn.active {
    background: #0284C7 !important;
    color: #FFFFFF !important;
    border-color: #0284C7 !important;
}

:root[data-theme="light"] .stat-value {
    color: #0F172A !important;
}

