/* ============================================
   NEXUS — Traffic Intelligence Platform
   Modern Command Center Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(99, 102, 241, 0.12);
    --sidebar-active: rgba(99, 102, 241, 0.18);
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #e2e8f0;
    --sidebar-width: 260px;
    --sidebar-mini: 68px;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --bg: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-light: rgba(99, 102, 241, 0.08);
    --accent-glow: rgba(99, 102, 241, 0.25);
    --cyan: #06b6d4;
    --emerald: #10b981;
    --amber: #f59e0b;
    --rose: #f43f5e;
    --violet: #8b5cf6;
    --topbar-h: 56px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg);
    color: var(--text-primary);
    margin: 0;
}

/* === MudBlazor Overrides === */

/* App Bar — clean white topbar */
.mud-appbar.app-topbar {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border) !important;
    box-shadow: none !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.mud-appbar.app-topbar .mud-icon-button { color: var(--text-secondary) !important; }
.mud-appbar.app-topbar .mud-icon-button:hover { color: var(--accent) !important; background: var(--accent-light) !important; }

/* Drawer / Sidebar */
.mud-drawer {
    background: var(--sidebar-bg) !important;
    border-right: 1px solid rgba(255,255,255,0.06) !important;
    box-shadow: none !important;
}

/* Nav Links */
.mud-navmenu .mud-nav-link {
    border-radius: 8px !important;
    margin: 1px 10px !important;
    padding: 8px 12px !important;
    color: var(--sidebar-text) !important;
    font-size: 0.835rem !important;
    font-weight: 450 !important;
    transition: all var(--transition) !important;
    height: auto !important;
    min-height: 38px !important;
}
.mud-navmenu .mud-nav-link:hover {
    background: var(--sidebar-hover) !important;
    color: var(--sidebar-text-active) !important;
}
.mud-navmenu .mud-nav-link.active {
    background: var(--sidebar-active) !important;
    color: #fff !important;
    font-weight: 600 !important;
    box-shadow: 0 0 20px var(--accent-glow);
}
.mud-navmenu .mud-nav-link.active .mud-icon-root {
    color: #818cf8 !important;
}
.mud-navmenu .mud-nav-link .mud-icon-root {
    color: var(--sidebar-text) !important;
    font-size: 1.2rem !important;
    margin-right: 10px;
}
.mud-navmenu .mud-nav-link:hover .mud-icon-root {
    color: #a5b4fc !important;
}

/* Nav Groups */
.mud-navmenu .mud-nav-group .mud-nav-group-text {
    color: var(--sidebar-text) !important;
    font-size: 0.835rem !important;
    font-weight: 450 !important;
    padding: 8px 12px !important;
    margin: 1px 10px !important;
    border-radius: 8px !important;
}
.mud-navmenu .mud-nav-group .mud-nav-group-text:hover {
    background: var(--sidebar-hover) !important;
    color: var(--sidebar-text-active) !important;
}
.mud-navmenu .mud-nav-group .mud-collapse-wrapper .mud-nav-link {
    padding-left: 20px !important;
    font-size: 0.8rem !important;
    min-height: 34px !important;
}

/* Nav section labels */
.nav-section-label {
    color: #475569;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 16px 22px 6px;
    user-select: none;
}

/* Sidebar logo area */
.sidebar-brand {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 8px;
}
.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-brand .brand-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.2;
}
.sidebar-brand .brand-sub {
    font-size: 0.65rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* === Card System === */
.nexus-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
}
.nexus-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-md);
}

/* KPI Cards */
.kpi-card {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: none !important;
    transition: all var(--transition) !important;
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}
.kpi-card.kpi-accent::before { background: var(--accent); }
.kpi-card.kpi-cyan::before { background: var(--cyan); }
.kpi-card.kpi-emerald::before { background: var(--emerald); }
.kpi-card.kpi-amber::before { background: var(--amber); }
.kpi-card.kpi-rose::before { background: var(--rose); }
.kpi-card.kpi-violet::before { background: var(--violet); }
.kpi-card:hover {
    border-color: #cbd5e1 !important;
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-1px);
}
.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    line-height: 1;
}
.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}
.kpi-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
.kpi-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kpi-icon-wrap.bg-accent { background: rgba(99,102,241,0.1); color: var(--accent); }
.kpi-icon-wrap.bg-cyan { background: rgba(6,182,212,0.1); color: var(--cyan); }
.kpi-icon-wrap.bg-emerald { background: rgba(16,185,129,0.1); color: var(--emerald); }
.kpi-icon-wrap.bg-amber { background: rgba(245,158,11,0.1); color: var(--amber); }
.kpi-icon-wrap.bg-rose { background: rgba(244,63,94,0.1); color: var(--rose); }
.kpi-icon-wrap.bg-violet { background: rgba(139,92,246,0.1); color: var(--violet); }

/* === Status Badges === */
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.online { background: var(--emerald); box-shadow: 0 0 8px rgba(16,185,129,0.4); }
.status-dot.offline { background: var(--rose); box-shadow: 0 0 8px rgba(244,63,94,0.3); }
.status-dot.warning { background: var(--amber); }

/* === Tables === */
.mud-table-container {
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
}
.mud-table-head .mud-table-cell {
    font-weight: 600 !important;
    font-size: 0.7rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.6px !important;
    color: var(--text-muted) !important;
    background: var(--surface-hover) !important;
    border-bottom: 1px solid var(--border) !important;
}
.mud-table-body .mud-table-row:hover {
    background: var(--accent-light) !important;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* === Login Page === */
.login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    position: relative;
    overflow: hidden;
}
.login-bg::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
    top: -200px; right: -100px;
    border-radius: 50%;
}
.login-bg::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(6,182,212,0.1) 0%, transparent 70%);
    bottom: -150px; left: -100px;
    border-radius: 50%;
}
.login-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(99,102,241,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99,102,241,0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 40%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 40%, transparent 100%);
}
.login-card {
    position: relative;
    z-index: 1;
    width: 400px;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: 20px;
    padding: 40px;
}
.login-card .mud-input-outlined .mud-input-outlined-border {
    border-color: rgba(148,163,184,0.2) !important;
}
.login-card .mud-input-outlined:hover .mud-input-outlined-border {
    border-color: rgba(99,102,241,0.4) !important;
}
.login-card .mud-input-outlined.mud-input-focused .mud-input-outlined-border {
    border-color: #6366f1 !important;
}
.login-card .mud-input-label {
    color: #94a3b8 !important;
}
.login-card .mud-input-text input {
    color: #e2e8f0 !important;
}
.login-card .mud-input-adornment .mud-icon-root {
    color: #64748b !important;
}
.login-card .mud-checkbox .mud-primary-text { color: #94a3b8 !important; }

/* Login brand */
.login-brand {
    text-align: center;
    margin-bottom: 32px;
}
.login-brand-icon {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(99,102,241,0.3);
}
.login-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
}
.login-brand p {
    font-size: 0.85rem;
    color: #64748b;
    margin: 6px 0 0;
}

/* === Animations === */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(99,102,241,0.2); }
    50% { box-shadow: 0 0 20px rgba(99,102,241,0.4); }
}
@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fade-in 0.4s ease-out both; }
.animate-in-1 { animation-delay: 0.05s; }
.animate-in-2 { animation-delay: 0.1s; }
.animate-in-3 { animation-delay: 0.15s; }
.animate-in-4 { animation-delay: 0.2s; }

/* === Dashboard Specifics === */
.dash-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}
.dash-greeting {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.dash-greeting-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Status list items */
.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.status-row:last-child { border-bottom: none; }
.status-row-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.status-row-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Map container */
.map-container {
    border-radius: var(--radius);
    overflow: hidden;
    background: #e2e8f0;
}

/* === Utility === */
.cursor-pointer { cursor: pointer; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.border-bottom { border-bottom: 1px solid var(--border); }

/* === Responsive === */
@media (max-width: 600px) {
    .hide-mobile { display: none !important; }
    .login-card { width: calc(100vw - 32px); padding: 28px; }
}

/* === Print === */
@media print {
    .mud-appbar, .mud-drawer, .no-print { display: none !important; }
    .mud-main-content { margin-left: 0 !important; padding: 0 !important; }
}

/* === Dark Mode Adjustments === */
.mud-theme-dark .nexus-card,
.mud-theme-dark .kpi-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
.mud-theme-dark .kpi-value { color: #f1f5f9; }
.mud-theme-dark .status-row { border-color: #334155; }
