/* Zyko Shield — Dashboard SaaS minimalista */
:root {
    --bg:        #0f1620;
    --surface:   #1a2332;
    --surface-2: #243044;
    --border:    #2d3a52;
    --text:      #e6edf3;
    --muted:     #8094ad;
    --accent:    #3b82f6;
    --ok:        #10b981;
    --warn:      #f59e0b;
    --err:       #ef4444;
    --attack:    #dc2626;
    --legit:     #059669;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
}

.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .8rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; }
.brand h1 { font-size: 1.1rem; margin: 0; font-weight: 600; }
.brand-mark { color: var(--accent); font-size: 1.3rem; }
.version-tag { color: var(--muted); font-size: .65rem; font-family: ui-monospace, SF Mono, Consolas, monospace; padding: .1rem .4rem; background: var(--surface-2); border-radius: 4px; margin-left: .3rem; user-select: text; }
.badges { display: flex; gap: .4rem; margin-left: 1rem; }
.badge {
    padding: .2rem .6rem; border-radius: 999px; font-size: .75rem;
    font-weight: 500; background: var(--surface-2);
}
.badge-tenant { background: var(--accent); color: white; }
.badge-user   { background: var(--surface-2); }
.actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }

/* Seletor de idioma (Plano 14e i18n) */
.lang-switcher select {
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    padding: .35rem .5rem; font-size: .85rem;
    font-family: inherit; cursor: pointer;
}
.lang-switcher select:hover { border-color: var(--accent); }
.lang-switcher select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ─── RTL (hebraico) ──────────────────────────────────────────────── */
body.rtl { direction: rtl; }
body.rtl .actions { margin-left: 0; margin-right: auto; }
body.rtl .badges  { margin-left: 0; margin-right: 1rem; }
body.rtl .agent-card.agent-up    { border-left: none; border-right: 3px solid var(--ok); }
body.rtl .agent-card.agent-stale { border-left: none; border-right: 3px solid var(--warn); }
body.rtl .vbox-before { border-left: none; border-right: 3px solid var(--muted); }
body.rtl .vbox-update { border-left: none; border-right: 3px solid var(--attack); }
body.rtl .vbox-after  { border-left: none; border-right: 3px solid var(--ok); }
body.rtl .info-box {
    border-left: none; border-right: 3px solid var(--accent);
    text-align: right;
}
body.rtl .timeline-row.tl-current {
    border-left: none; border-right: 3px solid var(--accent);
}
body.rtl .value-box.value-old   { border-left: none; border-right: 3px solid var(--muted); }
body.rtl .value-box.value-new   { border-left: none; border-right: 3px solid var(--attack); }
body.rtl .value-box.value-after { border-left: none; border-right: 3px solid var(--ok); }
body.rtl .company-card:hover { transform: translateX(-2px); }
/* Codigo monospace/UUID/hex deve ficar LTR mesmo em RTL — leitura tecnica */
body.rtl .vbox-val,
body.rtl .version-tag,
body.rtl code,
body.rtl pre { direction: ltr; text-align: left; }

.btn-ghost {
    background: transparent; color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    padding: .4rem .8rem; cursor: pointer; font-size: .85rem;
}
.btn-ghost:hover { background: var(--surface-2); }

main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

/* ─── Login (state machine UX spec v1.0) ─── */
.login-card {
    max-width: 520px; margin: 3rem auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 2rem;
    text-align: center;
    font-size: 16px; /* acessibilidade: >=16px */
}
.login-card h2 { margin-top: 0; margin-bottom: 1.2rem; font-size: 1.4rem; }
.login-card p  { line-height: 1.5; }
.login-card .state-msg { margin: 1rem 0 .8rem 0; }
.login-card .state-msg.ok   { color: var(--ok); }
.login-card .state-msg.err  { color: var(--err); }
.login-card .state-msg.warn { color: var(--warn); }
.login-footer { margin-top: 1.2rem; min-height: 1.2em; font-size: .85rem; }

/* QR */
.qr-box {
    background: white; padding: 16px; border-radius: 12px;
    display: inline-block; margin: 1rem 0;
    min-height: 256px; min-width: 256px;
}

/* WAITING_SCAN — meta linha (dot pulsante + countdown) */
.waiting-meta {
    display: flex; justify-content: center; align-items: center;
    gap: .6rem; margin-top: .6rem;
}
.dot-pulse {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.6s infinite;
    display: inline-block;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70%  { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* LOADING / COMPLETING — spinner */
.spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--surface-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 1.5rem auto;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* SELECT — cards de empresas */
.companies-list {
    display: flex; flex-direction: column; gap: .6rem;
    margin: 1.2rem 0;
}
.company-card {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); cursor: pointer; text-align: left;
    font-family: inherit; font-size: 1rem;
    transition: background .15s, border-color .15s, transform .1s;
}
.company-card:hover {
    background: rgba(59, 130, 246, .12);
    border-color: var(--accent);
    transform: translateX(2px);
}
.company-card:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
.company-icon { font-size: 1.5rem; }
.company-info { display: flex; flex-direction: column; flex: 1; gap: .15rem; }
.company-name { font-weight: 600; font-size: 1rem; }
.company-code { font-size: .8rem; }
.company-arrow { color: var(--muted); font-size: 1.2rem; }
.btn-back { margin-top: 1rem; }

/* SUCCESS / FAIL / NO_ACCESS — icones */
.icon-success, .icon-fail, .icon-warn {
    width: 64px; height: 64px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 1rem auto .5rem auto;
    font-size: 2rem; font-weight: 700;
}
.icon-success { background: rgba(16, 185, 129, .15);  color: var(--ok); }
.icon-fail    { background: rgba(239, 68, 68, .15);   color: var(--err); }
.icon-warn    { background: rgba(245, 158, 11, .15);  color: var(--warn); }

/* NO_ACCESS — caixa de instrucao */
.info-box {
    background: var(--surface-2); border-left: 3px solid var(--accent);
    border-radius: 4px; padding: 1rem;
    margin: 1.2rem 0; text-align: left;
    line-height: 1.5; font-size: .9rem;
}
.info-box code {
    background: var(--bg); padding: .1rem .4rem; border-radius: 3px;
    font-family: ui-monospace, SF Mono, Consolas, monospace; font-size: .85rem;
}

/* Buttons */
.btn-primary {
    background: var(--accent); color: white; border: none;
    padding: .7rem 1.4rem; border-radius: 6px; cursor: pointer;
    font-size: 1rem; font-weight: 500; font-family: inherit;
    margin-top: .8rem;
    transition: background .15s;
}
.btn-primary:hover { background: #2563eb; }
.btn-primary:focus-visible { outline: 2px solid white; outline-offset: 2px; }

/* Filters */
.filters {
    display: flex; gap: 1.2rem; align-items: center;
    padding: .8rem 1rem; background: var(--surface);
    border-radius: 8px; margin-bottom: 1rem;
}
.filters label { display: flex; align-items: center; gap: .4rem; }
.filters select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: .3rem .6rem; border-radius: 4px; }
.muted { color: var(--muted); font-size: .85rem; }
.err   { color: var(--err); }

/* Agents */
.agents { margin-bottom: 1.2rem; }
.agents h3 { margin: .5rem 0; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.agents-list { display: flex; gap: .8rem; flex-wrap: wrap; }
.agent-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: .7rem 1rem; min-width: 220px;
}
.agent-card.agent-up    { border-left: 3px solid var(--ok); }
.agent-card.agent-stale { border-left: 3px solid var(--warn); }
.agent-name { font-weight: 600; font-size: .85rem; word-break: break-all; }
.agent-meta { display: flex; gap: .8rem; font-size: .75rem; color: var(--muted); margin-top: .3rem; }
.agent-time { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

/* Alerts table */
.alerts h3 { margin: .5rem 0; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.alerts-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; overflow: hidden; }
.alerts-table th, .alerts-table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
.alerts-table th { background: var(--surface-2); font-size: .75rem; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.alerts-table tbody tr:hover { background: var(--surface-2); }
.alerts-table tr.row-attack { background: rgba(220, 38, 38, .08); }
.alerts-table tr.row-attack:hover { background: rgba(220, 38, 38, .15); }
.alerts-table a { color: var(--accent); text-decoration: none; }
.alerts-table a:hover { text-decoration: underline; }

.ev-badge {
    display: inline-block; padding: .15rem .5rem; border-radius: 4px;
    font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.ev-attack { background: var(--attack); color: white; }
.ev-legit  { background: var(--legit);  color: white; }
.ev-info   { background: var(--surface-2); color: var(--muted); }

/* ─── Alerts inline (Plano 14e UX: 3 valores + Aceitar como legitimo) ─── */
.alerts-table-inline td { vertical-align: top; padding: .8rem; }
.alerts-table-inline .col-when    { width: 130px; white-space: nowrap; color: var(--muted); font-size: .8rem; }
.alerts-table-inline .col-target  { width: 200px; }
.alerts-table-inline .col-target .field { color: var(--muted); }
.alerts-table-inline .col-target .small { font-size: .75rem; margin-top: .2rem; }
.alerts-table-inline .col-tier    { width: 110px; }
.alerts-table-inline .col-values  { min-width: 380px; }
.alerts-table-inline .col-source  { width: 160px; font-size: .8rem; }
.alerts-table-inline .col-action  { width: 120px; }
.alerts-table-inline .col-op      { width: 180px; }

/* Tier badges (score → severidade visual) */
.tier-badge {
    display: inline-block; padding: .25rem .6rem; border-radius: 4px;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    white-space: nowrap;
}
.tier-low      { background: rgba(128, 148, 173, .2); color: var(--muted); }
.tier-medium   { background: rgba(245, 158, 11, .2);  color: var(--warn); }
.tier-high     { background: rgba(239, 68, 68, .2);   color: var(--err); }
.tier-critical { background: var(--attack); color: white; }

/* 3 valores (Antes / Update / Banco apos a acao) */
.vbox-row { display: flex; gap: .4rem; }
.vbox {
    flex: 1; min-width: 0;
    background: var(--surface-2); border-radius: 6px;
    padding: .5rem .6rem;
    border-left: 3px solid var(--border);
}
.vbox-before { border-left-color: var(--muted); }
.vbox-update { border-left-color: var(--attack); }
.vbox-after  { border-left-color: var(--ok); }
.vbox-label  {
    font-size: .65rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); margin-bottom: .3rem; font-weight: 600;
}
.vbox-val {
    font-family: ui-monospace, SF Mono, Consolas, monospace;
    font-size: .8rem; word-break: break-all; line-height: 1.3;
    max-height: 4.5em; overflow: hidden; text-overflow: ellipsis;
}
.vbox-update .vbox-val { color: #fca5a5; }
.vbox-after  .vbox-val { color: #6ee7b7; }

/* Botoes de override do operador:
   - mode=accept        (ROLLBACK)   -> verde, sentido positivo "aceitar valor"
   - mode=manual_revert (OBSERVATION) -> ambar, sentido cuidadoso "reverter manual em obs" */
.btn-override {
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    padding: .35rem .7rem; cursor: pointer; font-size: .8rem;
    font-family: inherit;
    transition: background .15s, border-color .15s;
}
.btn-override:disabled { opacity: .5; cursor: wait; }
.btn-override[data-mode="accept"]:hover  { background: rgba(16, 185, 129, .15); border-color: var(--ok); color: var(--ok); }
.btn-override[data-mode="manual_revert"]:hover { background: rgba(245, 158, 11, .15); border-color: var(--warn, #f59e0b); color: var(--warn, #f59e0b); }

/* Legado — mantido pra compat de templates antigos (alert_detail.html). */
.btn-accept {
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    padding: .35rem .7rem; cursor: pointer; font-size: .8rem;
    font-family: inherit;
    transition: background .15s, border-color .15s;
}
.btn-accept:hover  { background: rgba(16, 185, 129, .15); border-color: var(--ok); color: var(--ok); }
.btn-accept:disabled { opacity: .5; cursor: wait; }

.op-status {
    display: inline-block; padding: .3rem .6rem; border-radius: 4px;
    font-size: .75rem; font-weight: 600;
}
.op-pending { background: rgba(245, 158, 11, .15); color: var(--warn); }
.op-applied { background: rgba(16, 185, 129, .15); color: var(--ok); }
.op-failed  { background: rgba(239, 68, 68, .15);  color: var(--err); }

/* Detail */
.back-link { display: inline-block; color: var(--accent); margin-bottom: 1rem; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; }
.detail-card h2 { margin-top: 0; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .5rem 1rem; }
.kv { display: flex; gap: .6rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.kv .k { color: var(--muted); min-width: 110px; }
.kv .v { color: var(--text); word-break: break-all; }

.value-pair    { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }
.value-pair-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }
.value-box { background: var(--surface-2); padding: 1rem; border-radius: 6px; }
.value-box h4 { margin: 0 0 .5rem 0; font-size: .8rem; text-transform: uppercase; color: var(--muted); }
.value-box.value-old   { border-left: 3px solid var(--muted); }
.value-box.value-new   { border-left: 3px solid var(--attack); }
.value-box.value-after { border-left: 3px solid var(--ok); }
.value-box pre { white-space: pre-wrap; word-break: break-all; margin: 0; font-family: ui-monospace, SF Mono, Consolas, monospace; font-size: .8rem; color: var(--text); }

/* Timeline */
.timeline h3 { margin: 1rem 0 .5rem 0; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.timeline-row { display: grid; grid-template-columns: 180px 140px 100px 80px 1fr; gap: 1rem; padding: .5rem .8rem; background: var(--surface); border-bottom: 1px solid var(--border); align-items: center; }
.timeline-row:first-child { border-radius: 8px 8px 0 0; }
.timeline-row:last-child  { border-radius: 0 0 8px 8px; border-bottom: none; }
.timeline-row.tl-current { background: var(--surface-2); border-left: 3px solid var(--accent); }
.tl-when, .tl-event, .tl-action, .tl-score, .tl-user { font-size: .85rem; }
.tl-when { color: var(--muted); }
