/**
 * WebOS Manager — Auth Ultra 2026
 * Dedicated sysadmin login stylesheet (cPanel / Webmin / Cockpit inspired)
 * Palette: slate-900 bg, slate-800 surface, blue-500 primary, green-500 accent, orange-500 warn
 */

:root {
    --bg: #0f172a;
    --bg-2: #0b1220;
    --surface: #1e293b;
    --surface-2: #111c33;
    --surface-3: #0e1a30;
    --border: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(148, 163, 184, 0.32);
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --text-mute: #64748b;
    --primary: #3b82f6;
    --primary-2: #60a5fa;
    --primary-3: #1d4ed8;
    --accent: #22c55e;
    --accent-2: #16a34a;
    --warn: #f97316;
    --danger: #ef4444;
    --mono: "JetBrains Mono", "Fira Code", "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.65), 0 10px 30px -15px rgba(59, 130, 246, 0.25);
}

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

html, body { height: 100%; }

body {
    min-height: 100vh;
    font-family: var(--sans);
    color: var(--text);
    background: radial-gradient(1200px 800px at 15% 10%, rgba(59, 130, 246, 0.10), transparent 60%),
                radial-gradient(900px 700px at 90% 90%, rgba(34, 197, 94, 0.08), transparent 55%),
                linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ============= LAYOUT SPLIT ============= */
.auth-shell {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    min-height: 100vh;
}

/* ============= LEFT PANEL (server rack + topology) ============= */
.auth-panel {
    position: relative;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    border-right: 1px solid var(--border);
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.35), rgba(15, 23, 42, 0.85)),
        radial-gradient(600px 400px at 30% 20%, rgba(59, 130, 246, 0.18), transparent 60%),
        radial-gradient(500px 400px at 80% 80%, rgba(34, 197, 94, 0.14), transparent 60%);
}

/* Subtle scan grid overlay */
.auth-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(transparent 0, transparent 39px, rgba(148, 163, 184, 0.06) 40px),
        linear-gradient(90deg, transparent 0, transparent 39px, rgba(148, 163, 184, 0.06) 40px);
    background-size: 40px 40px;
    pointer-events: none;
    mask-image: radial-gradient(ellipse at center, black 40%, transparent 90%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 90%);
}

.brand {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 2;
}
.brand-mark {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 10px 30px -10px rgba(59, 130, 246, 0.6);
    position: relative;
}
.brand-mark svg { width: 26px; height: 26px; color: #fff; }
.brand-name {
    font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em;
}
.brand-tag {
    display: block;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Stage: rack + topology */
.stage {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 36px;
    align-items: center;
    margin: 40px 0;
}

.rack-wrap { position: relative; }
.rack {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.45));
}

.topology { width: 100%; height: auto; }

/* Stats badges */
.stats-row {
    position: relative; z-index: 2;
    display: flex; flex-wrap: wrap; gap: 12px;
    margin-top: 8px;
}
.stat-badge {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-family: var(--mono);
    font-size: 0.82rem;
}
.stat-badge .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    animation: pulse-dot 2.2s ease-in-out infinite;
}
.stat-badge.warn .dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.stat-badge.info .dot { background: var(--primary-2); box-shadow: 0 0 10px var(--primary-2); }
.stat-badge .label { color: var(--text-dim); }
.stat-badge .val { color: var(--text); font-weight: 600; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.85); }
}

/* Meta info block */
.meta {
    position: relative; z-index: 2;
    display: flex; flex-direction: column; gap: 6px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text-dim);
}
.meta .row { display: flex; gap: 10px; }
.meta .k { color: var(--text-mute); min-width: 80px; }
.meta .v { color: var(--text); }

/* ============= RIGHT PANEL (form card) ============= */
.auth-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 48px;
    position: relative;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    padding: 40px 36px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.85), rgba(17, 28, 51, 0.82));
    backdrop-filter: blur(20px) saturate(130%);
    -webkit-backdrop-filter: blur(20px) saturate(130%);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Gradient border (blue -> green) */
.auth-card::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    opacity: 0.9;
}

.card-head { margin-bottom: 26px; }
.card-head h1 {
    font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em;
    margin-bottom: 6px;
}
.card-head p { color: var(--text-dim); font-size: 0.92rem; }
.card-head .badge-admin {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px; margin-left: 8px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: var(--primary-2);
    font-family: var(--mono);
    font-size: 0.65rem; letter-spacing: 0.14em; text-transform: uppercase;
    vertical-align: middle;
}

/* Alert */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    border: 1px solid transparent;
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}
.alert svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 7px;
}

.field {
    position: relative;
    display: flex; align-items: center;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.field:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18), 0 0 24px -6px rgba(59, 130, 246, 0.5);
    background: rgba(15, 23, 42, 0.9);
}
.field svg.icon {
    width: 18px; height: 18px;
    color: var(--text-mute);
    margin-left: 14px;
    flex-shrink: 0;
}
.field input {
    flex: 1;
    background: transparent;
    border: 0; outline: none;
    color: var(--text);
    font-size: 0.95rem;
    padding: 13px 14px;
    font-family: var(--sans);
}
.field input::placeholder {
    color: var(--text-mute);
    font-family: var(--mono);
    font-size: 0.88rem;
    letter-spacing: 0.02em;
}
.field .toggle {
    background: transparent; border: 0;
    color: var(--text-mute);
    padding: 0 14px; height: 100%;
    cursor: pointer;
    display: inline-flex; align-items: center;
    transition: color .2s;
}
.field .toggle:hover, .field .toggle:focus-visible { color: var(--primary-2); }
.field .toggle svg { width: 18px; height: 18px; }

/* Remember + row */
.options-row {
    display: flex; align-items: center; justify-content: space-between;
    margin: 8px 0 22px;
    font-size: 0.85rem;
}
.check {
    display: inline-flex; align-items: center; gap: 8px;
    cursor: pointer; user-select: none;
    color: var(--text-dim);
}
.check input {
    width: 16px; height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Button */
.btn-primary {
    position: relative;
    width: 100%;
    border: 0;
    cursor: pointer;
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, var(--primary-3) 0%, var(--primary) 50%, var(--accent) 100%);
    background-size: 200% 100%;
    background-position: 0% 50%;
    box-shadow: 0 10px 24px -10px rgba(59, 130, 246, 0.6);
    overflow: hidden;
    transition: background-position .6s ease, transform .15s ease, box-shadow .2s ease;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-primary:hover {
    background-position: 100% 50%;
    box-shadow: 0 14px 30px -10px rgba(34, 197, 94, 0.55);
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .75; cursor: not-allowed; }
.btn-primary svg { width: 18px; height: 18px; }

.btn-primary .spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: none;
}
.btn-primary.is-loading .label,
.btn-primary.is-loading svg.icon { display: none; }
.btn-primary.is-loading .spinner { display: inline-block; }

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

/* Security notice */
.notice {
    margin-top: 22px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(249, 115, 22, 0.08);
    border: 1px solid rgba(249, 115, 22, 0.28);
    color: #fdba74;
    font-size: 0.78rem;
    display: flex; align-items: flex-start; gap: 10px;
    line-height: 1.5;
}
.notice svg { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }

/* Footer */
.foot {
    position: relative; z-index: 2;
    margin-top: 24px;
    display: flex; justify-content: space-between; align-items: center;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-mute);
}
.foot .links { display: flex; gap: 14px; }
.foot a { color: var(--text-dim); text-decoration: none; transition: color .2s; }
.foot a:hover { color: var(--primary-2); }

.auth-foot {
    position: absolute;
    bottom: 14px; left: 0; right: 0;
    text-align: center;
    font-family: var(--mono);
    font-size: 0.70rem;
    color: var(--text-mute);
}

/* ============= RACK SVG ANIM ============= */
.led {
    animation: led-blink 2.4s ease-in-out infinite;
}
.led.g  { animation-delay: 0s; }
.led.g2 { animation-delay: .4s; }
.led.g3 { animation-delay: .8s; }
.led.b  { animation-delay: 1.1s; }
.led.o  { animation-delay: .6s; }
@keyframes led-blink {
    0%, 100% { opacity: 1; }
    45%      { opacity: 0.35; }
    55%      { opacity: 1; }
}
.rack-bar {
    transform-origin: left center;
    animation: bar-pulse 3.2s ease-in-out infinite;
}
.rack-bar.d2 { animation-delay: .8s; }
.rack-bar.d3 { animation-delay: 1.6s; }
@keyframes bar-pulse {
    0%, 100% { transform: scaleX(0.45); opacity: 0.9; }
    50%      { transform: scaleX(1); opacity: 1; }
}

/* ============= TOPOLOGY SVG ANIM ============= */
.topo-link {
    stroke-dasharray: 4 6;
    animation: dash-flow 5s linear infinite;
}
.topo-link.d2 { animation-duration: 7s; }
.topo-link.d3 { animation-duration: 6s; animation-direction: reverse; }
@keyframes dash-flow {
    to { stroke-dashoffset: -100; }
}
.topo-node {
    transform-origin: center;
    animation: node-breathe 3s ease-in-out infinite;
}
.topo-node.n2 { animation-delay: .7s; }
.topo-node.n3 { animation-delay: 1.2s; }
.topo-node.n4 { animation-delay: 1.8s; }
@keyframes node-breathe {
    0%, 100% { filter: drop-shadow(0 0 3px rgba(59,130,246,0.5)); }
    50%      { filter: drop-shadow(0 0 10px rgba(59,130,246,0.9)); }
}

/* ============= RESPONSIVE ============= */
@media (max-width: 1100px) {
    .stage { grid-template-columns: 220px 1fr; gap: 20px; }
    .auth-panel { padding: 36px 32px; }
    .auth-right { padding: 36px 28px; }
}
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-panel {
        padding: 32px 24px 24px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .stage { grid-template-columns: 180px 1fr; gap: 16px; margin: 20px 0; }
    .auth-right { padding: 28px 20px 60px; }
    .auth-card { padding: 30px 22px; }
    .auth-foot { position: static; margin-top: 24px; }
}
@media (max-width: 560px) {
    .stage { grid-template-columns: 1fr; }
    .rack-wrap { max-width: 200px; margin: 0 auto; }
    .card-head h1 { font-size: 1.3rem; }
}

/* ============= ACCESSIBILITY ============= */
:focus-visible {
    outline: 2px solid var(--primary-2);
    outline-offset: 2px;
    border-radius: 4px;
}
.sr-only {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
@media (prefers-contrast: more) {
    :root { --border: rgba(226, 232, 240, 0.45); --text-dim: #cbd5e1; }
}
