/* ═══════════════════════════════════════════════════════════════
   Network Monitor v5.0 — Main CSS
   Core variables, reset, typography, scrollbars
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Dark theme (default) */
    --b0: #06090f;
    --b1: #0c1018;
    --b2: #111722;
    --b3: #171f2e;
    --b4: #1d2738;
    --bh: #232e42;
    --br0: #1a2332;
    --br1: #243044;
    --br2: #2e3d56;
    --t0: #f1f5f9;
    --t1: #cbd5e1;
    --t2: #8b9bb4;
    --t3: #56657e;
    --blue: #2d8cf0;
    --bd: rgba(45, 140, 240, .12);
    --cyan: #00d4aa;
    --cd: rgba(0, 212, 170, .1);
    --green: #34d399;
    --gd: rgba(52, 211, 153, .1);
    --yel: #fbbf24;
    --yd: rgba(251, 191, 36, .08);
    --ora: #fb923c;
    --od: rgba(251, 146, 60, .1);
    --red: #f43f5e;
    --rd: rgba(244, 63, 94, .08);
    --pur: #a78bfa;
    --pd: rgba(167, 139, 250, .1);
    --f: 'DM Sans', system-ui, -apple-system, sans-serif;
    --m: 'IBM Plex Mono', 'Fira Code', monospace;
    --r: 10px;
    --rs: 6px;
    --rl: 16px;
    --transition: 0.2s ease;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-modal: 0 8px 32px rgba(0, 0, 0, 0.5);
    --sidebar-width: 220px;
    --sidebar-collapsed: 56px;
    --header-height: 48px;
    /* Compatibility aliases used by JS-generated inline styles */
    --bg2: var(--b2);
    --bg3: var(--b3);
    --bg4: var(--b4);
    /* Glow system — multi-layer box-shadows */
    --glow-cyan:  0 0 0 1px rgba(0,212,170,.15), 0 0 20px rgba(0,212,170,.18), 0 0 40px rgba(0,212,170,.06);
    --glow-blue:  0 0 0 1px rgba(45,140,240,.15), 0 0 20px rgba(45,140,240,.18), 0 0 40px rgba(45,140,240,.06);
    --glow-red:   0 0 0 1px rgba(244,63,94,.2),   0 0 20px rgba(244,63,94,.22),  0 0 40px rgba(244,63,94,.08);
    --glow-green: 0 0 0 1px rgba(52,211,153,.15), 0 0 20px rgba(52,211,153,.18), 0 0 40px rgba(52,211,153,.06);
    --glow-yel:   0 0 0 1px rgba(251,191,36,.15), 0 0 20px rgba(251,191,36,.18), 0 0 40px rgba(251,191,36,.06);
    --glow-pur:   0 0 0 1px rgba(167,139,250,.15),0 0 20px rgba(167,139,250,.18),0 0 40px rgba(167,139,250,.06);
    /* Elevation shadow scale */
    --sh1: 0 1px 2px rgba(0,0,0,.2);
    --sh2: 0 2px 8px rgba(0,0,0,.25);
    --sh3: 0 4px 16px rgba(0,0,0,.3);
    --sh4: 0 8px 32px rgba(0,0,0,.4);
    --sh5: 0 16px 56px rgba(0,0,0,.5);
    /* Spring & expo easing */
    --ease-spring: cubic-bezier(.34,1.56,.64,1);
    --ease-expo:   cubic-bezier(.16,1,.3,1);
}

/* Light Theme */
html[data-theme="light"] {
    --b0: #f8fafc;
    --b1: #f1f5f9;
    --b2: #e2e8f0;
    --b3: #cbd5e1;
    --b4: #94a3b8;
    --bh: #e2e8f0;
    --br0: #cbd5e1;
    --br1: #94a3b8;
    --br2: #64748b;
    --t0: #0f172a;
    --t1: #1e293b;
    --t2: #475569;
    --t3: #64748b;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-modal: 0 8px 32px rgba(0,0,0,0.12);
    --bd: rgba(45, 140, 240, .08);
    --cd: rgba(0, 212, 170, .08);
    --gd: rgba(52, 211, 153, .08);
    --yd: rgba(251, 191, 36, .06);
    --od: rgba(251, 146, 60, .08);
    --rd: rgba(244, 63, 94, .06);
    --pd: rgba(167, 139, 250, .08);
}
html[data-theme="light"] body::before {
    background: radial-gradient(ellipse at 20% 50%, rgba(45,140,240,.04) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(0,212,170,.03) 0%, transparent 50%);
}
html[data-theme="light"] ::-webkit-scrollbar-track { background: #e2e8f0; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #94a3b8; }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--f);
    background: var(--b0);
    color: var(--t0);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(45, 140, 240, .03), transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 212, 170, .02), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

html[data-theme="light"] body::before { display: none; }

/* Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--br1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--br2); }

/* Typography */
h1 { font-size: 15px; font-weight: 600; }
h2 { font-size: 14px; font-weight: 600; }
h3 { font-size: 12px; font-weight: 600; }
h4 { font-size: 11px; font-weight: 600; }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre { font-family: var(--m); }

/* Selection */
::selection {
    background: rgba(45, 140, 240, 0.3);
    color: var(--t0);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes bl {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

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

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.3); }
}

@keyframes rp {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 12px var(--rd); }
}

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

@keyframes pulse-risky {
    0%, 100% { box-shadow: 0 0 0 0 var(--rd); }
    50% { box-shadow: 0 0 20px 10px var(--rd); }
}

@keyframes pulse-kc {
    0%, 100% { box-shadow: 0 0 5px var(--rd); }
    50% { box-shadow: 0 0 20px var(--rd); }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes map-pulse {
    0%, 100% { transform: scale(1); opacity: .3; }
    50% { transform: scale(2); opacity: 0; }
}

@keyframes flow-pulse {
    0%, 100% { opacity: .3; }
    50% { opacity: 1; }
}

@keyframes count-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes skeletonPulse {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

@keyframes notifPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.3); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1); }
}
.notif-count.pulse { animation: notifPulse .4s ease; }

/* Mobile sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed; top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,.5); z-index: 299;
}
.sidebar-backdrop.show { display: block; }

/* Smooth view transition */
.view-transition { animation: fadeIn .2s ease; }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--b3) 25%, var(--b4) 50%, var(--b3) 75%);
    background-size: 200px 100%;
    animation: skeletonPulse 1.5s ease-in-out infinite;
    border-radius: var(--rs);
}

/* Spinner */
.sp {
    width: 9px; height: 9px;
    border: 2px solid var(--br1);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: sp .8s linear infinite;
}

.sp-lg {
    width: 24px; height: 24px;
    border: 3px solid var(--br1);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: sp .8s linear infinite;
}

/* Utility classes */
.text-center { text-align: center; }
.text-muted { color: var(--t3); }
.text-mono { font-family: var(--m); }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: 6px; }
.gap-md { gap: 10px; }
.gap-lg { gap: 16px; }

/* ── Ultra-Advanced Keyframes ── */
@keyframes springIn {
    0%   { opacity: 0; transform: translateY(10px) scale(.94); }
    60%  { opacity: 1; transform: translateY(-3px) scale(1.02); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes flashUpdate {
    0%   { color: inherit; }
    25%  { color: var(--yel); text-shadow: 0 0 12px var(--yel); }
    100% { color: inherit; text-shadow: none; }
}

@keyframes livePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,.5); opacity:1; }
    50%       { box-shadow: 0 0 0 5px rgba(52,211,153,0); opacity:.7; }
}

@keyframes loadbarProgress {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes toastSlideIn {
    from { opacity:0; transform: translateX(100%) scale(.92); }
    to   { opacity:1; transform: translateX(0) scale(1); }
}

@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

@keyframes badgeBounce {
    0%,100% { transform: scale(1); }
    30%  { transform: scale(1.4); }
    60%  { transform: scale(.9); }
    80%  { transform: scale(1.1); }
}

/* ── Pulse class — used by badge on new alert ── */
.pulse {
    animation: badgeBounce .5s var(--ease-spring) both;
}

/* ── Top Loading Bar ── */
#nmLoadBar {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 2px;
    z-index: 9999;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity .15s;
}

#nmLoadBar.active { opacity: 1; }

#nmLoadBar::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: 45%;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--blue), transparent);
    animation: loadbarProgress 1.1s ease-in-out infinite;
    border-radius: 1px;
}

/* ── Ripple Effect ── */
.ripple-wave {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: rippleExpand .5s linear;
    background: rgba(255,255,255,.25);
    pointer-events: none;
}

@keyframes rippleExpand {
    to { transform: scale(4); opacity: 0; }
}

/* ── Live dot indicator ── */
.live-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: livePulse 2s ease-in-out infinite;
    margin-left: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ── Reduce motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
