/* =========================================================
   DETECTREX — Design System
   Paleta: REXSUITE brand tokens
   Fonte: Geist + Geist Mono (família TYREXCO)
   ========================================================= */

/* ---------------------------------------------------------
   DESIGN TOKENS — alinhados ao REXSUITE brand guide
--------------------------------------------------------- */
:root {
    /* ── Surface layers (rex-ink family) ── */
    --bg-base:      #0A0A0B;   /* --rex-ink     */
    --bg-surface:   #131316;   /* --rex-ink-2   */
    --bg-elevated:  #1E1E22;   /* --rex-ink-3   */
    --bg-hover:     #2A2A30;   /* --rex-ink-4   */
    --bg-active:    #2E2E34;   /* --rex-line     */
    --border:        rgba(255,255,255,0.06);
    --border-strong: rgba(255,255,255,0.12);

    /* ── Text ── */
    --text-primary:   #F4F1EA;   /* --rex-paper    */
    --text-secondary: #9A9AA1;   /* --muted-2      */
    --text-tertiary:  #6B6B72;   /* --muted        */
    --text-inverse:   #0A0A0B;

    /* ── DETECTREX accent — sodium amber ── */
    --accent:     #FFC400;
    --accent-dim: rgba(255, 196, 0, 0.10);
    --accent-glow:rgba(255, 196, 0, 0.28);

    /* ── Status ── */
    --green:      #00D17A;   /* --rex-clock (emerald) */
    --green-dim:  rgba(0, 209, 122, 0.10);
    --green-glow: rgba(0, 209, 122, 0.28);
    --red:        #FF4D2E;   /* --rex-help (coral)    */
    --red-dim:    rgba(255, 77, 46, 0.10);
    --amber:      #FFC400;
    --amber-dim:  rgba(255, 196, 0, 0.10);

    /* ── Fonts — Geist family (REXSUITE brand) ── */
    --font-display: 'Geist', system-ui, sans-serif;
    --font-body:    'Geist', system-ui, sans-serif;
    --font-mono:    'Geist Mono', 'Courier New', monospace;
    --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
    --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
    --space-12: 3rem; --space-16: 4rem;
    --sidebar-w: 228px;
    --radius-sm: 4px; --radius: 8px; --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow:    0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
}

/* ---------------------------------------------------------
   RESET & BASE
--------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
    height: 100%;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { font-family: var(--font-display); }

/* ---------------------------------------------------------
   PAGE LAYOUT
--------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}
.app-sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    flex-shrink: 0;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content {
    flex: 1;
    padding: var(--space-8) var(--space-10);
    animation: fadeUp 0.35s ease both;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------
   SIDEBAR
--------------------------------------------------------- */
.sidebar-logo {
    padding: var(--space-5) var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}
/* Logo mark — now an <img> with rex-mark-detect.png */
.logo-mark { display: none; } /* legacy, mantido pra não quebrar se usado */

.logo-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.15;
}
.logo-sub {
    font-size: 0.5625rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    margin-top: 1px;
}
.sidebar-nav {
    flex: 1;
    padding: var(--space-4) var(--space-3);
    display: flex; flex-direction: column; gap: var(--space-1);
}
.nav-section-label {
    font-size: 0.625rem; font-weight: 600; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-tertiary);
    padding: var(--space-4) var(--space-3) var(--space-2);
}
.nav-item {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    color: var(--text-secondary); text-decoration: none;
    font-size: 0.875rem; font-weight: 400;
    transition: background 0.15s, color 0.15s;
    border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.nav-item.active {
    background: var(--accent-dim); color: var(--accent);
    border-color: rgba(245,158,11,0.2); font-weight: 500;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }
.sidebar-footer { padding: var(--space-4) var(--space-3); border-top: 1px solid var(--border); }

/* ---------------------------------------------------------
   PAGE HEADER
--------------------------------------------------------- */
.page-header { margin-bottom: var(--space-8); display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.page-header-left { flex: 1; }
.page-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.2; }
.page-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: var(--space-1); }

/* ---------------------------------------------------------
   CARDS
--------------------------------------------------------- */
.card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card-header { padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.card-title { font-family: var(--font-display); font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.card-body { padding: var(--space-4) var(--space-6); }

/* ---------------------------------------------------------
   STATUS PILLS
--------------------------------------------------------- */
.stat-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 100px; font-size: 0.75rem; font-weight: 500; }
.stat-pill.green  { background: var(--green-dim);  color: var(--green);  }
.stat-pill.amber  { background: var(--amber-dim);  color: var(--amber);  }
.stat-pill.muted  { background: var(--bg-hover);   color: var(--text-secondary); }
.stat-pill.red    { background: var(--red-dim);    color: var(--red);    }

/* ---------------------------------------------------------
   STATUS DOT
--------------------------------------------------------- */
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.status-dot.active { background: var(--green); box-shadow: 0 0 8px var(--green-glow); animation: pulse-green 2s ease-in-out infinite; }
.status-dot.idle   { background: var(--amber); box-shadow: 0 0 6px rgba(245,158,11,0.3); }
.status-dot.offline{ background: var(--text-tertiary); }
@keyframes pulse-green {
    0%,100% { box-shadow: 0 0 4px var(--green-glow); }
    50%     { box-shadow: 0 0 14px var(--green-glow); }
}

/* ── Avatar inline override (garante brand DETECTREX amber) ── */
.avatar {
    border-color: rgba(255,196,0,0.22);
    background: rgba(255,196,0,0.08);
    color: var(--accent);
}

/* ---------------------------------------------------------
   TABLE
--------------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table thead tr { border-bottom: 1px solid var(--border); }
.data-table th { padding: var(--space-3) var(--space-4); text-align: left; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); white-space: nowrap; }
.data-table td { padding: var(--space-3) var(--space-4); color: var(--text-primary); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.td-mono { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-secondary); white-space: nowrap; }
.td-dim  { color: var(--text-secondary); font-size: 0.875rem; }

/* ---------------------------------------------------------
   ACTIVITY BAR
--------------------------------------------------------- */
.activity-bar { display: flex; align-items: center; gap: var(--space-3); min-width: 140px; }
.activity-track { flex: 1; height: 4px; background: var(--bg-hover); border-radius: 100px; overflow: hidden; }
.activity-fill { height: 100%; border-radius: 100px; background: linear-gradient(90deg, var(--green) 0%, #16d47b 100%); transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.activity-fill.low { background: linear-gradient(90deg, var(--amber) 0%, #fbbf24 100%); }
.activity-fill.none { background: var(--text-tertiary); }
.activity-pct { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-secondary); min-width: 2.25rem; text-align: right; }

/* ---------------------------------------------------------
   FORMS
--------------------------------------------------------- */
.form-field { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label { font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); }
.form-input {
    width: 100%; background: var(--bg-hover); border: 1px solid var(--border-strong);
    border-radius: var(--radius); padding: var(--space-3) var(--space-4);
    color: var(--text-primary); font-family: var(--font-body); font-size: 0.9375rem; outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-input::placeholder { color: var(--text-tertiary); }

/* ---------------------------------------------------------
   BUTTONS
--------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.9375rem; font-weight: 500; cursor: pointer; transition: all 0.15s; text-decoration: none; border: 1px solid transparent; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }
.btn-primary:hover { background: #fbbf24; box-shadow: 0 4px 16px rgba(245,158,11,0.35); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { font-size: 0.8125rem; padding: var(--space-2) var(--space-3); }
button { cursor: pointer; }

/* ---------------------------------------------------------
   ALERTS
--------------------------------------------------------- */
.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius); font-size: 0.875rem; display: flex; align-items: center; gap: var(--space-2); }
.alert-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.alert-info  { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(245,158,11,0.2); }

/* ---------------------------------------------------------
   EMPTY STATE
--------------------------------------------------------- */
.empty-state { text-align: center; padding: var(--space-16) var(--space-8); color: var(--text-tertiary); }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto var(--space-4); opacity: 0.25; display: block; }
.empty-state p { font-size: 0.9375rem; }

/* ---------------------------------------------------------
   TIMELINE
--------------------------------------------------------- */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
    display: flex; gap: var(--space-4); padding: var(--space-3) var(--space-4);
    align-items: flex-start; transition: background 0.12s;
    border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item:hover { background: var(--bg-hover); }
.timeline-time { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-tertiary); min-width: 5.5rem; padding-top: 3px; flex-shrink: 0; }
.timeline-badge {
    display: inline-flex; align-items: center; padding: 2px 8px;
    border-radius: 4px; font-size: 0.625rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; flex-shrink: 0; margin-top: 2px; white-space: nowrap;
}
.badge-app    { background: var(--accent-dim); color: var(--accent); }
.badge-idle   { background: var(--bg-active);  color: var(--text-tertiary); }
.badge-sample { background: var(--green-dim);  color: var(--green); }
.badge-logon  { background: rgba(99,102,241,0.12); color: #818cf8; }
.badge-info   { background: rgba(56,189,248,0.1);  color: #38bdf8; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-app { font-weight: 500; font-size: 0.875rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-detail { font-size: 0.8125rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.timeline-dur { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-tertiary); flex-shrink: 0; padding-top: 3px; }

/* ---------------------------------------------------------
   FILTER BAR
--------------------------------------------------------- */
.filter-bar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-6); flex-wrap: wrap; }
.filter-bar input[type="date"] {
    background: var(--bg-elevated); border: 1px solid var(--border-strong);
    border-radius: var(--radius); padding: var(--space-2) var(--space-3);
    color: var(--text-primary); font-family: var(--font-mono); font-size: 0.875rem;
    outline: none; color-scheme: dark;
}
.filter-bar input[type="date"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ---------------------------------------------------------
   REPORT BARS
--------------------------------------------------------- */
.report-row {
    display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border); transition: background 0.12s;
}
.report-row:last-child { border-bottom: none; }
.report-row:hover { background: var(--bg-hover); }
.report-date { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-secondary); min-width: 5.5rem; flex-shrink: 0; }
.report-bar-wrap { flex: 1; display: flex; gap: 2px; height: 20px; border-radius: var(--radius-sm); overflow: hidden; }
.seg-active { background: var(--green); }
.seg-idle   { background: var(--bg-active); }
.seg-prod   { background: #818cf8; }
.seg-neutral{ background: var(--text-tertiary); opacity: 0.5; }
.seg-unp    { background: var(--red); }
.report-nums { display: flex; gap: var(--space-6); min-width: 14rem; flex-shrink: 0; justify-content: flex-end; }
.report-num { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-secondary); text-align: right; }
.report-num span { display: block; font-size: 0.5625rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------------------------------------------------------
   AVATAR
--------------------------------------------------------- */
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent-dim); border: 1px solid rgba(245,158,11,0.2);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-size: 0.6875rem; font-weight: 700;
    color: var(--accent); flex-shrink: 0; text-transform: uppercase;
}

/* ---------------------------------------------------------
   LOGIN SHELL
--------------------------------------------------------- */
.login-shell {
    min-height: 100vh; background: var(--bg-base);
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.login-shell::before {
    content: ''; position: absolute; width: 600px; height: 600px; border-radius: 50%;
    background: radial-gradient(circle, rgba(245,158,11,0.07) 0%, transparent 70%);
    top: -180px; left: -180px; pointer-events: none;
}
.login-shell::after {
    content: ''; position: absolute; width: 500px; height: 500px; border-radius: 50%;
    background: radial-gradient(circle, rgba(34,197,94,0.04) 0%, transparent 70%);
    bottom: -120px; right: -120px; pointer-events: none;
}
.login-card {
    background: var(--bg-surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg); padding: var(--space-10);
    width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
    position: relative; z-index: 1; animation: fadeUp 0.5s ease both;
}
.login-logo { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-8); }
.login-logo-mark { display: none; } /* legacy */
.login-logo-text {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.15;
}
.login-logo-sub {
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.login-heading {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}
.login-sub { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: var(--space-8); }
.login-fields { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-6); }

/* ---------------------------------------------------------
   MISC
--------------------------------------------------------- */
.refresh-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; animation: blink 2s ease infinite; }
@keyframes blink { 0%,90%,100%{opacity:1;} 50%{opacity:0.2;} }
.section-label { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-tertiary); }

/* ---------------------------------------------------------
   BLAZOR INFRA
--------------------------------------------------------- */
.blazor-error-boundary { background: var(--red-dim); border: 1px solid rgba(239,68,68,0.2); color: var(--red); padding: var(--space-4) var(--space-6); border-radius: var(--radius); margin: var(--space-4); }
.blazor-error-boundary::after { content: "Erro inesperado. Recarregue a página."; }
#blazor-error-ui {
    color-scheme: dark; background: var(--bg-surface); border-top: 1px solid var(--border);
    color: var(--text-secondary); bottom: 0; left: 0; padding: var(--space-3) var(--space-6);
    position: fixed; width: 100%; z-index: 1000; display: none; font-size: 0.875rem;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: var(--space-4); top: 50%; transform: translateY(-50%); }

/* custom scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
