/*
  Identidade visual — "Monitoramento de SLA & Entregas".
  Conceito: torre de controle / NOC (network operations center) logístico.
  Dark = navy profundo com ciano vivo e semáforos de status (verde/âmbar/
  vermelho) em alto contraste — tela de sala de controle à noite. Light =
  "sala de controle clara", branco-azulado com ciano escuro — mesma central
  de monitoramento, turno diurno. Títulos em Rajdhani (técnico, quadrado).
  Grade densa, painéis com borda fina luminosa (glow sutil no dark). Pontos
  de status pulsam via CSS respeitando prefers-reduced-motion.

  Arquivo independente: não referencia dashboard-shared.css. Continua
  carregando dashboard-shared.js (helpers de tema/formatação/tabela/chips),
  por isso define todos os tokens que aquele script espera.
*/

:root {
  color-scheme: light;

  /* ---------- Tokens exigidos pelo dashboard-shared.js ---------- */
  --text-primary: #0b2a3d;
  --text-secondary: #3e5c6d;
  --text-muted: #7c93a0;
  --surface-1: #ffffff;
  --gridline: #d7e2e8;
  --baseline: #b7c8d1;

  --series-1: #0f7a8c; /* ciano escuro */
  --series-2: #4a4fd1; /* índigo */
  --series-3: #b23a7c; /* magenta */
  --series-4: #8a5a2f; /* marrom-ferrugem */
  --series-5: #45607a; /* ardósia */
  --series-6: #6a4ca0; /* violeta */
  --series-7: #2f7a5c; /* verde-azulado apagado */
  --series-8: #9c8a3a; /* cáqui dourado */

  --status-good: #12b76a;
  --status-warning: #f59e0b;
  --status-serious: #f2711f;
  --status-critical: #e0393e;

  /* ---------- Tokens próprios do tema ---------- */
  --page-plane: #eef3f6;
  --surface-2: #e3edf2;
  --border-ring: rgba(11, 42, 61, 0.14);
  --panel-glow: 0 0 0 rgba(0, 0, 0, 0);
  --cyan: #0f7a8c;
  --shadow-card: 0 1px 0 rgba(11, 42, 61, 0.05), 0 6px 16px rgba(11, 42, 61, 0.06);

  --font-title: "Rajdhani", "Inter", system-ui, sans-serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --text-primary: #eaf6fb;
    --text-secondary: #a9c4d4;
    --text-muted: #6f8fa3;
    --surface-1: #0a1826;
    --gridline: #173245;
    --baseline: #234a61;

    --series-1: #22d3ee;
    --series-2: #818cf8;
    --series-3: #e879b9;
    --series-4: #c99a6a;
    --series-5: #7fa8c9;
    --series-6: #a78bd6;
    --series-7: #5fd1a8;
    --series-8: #d9c56a;

    --status-good: #22c55e;
    --status-warning: #fbbf24;
    --status-serious: #fb8a3c;
    --status-critical: #f04438;

    --page-plane: #050e16;
    --surface-2: #0f2233;
    --border-ring: rgba(234, 246, 251, 0.16);
    --panel-glow: 0 0 0 1px rgba(34, 211, 238, 0.08);
    --cyan: #22d3ee;
    --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --text-primary: #eaf6fb;
  --text-secondary: #a9c4d4;
  --text-muted: #6f8fa3;
  --surface-1: #0a1826;
  --gridline: #173245;
  --baseline: #234a61;

  --series-1: #22d3ee;
  --series-2: #818cf8;
  --series-3: #e879b9;
  --series-4: #c99a6a;
  --series-5: #7fa8c9;
  --series-6: #a78bd6;
  --series-7: #5fd1a8;
  --series-8: #d9c56a;

  --status-good: #22c55e;
  --status-warning: #fbbf24;
  --status-serious: #fb8a3c;
  --status-critical: #f04438;

  --page-plane: #050e16;
  --surface-2: #0f2233;
  --border-ring: rgba(234, 246, 251, 0.16);
  --panel-glow: 0 0 0 1px rgba(34, 211, 238, 0.08);
  --cyan: #22d3ee;
  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.45);
}

/* ---------- Reset ---------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--page-plane);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-title); }

/* ---------- Layout geral ---------- */

.noc-shell { display: flex; flex-direction: column; min-height: 100vh; }

.noc-main {
  flex: 1;
  width: 100%;
  max-width: 1520px;
  margin: 0 auto;
  padding: 16px 18px 26px;
}

/* ---------- Cabeçalho ---------- */

.noc-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface-1);
  border-bottom: 1px solid var(--cyan);
  box-shadow: var(--panel-glow);
}

.noc-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  max-width: 1520px;
  margin: 0 auto;
}

.noc-header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }

.noc-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--border-ring);
  white-space: nowrap;
}
.noc-back:hover { color: var(--cyan); border-color: var(--cyan); }
.noc-back .material-symbols-outlined { font-size: 16px; }

.noc-titles { min-width: 0; }
.noc-eyebrow {
  font-family: var(--font-title);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 2px;
}
.noc-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.noc-header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.noc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border: 1px solid var(--border-ring);
  color: var(--text-secondary);
  white-space: nowrap;
}
.noc-badge .material-symbols-outlined { font-size: 14px; }

.noc-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-ring);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.noc-theme-toggle:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------- Faixa de status (semáforos por região + relógio) ---------- */

.noc-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-1);
  border: 1px solid var(--border-ring);
  box-shadow: var(--panel-glow);
  padding: 10px 14px;
  margin: 16px 0;
}

.noc-semaphores { display: flex; flex-wrap: wrap; gap: 8px; }

.noc-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--border-ring);
  background: var(--surface-2);
  white-space: nowrap;
}

.noc-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--status-good);
  position: relative;
}
.noc-pulse-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.45;
  animation: noc-pulse 1.8s ease-out infinite;
}
.noc-pulse-dot.is-warning { background: var(--status-warning); }
.noc-pulse-dot.is-serious { background: var(--status-serious); }
.noc-pulse-dot.is-critical { background: var(--status-critical); }

@keyframes noc-pulse {
  0% { transform: scale(0.6); opacity: 0.5; }
  100% { transform: scale(2.1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .noc-pulse-dot::after { animation: none; }
}

.noc-clock {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.noc-clock .material-symbols-outlined { font-size: 17px; color: var(--cyan); }
.noc-clock-time { font-weight: 700; color: var(--text-primary); }

/* ---------- Filtros ---------- */

.noc-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }

.noc-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-1);
  border: 1px solid var(--border-ring);
  padding: 3px;
}

.dash-filter-chip {
  appearance: none;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.dash-filter-chip[aria-pressed="true"] { background: var(--cyan); color: #04222a; }
.dash-filter-chip:not([aria-pressed="true"]):hover { color: var(--text-primary); }

.noc-select {
  appearance: none;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-1);
  border: 1px solid var(--border-ring);
  padding: 8px 30px 8px 12px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237c93a0' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ---------- KPIs (readouts) ---------- */

.noc-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.noc-kpi {
  background: var(--surface-1);
  border: 1px solid var(--border-ring);
  border-top: 3px solid var(--cyan);
  box-shadow: var(--panel-glow);
  padding: 14px 15px;
  min-width: 0;
}
.noc-kpi--good { border-top-color: var(--status-good); }
.noc-kpi--warning { border-top-color: var(--status-warning); }

.noc-kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.noc-kpi-value-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.noc-kpi-value {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.noc-kpi-delta { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.noc-kpi-delta .material-symbols-outlined { font-size: 14px; }
.noc-kpi-delta.is-good { color: var(--status-good); }
.noc-kpi-delta.is-neutral { color: var(--text-muted); }
.noc-kpi-sub { font-size: 11.5px; color: var(--text-muted); margin: 6px 0 0; }

/* ---------- Painel de metas (SLA) ---------- */

.noc-goal-panel {
  background: var(--surface-1);
  border: 1px solid var(--border-ring);
  border-top: 3px solid var(--status-warning);
  box-shadow: var(--panel-glow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}
.noc-goal-row { display: flex; justify-content: space-between; font-size: 12.5px; }
.noc-goal-row .label { color: var(--text-secondary); }
.noc-goal-row .value { font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ---------- Grade densa ---------- */

.noc-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; margin-bottom: 10px; }

.noc-panel {
  background: var(--surface-1);
  border: 1px solid var(--border-ring);
  box-shadow: var(--panel-glow);
  padding: 14px 14px 10px;
  grid-column: span 12;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.noc-panel--8 { grid-column: span 12; }
.noc-panel--7 { grid-column: span 12; }
.noc-panel--5 { grid-column: span 12; }
.noc-panel--4 { grid-column: span 12; }
@media (min-width: 860px) {
  .noc-panel--8 { grid-column: span 8; }
  .noc-panel--7 { grid-column: span 7; }
  .noc-panel--5 { grid-column: span 5; }
  .noc-panel--4 { grid-column: span 4; }
}

.noc-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.noc-panel-title {
  font-family: var(--font-title);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}
.noc-panel-caption { font-size: 11.5px; color: var(--text-muted); margin: 3px 0 0; }

.noc-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-ring);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.noc-icon-btn:hover { color: var(--text-primary); border-color: var(--cyan); }
.noc-icon-btn[aria-pressed="true"] { color: var(--cyan); border-color: var(--cyan); }

.dash-chart-body.is-hidden { display: none; }

.noc-canvas-wrap { position: relative; width: 100%; flex: 1; min-height: 210px; }
.noc-canvas-wrap canvas { width: 100% !important; height: 100% !important; }
.noc-canvas-wrap--tall { min-height: 280px; }

/* Grade de gauges (SLA por região) */
.noc-gauge-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; flex: 1; }
.noc-gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.noc-gauge-canvas-wrap { position: relative; width: 100%; height: 100px; }
.noc-gauge-canvas-wrap canvas { width: 100% !important; height: 100% !important; }
.noc-gauge-label { font-size: 11.5px; font-weight: 700; color: var(--text-secondary); text-align: center; }

.dash-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 11.5px; color: var(--text-secondary); }
.dash-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dash-legend-swatch { width: 10px; height: 10px; flex-shrink: 0; }

/* ---------- Feed de últimas entregas ---------- */

.noc-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; overflow-y: auto; max-height: 300px; }
.noc-feed-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--gridline);
  font-size: 12px;
}
.noc-feed-item:last-child { border-bottom: none; }
.noc-feed-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--status-good); }
.noc-feed-dot.is-warning { background: var(--status-warning); }
.noc-feed-dot.is-critical { background: var(--status-critical); }
.noc-feed-main { flex: 1; min-width: 0; }
.noc-feed-code { font-weight: 700; color: var(--text-primary); }
.noc-feed-unit { color: var(--text-muted); }
.noc-feed-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Tabelas ---------- */

.noc-table-wrap { display: none; overflow-x: auto; margin-top: 8px; }
.noc-table-wrap.is-visible { display: block; }
.noc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 420px; }
.noc-table caption { text-align: left; font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.noc-table th, .noc-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}
.noc-table th { color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Badges de status ---------- */

.noc-status-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; }
.noc-status-chip .material-symbols-outlined { font-size: 14px; }
.noc-badge--good { color: var(--status-good); background: color-mix(in srgb, var(--status-good) 14%, transparent); }
.noc-badge--warning { color: var(--status-warning); background: color-mix(in srgb, var(--status-warning) 18%, transparent); }
.noc-badge--serious { color: var(--status-serious); background: color-mix(in srgb, var(--status-serious) 16%, transparent); }
.noc-badge--critical { color: var(--status-critical); background: color-mix(in srgb, var(--status-critical) 14%, transparent); }

/* ---------- Rodapé ---------- */

.noc-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-ring);
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Responsivo ---------- */

@media (max-width: 480px) {
  .noc-title { font-size: 17px; }
  .noc-kpi-value { font-size: 23px; }
  .noc-main { padding: 12px; }
  .noc-header-inner { padding: 10px 12px; }
  .noc-status-bar { flex-direction: column; align-items: flex-start; }
}
