/* =============================================
   NYAXUS v7 — SKEUOMORPHIC AERO × SKEUOCORD
   Base: layout, chrome, panels, sidebar, footer,
   dark theme, accessibility.
   SkeuoCord-inspired: double-layer shadows,
   text depth, pressed states, avatar borders.
   ============================================= */

:root {
    /* Light theme — Frutiger Aero */
    --page-bg: #e0ecf8;
    --page-bg-grad: linear-gradient(
        160deg,
        #eef6fc 0%,
        #e0eaf4 40%,
        #d0e0f0 100%
    );
    --tile-bg: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.92) 0%,
        rgba(248, 252, 255, 0.85) 40%,
        rgba(232, 242, 250, 0.75) 100%
    );
    --tile-hover: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(250, 253, 255, 0.9) 40%,
        rgba(240, 248, 255, 0.82) 100%
    );
    --chrome-border: rgba(120, 150, 180, 0.4);
    --chrome-border-light: rgba(140, 170, 200, 0.3);
    --chrome-text: #0f1a25;
    --chrome-text-dim: #3a5068;
    --chrome-dark: #0d1b2a;
    --trace: #0077aa;
    --trace-bright: #0099cc;
    --trace-glow: rgba(0, 180, 220, 0.35);
    --trace-dim: rgba(0, 160, 200, 0.15);
    --hud-ok: #007a5e;
    --hud-warn: #a06000;
    --hud-err: #992222;
    --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
    --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;

    --focus-ring: 0 0 0 3px rgba(0, 180, 230, 0.4);
    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 10px;

    /* SkeuoCord double-layer shadows: inner light ring + outer dark shadow */
    --shadow-sm:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 0 0 1px rgba(255, 255, 255, 0.5), 0 1px 2px rgba(0, 30, 60, 0.1),
        0 2px 4px rgba(0, 30, 60, 0.06);
    --shadow-md:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 30, 60, 0.12),
        0 4px 12px rgba(0, 30, 60, 0.08);
    --shadow-lg:
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.3), 0 4px 12px rgba(0, 30, 60, 0.15),
        0 8px 24px rgba(0, 30, 60, 0.1);
    --shadow-pressed:
        inset 0 2px 4px rgba(0, 30, 60, 0.15),
        inset 0 1px 2px rgba(0, 30, 60, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.3);

    --glass: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.5);
}

/* =============================================
   DARK THEME — Dark Aero / Liquid Glass
   ============================================= */
[data-theme="dark"] {
    --page-bg: #080d14;
    --page-bg-grad: linear-gradient(
        160deg,
        #0a1120 0%,
        #080d14 50%,
        #060a10 100%
    );
    --tile-bg: linear-gradient(
        180deg,
        rgba(32, 48, 72, 0.9) 0%,
        rgba(24, 38, 58, 0.85) 40%,
        rgba(18, 28, 44, 0.8) 100%
    );
    --tile-hover: linear-gradient(
        180deg,
        rgba(40, 60, 88, 0.95) 0%,
        rgba(32, 48, 72, 0.9) 40%,
        rgba(24, 38, 58, 0.85) 100%
    );
    --chrome-border: rgba(80, 120, 160, 0.4);
    --chrome-border-light: rgba(60, 100, 140, 0.3);
    --chrome-text: #e0f0ff;
    --chrome-text-dim: #90b0d0;
    --chrome-dark: #c0d8f0;
    --trace: #00d4f0;
    --trace-bright: #40e8ff;
    --trace-glow: rgba(0, 220, 255, 0.45);
    --trace-dim: rgba(0, 200, 240, 0.2);
    --hud-ok: #00e0a0;
    --hud-warn: #ffc840;
    --hud-err: #ff6060;

    /* Dark double-layer: inner dark ring + outer darker shadow */
    --shadow-sm:
        inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.3),
        0 1px 3px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-md:
        inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.35),
        0 2px 8px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg:
        inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.4),
        0 4px 16px rgba(0, 0, 0, 0.5), 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-pressed:
        inset 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 3px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.3);

    --glass: rgba(20, 36, 56, 0.6);
    --glass-border: rgba(60, 100, 140, 0.35);
}

/* =============================================
   REDUCED MOTION
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    body * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    font-family: var(--font-ui);
    color: var(--chrome-text);
    background: var(--page-bg-grad);
    background-attachment: fixed;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

*:focus {
    outline: none;
}
*:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

/* =============================================
   GLASS MESH BACKGROUND
   ============================================= */
.glass-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .glass-canvas {
        display: none;
    }
}

/* =============================================
   CHROME HEADER — SkeuoCord glossy bar
   ============================================= */
.chrome-header {
    position: relative;
    z-index: 10;
    height: 40px;
    background: var(--tile-bg);
    border-bottom: 1px solid var(--chrome-border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

/* Text depth shadow */
.chrome-header .title {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--chrome-dark);
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.4),
        0 -1px 0 rgba(0, 0, 0, 0.05);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

[data-theme="dark"] .chrome-header .title {
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.5),
        0 0 4px rgba(0, 0, 0, 0.3);
}

.chrome-header .header-trace {
    flex: 1;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--trace-dim) 20%,
        var(--trace-bright) 50%,
        var(--trace-dim) 80%,
        transparent 100%
    );
    border-radius: 1px;
    min-width: 40px;
}

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

.version-pill {
    font-family: var(--font-mono);
    font-size: 0.7em;
    color: var(--chrome-text-dim);
    background: rgba(0, 30, 60, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--chrome-border-light);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .version-pill {
    background: rgba(255, 255, 255, 0.08);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Theme toggle */
.theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--chrome-border);
    border-radius: var(--radius-sm);
    background: var(--tile-bg);
    cursor: pointer;
    font-size: 0.9em;
    color: var(--chrome-text-dim);
    transition: all 0.15s ease;
    padding: 0;
    box-shadow: var(--shadow-sm);
}

.theme-btn:hover {
    border-color: var(--trace-bright);
    color: var(--trace-bright);
    box-shadow:
        0 0 0 1px var(--trace-dim),
        0 0 10px var(--trace-glow),
        var(--shadow-sm);
}

.theme-btn .theme-icon-dark {
    display: none;
}
[data-theme="dark"] .theme-btn .theme-icon-light {
    display: none;
}
[data-theme="dark"] .theme-btn .theme-icon-dark {
    display: inline;
}

/* Header login form */
.header-login-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-input {
    width: 130px;
    padding: 4px 8px;
    font-family: var(--font-ui);
    font-size: 0.78em;
    border: 1px solid var(--chrome-border);
    border-radius: var(--radius-sm);
    background: var(--glass);
    color: var(--chrome-text);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
    height: 28px;
    line-height: 1;
}

.header-input:focus {
    border-color: var(--trace-bright);
    box-shadow: 0 0 0 2px var(--trace-dim);
    outline: none;
}

.header-btn {
    padding: 4px 12px;
    font-size: 0.75em;
    height: 28px;
    line-height: 1;
}

/* =============================================
   APP SHELL
   ============================================= */
.app-shell {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px 20px 30px;
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 1fr auto;
    gap: 16px;
    min-height: calc(100vh - 40px);
}

/* =============================================
   PANEL — SkeuoCord raised bezel
   ============================================= */
.panel {
    background: var(--tile-bg);
    border: 1px solid var(--chrome-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
    backdrop-filter: blur(12px) saturate(1.1);
    -webkit-backdrop-filter: blur(12px) saturate(1.1);
}

/* SkeuoCord glossy highlight strip */
.panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.7) 15%,
        rgba(255, 255, 255, 0.9) 50%,
        rgba(255, 255, 255, 0.7) 85%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 2;
}

/* Bottom shadow for depth */
.panel::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 0, 0, 0.03) 15%,
        rgba(0, 0, 0, 0.06) 50%,
        rgba(0, 0, 0, 0.03) 85%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 2;
}

[data-theme="dark"] .panel::before {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.12) 15%,
        rgba(255, 255, 255, 0.18) 50%,
        rgba(255, 255, 255, 0.12) 85%,
        transparent 100%
    );
}

[data-theme="dark"] .panel::after {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 0, 0, 0.2) 15%,
        rgba(0, 0, 0, 0.3) 50%,
        rgba(0, 0, 0, 0.2) 85%,
        transparent 100%
    );
}

.panel:hover {
    border-color: rgba(0, 180, 220, 0.45);
    box-shadow:
        var(--shadow-lg),
        0 0 24px var(--trace-dim);
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    grid-row: 1 / 2;
}

.sidebar-brand {
    padding: 16px;
    text-align: center;
}

/* Mascot with SkeuoCord avatar-style border */
.mascot-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 10px;
    position: relative;
}

.mascot-icon .head {
    position: absolute;
    top: 4px;
    left: 50%;
    width: 32px;
    height: 28px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, var(--trace-bright), var(--trace));
    border-radius: 50% 50% 45% 45%;
    box-shadow: 0 0 12px var(--trace-glow);
}

.mascot-icon .ear {
    position: absolute;
    top: 0;
    width: 10px;
    height: 14px;
    background: linear-gradient(180deg, var(--trace-bright), var(--trace));
    border-radius: 50% 50% 0 0;
}

.mascot-icon .ear.left {
    left: 4px;
    transform: rotate(-12deg);
}
.mascot-icon .ear.right {
    right: 4px;
    transform: rotate(12deg);
}

.mascot-icon .hp {
    position: absolute;
    top: 10px;
    left: 50%;
    width: 42px;
    height: 5px;
    transform: translateX(-50%);
    background: var(--chrome-dark);
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mascot-icon .tail {
    position: absolute;
    bottom: 2px;
    left: 50%;
    width: 3px;
    height: 16px;
    transform: translateX(-50%);
    background: linear-gradient(
        180deg,
        var(--chrome-dark),
        var(--trace-bright)
    );
    border-radius: 2px;
}

.mascot-icon .tail::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 50%;
    width: 6px;
    height: 6px;
    transform: translateX(-50%);
    background: var(--trace-bright);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--trace-glow);
}

.sidebar-brand h1 {
    font-size: 1.1em;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--chrome-dark);
    text-transform: uppercase;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .sidebar-brand h1 {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.sidebar-brand .version {
    font-family: var(--font-mono);
    font-size: 0.65em;
    color: var(--chrome-text-dim);
    margin-top: 2px;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    grid-row: 1 / 2;
}

/* =============================================
   FOOTER
   ============================================= */
.app-footer {
    grid-column: 1 / -1;
    grid-row: 2 / 3;
    padding: 20px;
    text-align: center;
    font-size: 0.78em;
    color: var(--chrome-text-dim);
    border-top: 1px solid var(--chrome-border);
    margin-top: auto;
}

.app-footer a {
    color: var(--chrome-text-dim);
    text-decoration: none;
    margin: 0 12px;
    font-weight: 500;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    transition:
        color 0.15s ease,
        background 0.15s ease;
}

.app-footer a:hover {
    color: var(--trace-bright);
    background: var(--trace-dim);
}

.footer-meta {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-specs {
    opacity: 0.7;
    font-size: 0.9em;
}

/* =============================================
   AVATAR BORDER — SkeuoCord-style profile ring
   ============================================= */
.avatar-frame {
    position: relative;
    display: inline-block;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.8) 0%,
        rgba(200, 210, 220, 0.5) 50%,
        rgba(160, 170, 180, 0.3) 100%
    );
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .avatar-frame {
    background: linear-gradient(
        180deg,
        rgba(60, 80, 110, 0.6) 0%,
        rgba(40, 60, 90, 0.4) 50%,
        rgba(30, 50, 80, 0.3) 100%
    );
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.3),
        0 2px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.avatar-frame img,
.avatar-frame .avatar-placeholder {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--tile-bg);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
        padding: 12px;
    }
    .sidebar {
        grid-row: auto;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .sidebar-brand {
        flex: 1 1 100%;
    }
    .tree-nav,
    .sys-stats {
        flex: 1 1 45%;
    }
    .app-footer {
        grid-column: 1;
    }
}

@media (max-width: 600px) {
    .app-shell {
        padding: 8px;
        gap: 12px;
    }
    .chrome-header {
        padding: 0 10px;
        gap: 6px;
        height: 32px;
    }
    .chrome-header .title {
        font-size: 0.75em;
    }
    .version-pill {
        display: none;
    }
    .sidebar {
        flex-direction: column;
    }
    .tree-nav,
    .sys-stats {
        flex: 1 1 100%;
    }
    .status-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .app-footer a {
        display: inline-block;
        margin: 4px 8px;
    }
}
