/*
 * Tema do Painel de Monitoramento: geometria do SAP Fiori Horizon com as cores da H&CO.
 * Tokens em :root; componentes com prefixo do Fiori (shellbar, filterbar, table, status, btn, strip, objpage, pager).
 */

@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/poppins-500.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/poppins-600.woff2') format('woff2'); }

:root {
    /* Marca H&CO */
    --brand-navy: #15234A;
    --brand-navy-hover: #22356B;
    --brand-navy-active: #0E1834;
    --brand-red: #D12B38;
    --brand-cyan: #00ACD8;

    /* Superfícies (Horizon claro) */
    --bg-page: #F5F6F7;
    --bg-surface: #FFFFFF;
    --bg-surface-alt: #F7F8FA;
    --bg-hover: #EAECEE;
    --bg-selected: #EBF2FC;
    --border: #D9D9D9;
    --border-field: #8396A8;

    /* Texto */
    --text: #1D2D3E;
    --text-muted: #556B82;
    --text-on-brand: #FFFFFF;
    --link: #15234A;
    --focus: #0070F2;

    /* Semânticas (Horizon) */
    --negative: #AA0808;    --negative-bg: #FFEAF4;
    --critical: #B44F00;    --critical-bg: #FFF3B8;   --critical-edge: #E76500;
    --positive: #256F3A;    --positive-bg: #F5FAE5;
    --information: #0064D9; --information-bg: #E1F4FF;
    --neutral: #556B82;     --neutral-bg: #EFF1F2;

    /* Geometria */
    --radius-control: 8px;
    --radius-panel: 12px;
    --radius-pill: 999px;
    --control-h: 32px;        /* compact */
    --row-h: 36px;
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px;
    --shadow-1: 0 0 2px rgba(34, 53, 72, .16), 0 2px 4px rgba(34, 53, 72, .16);
    --shadow-2: 0 0 2px rgba(34, 53, 72, .16), 0 8px 16px rgba(34, 53, 72, .16);

    /* Tipografia */
    --font-brand: 'Poppins', system-ui, sans-serif;
    --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    --fs-s: 12px; --fs-m: 14px; --fs-l: 16px; --fs-xl: 20px;
}

@media (max-width: 767px) {
    :root { --control-h: 44px; --row-h: 44px; } /* cozy */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fs-m)/1.43 var(--font-body); color: var(--text); background: var(--bg-page); }
a { color: var(--link); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-brand); font-weight: 600; color: var(--text); margin: 0; }
.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

/* ---------------------------------------------------------------- Shell Bar */
.shellbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--space-6); height: 52px; padding: 0 var(--space-4); background: var(--brand-navy); color: var(--text-on-brand); }
.shellbar__brand { display: flex; align-items: center; gap: var(--space-3); color: inherit; }
.shellbar__brand:hover { text-decoration: none; }
.shellbar__brand img { height: 22px; width: auto; display: block; }
.shellbar__title { font-family: var(--font-brand); font-weight: 500; font-size: var(--fs-m); padding-left: var(--space-3); border-left: 1px solid rgba(255, 255, 255, .3); white-space: nowrap; }
.shellbar__nav { display: flex; align-self: stretch; gap: var(--space-1); }
.shellbar__nav a { display: flex; align-items: center; padding: 0 var(--space-3); color: rgba(255, 255, 255, .82); font-weight: 500; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.shellbar__nav a:hover { color: #fff; text-decoration: none; background: rgba(255, 255, 255, .08); }
.shellbar__nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--brand-red); }
.shellbar__user { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-s); white-space: nowrap; }
.shellbar__avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 255, .16); font-weight: 600; text-transform: uppercase; }
.shellbar__user a { color: #fff; display: inline-flex; align-items: center; gap: var(--space-1); }

@media (max-width: 767px) {
    .shellbar { flex-wrap: wrap; height: auto; gap: 0 var(--space-3); padding-top: var(--space-2); }
    .shellbar__title { display: none; }
    .shellbar__nav { order: 3; width: 100%; height: 44px; }
    .shellbar__user-name { display: none; }
}

/* ---------------------------------------------------------------- Página */
.page { max-width: 1440px; margin: 0 auto; padding: var(--space-6) var(--space-8) var(--space-8); }
.page__header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.page__title { font-size: var(--fs-xl); }
.page__subtitle { margin: var(--space-1) 0 0; color: var(--text-muted); max-width: 80ch; }
.section { margin-top: var(--space-6); }
.section__title { font-size: var(--fs-l); margin-bottom: var(--space-3); }
.hint { color: var(--text-muted); }
.back { display: inline-flex; align-items: center; gap: var(--space-1); margin-bottom: var(--space-3); }
@media (max-width: 767px) { .page { padding: var(--space-4); } }

.card { background: var(--bg-surface); border-radius: var(--radius-panel); box-shadow: var(--shadow-1); }

/* ---------------------------------------------------------------- Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1); height: var(--control-h); min-width: var(--control-h); padding: 0 var(--space-3); border: 1px solid var(--border-field); border-radius: var(--radius-control); background: var(--bg-surface); color: var(--brand-navy); font: 600 var(--fs-m) var(--font-body); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:active { background: var(--bg-selected); }
.btn--emphasized { background: var(--brand-navy); border-color: var(--brand-navy); color: var(--text-on-brand); }
.btn--emphasized:hover { background: var(--brand-navy-hover); border-color: var(--brand-navy-hover); }
.btn--emphasized:active { background: var(--brand-navy-active); }
.btn--transparent { border-color: transparent; background: transparent; }
.btn--negative { color: var(--negative); border-color: var(--negative); }
.btn--negative:hover { background: var(--negative-bg); }
.btn--block { width: 100%; }
.btn--sm { height: 26px; padding: 0 var(--space-2); font-size: var(--fs-s); }
@media (max-width: 767px) { .btn--sm { height: 36px; } }
.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ---------------------------------------------------------------- Campos */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field__label { font-size: var(--fs-s); color: var(--text-muted); font-weight: 500; }
.input, .select { height: var(--control-h); padding: 0 var(--space-3); border: 1px solid var(--border-field); border-radius: var(--radius-control); background: var(--bg-surface); color: var(--text); font: var(--fs-m) var(--font-body); min-width: 0; }
.select { padding-right: var(--space-8); appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2315234A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:hover, .select:hover { border-color: var(--brand-navy); }
.input:focus, .select:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }

/* ---------------------------------------------------------------- Filter Bar */
.filterbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-4); padding: var(--space-4); margin-bottom: var(--space-4); }
.filterbar .field { min-width: 200px; }
@media (max-width: 767px) { .filterbar .field { flex: 1 1 100%; } .filterbar .btn { width: 100%; } }

/* ---------------------------------------------------------------- Message Strip */
.strip { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-4); border: 1px solid; border-radius: var(--radius-control); }
.strip .icon { margin-top: 2px; }
.strip--negative { color: var(--negative); background: var(--negative-bg); border-color: #F7BFBF; }
.strip--critical { color: var(--critical); background: var(--critical-bg); border-color: #F5D35A; }
.strip--positive { color: var(--positive); background: var(--positive-bg); border-color: #C8E3A0; }
.strip--information { color: var(--information); background: var(--information-bg); border-color: #A9D8F7; }
.strip__body { color: var(--text); }

/* ---------------------------------------------------------------- Table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.table th, .table td { height: var(--row-h); padding: var(--space-2) var(--space-3); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th { position: sticky; top: 0; background: var(--bg-surface-alt); color: var(--text-muted); font-size: var(--fs-s); font-weight: 600; white-space: nowrap; }
.table thead th:first-child { border-top-left-radius: var(--radius-panel); }
.table thead th:last-child { border-top-right-radius: var(--radius-panel); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg-hover); }
.table td.num, .table th.num { text-align: right; }
.table td.item { font-family: var(--font-mono); font-size: var(--fs-s); }
.table td.actions-cell { white-space: nowrap; text-align: right; }
.table td.actions-cell small { white-space: normal; min-width: 220px; max-width: 320px; margin: 0 0 var(--space-1) auto; }
.table td.nowrap { white-space: nowrap; }
.table .empty { text-align: center; color: var(--text-muted); height: 72px; }
.table pre { margin: 0; }
.table small { display: block; color: var(--text-muted); font-size: var(--fs-s); }
.table .wrap { min-width: 220px; max-width: 420px; }
/* faixa de 3px na borda esquerda, na cor do status */
.table tbody tr > td:first-child { box-shadow: inset 3px 0 0 transparent; }
.table tbody tr.edge-negative > td:first-child { box-shadow: inset 3px 0 0 var(--negative); }
.table tbody tr.edge-critical > td:first-child, .table tbody tr.parada > td:first-child { box-shadow: inset 3px 0 0 var(--critical-edge); }
.table tbody tr.edge-information > td:first-child { box-shadow: inset 3px 0 0 var(--information); }
.table tbody tr.status-ignorado td { color: var(--text-muted); }
.table tbody tr.parada td { font-weight: 600; }
.table-wrap.card { padding: 0; }
.table td.wrap-mobile { min-width: 180px; }

/* Tabela chave/valor (Object Page) */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-4) var(--space-6); padding: var(--space-4) var(--space-6) var(--space-6); margin: 0; }
.kv div { min-width: 0; }
.kv dt { font-size: var(--fs-s); color: var(--text-muted); margin-bottom: 2px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv .kv--wide { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- Object Status */
.status { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--space-2); border-radius: var(--radius-pill); font-size: var(--fs-s); font-weight: 600; white-space: nowrap; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status--negative { color: var(--negative); background: var(--negative-bg); }
.status--critical { color: var(--critical); background: var(--critical-bg); }
.status--positive { color: var(--positive); background: var(--positive-bg); }
.status--information { color: var(--information); background: var(--information-bg); }
.status--neutral { color: var(--neutral); background: var(--neutral-bg); }

/* ---------------------------------------------------------------- Object Page */
.objpage__header { padding: var(--space-6) var(--space-6) var(--space-4); border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }
.objpage__eyebrow { font-size: var(--fs-s); color: var(--text-muted); margin-bottom: var(--space-1); }
.objpage__title { font-size: var(--fs-xl); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; overflow-wrap: anywhere; }
.objpage__actions form { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.objpage__strip { padding: var(--space-4) var(--space-6) 0; }
.objpage__strip .strip { margin: 0; }
.code { margin: 0; padding: var(--space-4); background: var(--bg-surface-alt); border-radius: var(--radius-control); font: var(--fs-s)/1.5 var(--font-mono); overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.card > .code { border-radius: var(--radius-panel); }
@media (max-width: 767px) { .objpage__header, .kv { padding-left: var(--space-4); padding-right: var(--space-4); } .objpage__actions, .objpage__actions form, .objpage__actions .input { width: 100%; } }

/* ---------------------------------------------------------------- Paginator */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); color: var(--text-muted); }

/* ---------------------------------------------------------------- Login */
.login { display: grid; grid-template-columns: 3fr 2fr; min-height: 100vh; background: var(--bg-surface); }
.login__hero { position: relative; overflow: hidden; color: #fff; background:
    radial-gradient(60% 50% at 70% 35%, rgba(0, 172, 216, .22), transparent 70%),
    radial-gradient(50% 40% at 15% 90%, rgba(209, 43, 56, .14), transparent 70%),
    linear-gradient(135deg, var(--brand-navy) 0%, #1E2F6B 100%); }
.login__graph { position: absolute; inset: 0; width: 100%; height: 100%; }
.login__tagline { position: absolute; left: 48px; right: 48px; bottom: 48px; max-width: 520px; }
.login__tagline h1 { color: #fff; font-size: 34px; line-height: 1.2; }
.login__tagline h1 span { color: var(--brand-red); }
.login__tagline p { margin: var(--space-3) 0 0; color: rgba(255, 255, 255, .78); font-size: var(--fs-l); }
.login__panel { display: flex; flex-direction: column; justify-content: center; padding: var(--space-8) clamp(24px, 6vw, 96px); }
.login__form { width: 100%; max-width: 360px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-4); }
.login__logo { height: 40px; width: auto; align-self: flex-start; margin-bottom: var(--space-4); }
.login__title { font-size: 22px; }
.login__lead { margin: calc(-1 * var(--space-3)) 0 var(--space-2); color: var(--text-muted); }
.login__form .input { height: 40px; }
.login__form .btn { height: 40px; margin-top: var(--space-2); }
.login__form .strip { margin: 0; }
.login__foot { margin-top: var(--space-8); font-size: var(--fs-s); color: var(--text-muted); text-align: center; }

/* fluxos animados do grafo */
.flow { stroke-dasharray: 2 18; stroke-linecap: round; animation: flow 8s linear infinite; }
.flow--slow { animation-duration: 10s; }
.flow--fast { animation-duration: 6s; }
.flow--rev { animation-direction: reverse; }
.pulse { transform-box: fill-box; transform-origin: center; animation: pulse 4s ease-in-out infinite; }
@keyframes flow { to { stroke-dashoffset: -200; } }
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(1); } 50% { opacity: .08; transform: scale(1.35); } }
@media (prefers-reduced-motion: reduce) { .flow, .pulse { animation: none; } }

@media (max-width: 767px) {
    .login { grid-template-columns: 1fr; grid-template-rows: 160px 1fr; }
    .login__tagline { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); }
    .login__tagline h1 { font-size: 22px; }
    .login__tagline p { display: none; }
    .login__graph { opacity: .45; }
    .login__graph text { display: none; }
    .login__panel { justify-content: flex-start; padding: var(--space-6) var(--space-4); }
}

/* ---------------------------------------------------------------- Kit */
.kit-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-4); }
.swatch { width: 120px; border-radius: var(--radius-control); overflow: hidden; box-shadow: var(--shadow-1); font-size: var(--fs-s); }
.swatch i { display: block; height: 48px; }
.swatch span { display: block; padding: var(--space-1) var(--space-2); background: var(--bg-surface); }
