/* ── ZX Bus Processor — CSS Global ─────────────────────────────────────────
   Compartilhado entre base.html (shell), base_frameless.html (iframes) e
   paginas publicas (login, reset_password, forgot_password).
   ──────────────────────────────────────────────────────────────────────── */

/* ── Brand fixas (NAO mudam por tema) ── */
:root {
    /* Direcionalidade no mapa operacional e sinotico linear */
    --brand-ida:        #00C853;
    --brand-volta:      #2962FF;

    /* Outline e texto fixos dentro de markers coloridos (alta saturacao) */
    --marker-outline:   #FFFFFF;
    --marker-text:      #0F172A;

    /* Paleta categorica de 16 cores para markers/services do mapa */
    --map-marker-01:    #38bdf8;
    --map-marker-02:    #f472b6;
    --map-marker-03:    #34d399;
    --map-marker-04:    #fbbf24;
    --map-marker-05:    #a78bfa;
    --map-marker-06:    #fb923c;
    --map-marker-07:    #22d3ee;
    --map-marker-08:    #f87171;
    --map-marker-09:    #c084fc;
    --map-marker-10:    #818cf8;
    --map-marker-11:    #4ade80;
    --map-marker-12:    #facc15;
    --map-marker-13:    #e879f9;
    --map-marker-14:    #fcd34d;
    --map-marker-15:    #7dd3fc;
    --map-marker-16:    #c4b5fd;
}

/* ── Tema Dark (default / referencia) ── */
:root, [data-theme="dark"] {
    --canvas:            #0F172A;
    --surface:           #1E293B;
    --surface-alt:       #163145;
    --surface-elevated:  #233754;
    --border:            #334155;
    --border-soft:       #1E293B;
    --text:              #E2E8F0;
    --text-secondary:    #CBD5E1;
    --text-muted:        #B0BCCE;
    --text-faint:        #94A3B8;
    --text-ghost:        #64748B;
    --accent:            #38BDF8;
    --accent-hover:      #0EA5E9;
    --accent-bg:         #0C4A6E;
    --accent-bg-soft:    rgba(56, 189, 248, 0.10);
    --btn-primary:       #1D4ED8;
    --btn-primary-hover: #1E40AF;
    --btn-primary-fg:    #FFFFFF;
    --ok:                #4ADE80;
    --warn:              #FBBF24;
    --error:             #F87171;
    --ok-bg:             rgba(74, 222, 128, 0.14);
    --warn-bg:           rgba(251, 191, 36, 0.14);
    --error-bg:          rgba(248, 113, 113, 0.12);
    --input-bg:          #0F172A;
    --row-hover:         #1A2535;
    --highlight:         #F1F5F9;
    --shadow-sm:         0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:         0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-lg:         0 16px 32px rgba(0, 0, 0, 0.6);
    --overlay:           rgba(2, 6, 23, 0.78);
    --scrollbar-thumb:   #334155;
    --scrollbar-track:   transparent;
    color-scheme: dark;
}

/* ── Tema Light ──
   Hierarquia de elevacao (mais profundo -> mais alto):
   canvas (#D7DCE1, slate-200ish) -> surface-alt (#EAEEF3, slate-100ish)
   -> surface (#FFFFFF, branco). Cards brancos "flutuam" sobre fundo
   tonalizado, dando contraste visivel sem ofuscar. */
[data-theme="light"] {
    --canvas:            #D7DCE1;
    --surface:           #FFFFFF;
    --surface-alt:       #EAEEF3;
    --surface-elevated:  #FFFFFF;
    --border:            #B8C2CC;
    --border-soft:       #DDE2E8;
    --text:              #0F172A;
    --text-secondary:    #1E293B;
    --text-muted:        #334155;
    --text-faint:        #475569;
    --text-ghost:        #94A3B8;
    --accent:            #0369A1;
    --accent-hover:      #075985;
    --accent-bg:         #E0F2FE;
    --accent-bg-soft:    rgba(3, 105, 161, 0.08);
    --btn-primary:       #2563EB;
    --btn-primary-hover: #1D4ED8;
    --btn-primary-fg:    #FFFFFF;
    --ok:                #15803D;
    --warn:              #B45309;
    --error:             #DC2626;
    --ok-bg:             #DCFCE7;
    --warn-bg:           #FEF3C7;
    --error-bg:          #FEE2E2;
    --input-bg:          #FFFFFF;
    --row-hover:         #C8CFD7;
    --highlight:         #0F172A;
    --shadow-sm:         0 1px 2px rgba(15, 23, 42, 0.08);
    --shadow-md:         0 4px 14px rgba(15, 23, 42, 0.10);
    --shadow-lg:         0 16px 32px rgba(15, 23, 42, 0.14);
    --overlay:           rgba(15, 23, 42, 0.50);
    --scrollbar-thumb:   #B8C2CC;
    --scrollbar-track:   transparent;
    color-scheme: light;
}

/* ── Tema Midnight ── */
[data-theme="midnight"] {
    --canvas:            #09090B;
    --surface:           #18181B;
    --surface-alt:       #111113;
    --surface-elevated:  #27272A;
    --border:            #27272A;
    --border-soft:       #1C1C1F;
    --text:              #E4E4E7;
    --text-secondary:    #BCBCC4;
    --text-muted:        #A1A1AA;
    --text-faint:        #8B8B92;
    --text-ghost:        #52525B;
    --accent:            #A78BFA;
    --accent-hover:      #8B5CF6;
    --accent-bg:         #2E1065;
    --accent-bg-soft:    rgba(167, 139, 250, 0.10);
    --btn-primary:       #7C3AED;
    --btn-primary-hover: #6D28D9;
    --btn-primary-fg:    #FFFFFF;
    --ok:                #4ADE80;
    --warn:              #FBBF24;
    --error:             #F87171;
    --ok-bg:             rgba(74, 222, 128, 0.12);
    --warn-bg:           rgba(251, 191, 36, 0.12);
    --error-bg:          rgba(248, 113, 113, 0.12);
    --input-bg:          #09090B;
    --row-hover:         #1F1F23;
    --highlight:         #FAFAFA;
    --shadow-sm:         0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md:         0 4px 14px rgba(0, 0, 0, 0.6);
    --shadow-lg:         0 16px 32px rgba(0, 0, 0, 0.7);
    --overlay:           rgba(0, 0, 0, 0.78);
    --scrollbar-thumb:   #3F3F46;
    --scrollbar-track:   transparent;
    color-scheme: dark;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    background: var(--canvas);
    color: var(--text);
    min-height: 100vh;
}

/* ── Scrollbar global (WebKit) ── */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--scrollbar-track); }
*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
    border: 2px solid var(--canvas);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-ghost); }

/* ── Layout ── */
main { max-width: none; margin: 0; padding: 0 1.5rem 1rem; }

/* ── Grid & Cards ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; }
.card h3 { font-size: 0.75rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.75rem; }
.card .value { font-size: 1.5rem; font-weight: 700; color: var(--highlight); }
.card .sub { font-size: 0.8rem; color: var(--text-faint); margin-top: 0.25rem; }

/* ── Status ── */
.status-ok   { color: var(--ok); }
.status-error { color: var(--error); }
.status-warn { color: var(--warn); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; color: var(--text-faint); font-weight: 500; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.7rem; text-transform: uppercase; }
td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-soft); color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }

/* ── Sections ── */
.section-title { font-size: 0.75rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem; }
.empty { color: var(--text-ghost); font-style: italic; font-size: 0.875rem; }

/* ── Quick links ── */
.quick-link { display: inline-flex; flex-direction: column; gap: 0.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 1rem; color: var(--text); text-decoration: none; font-size: 0.85rem; transition: border-color 0.15s; }
.quick-link:hover { border-color: var(--accent); text-decoration: none; }
.quick-link-sub { font-size: 0.7rem; color: var(--text-faint); }

/* ── HTMX ── */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ── Animations ── */
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 2s infinite; margin-right: 0.5rem; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Links ── */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
