/* CS-CAM Monitor DVR — Identidade visual Controle Sul */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap');

:root {
  --cs-blue:       #0A2D6E;
  --cs-blue-mid:   #1A4FA8;
  --cs-blue-light: #2D6FD9;
  --cs-accent:     #00AAFF;
  --cs-green:      #16A34A;
  --cs-red:        #DC2626;
  --cs-yellow:     #D97706;
  --cs-gray-50:    #F8FAFC;
  --cs-gray-100:   #F1F5F9;
  --cs-gray-200:   #E2E8F0;
  --cs-gray-300:   #CBD5E1;
  --cs-gray-500:   #64748B;
  --cs-gray-700:   #334155;
  --cs-gray-900:   #0F172A;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--cs-gray-100);
  color: var(--cs-gray-900);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, var(--cs-blue) 0%, var(--cs-blue-mid) 100%);
  color: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.topbar-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.topbar-logo-img {
  height: 42px;
  width: auto;
  display: block;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  color: rgba(255,255,255,.8);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

.user-badge {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
}

.user-avatar {
  width: 24px;
  height: 24px;
  background: var(--cs-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--cs-blue);
}

.btn-logout {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.25);
  color: rgba(255,255,255,.85);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.22); color: #fff; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--cs-gray-900);
}

.page-subtitle {
  font-size: 13px;
  color: var(--cs-gray-500);
  margin-top: 2px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}

/* ── Dashboard stats ─────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 4px solid var(--cs-blue-light);
  position: relative;
  overflow: hidden;
}

.stat-card.verde  { border-left-color: var(--cs-green); }
.stat-card.vermelho { border-left-color: var(--cs-red); }
.stat-card.amarelo { border-left-color: var(--cs-yellow); }
.stat-card.azul   { border-left-color: var(--cs-accent); }
.stat-card.cinza  { border-left-color: var(--cs-gray-400, #94a3b8); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--cs-gray-500);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--cs-gray-900);
  line-height: 1;
  font-family: 'Roboto Mono', monospace;
}

.stat-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  opacity: .08;
}

/* ── Tabelas ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--cs-gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--cs-gray-500);
  border-bottom: 2px solid var(--cs-gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--cs-gray-100);
  color: var(--cs-gray-700);
  vertical-align: middle;
}

tbody tr:hover { background: var(--cs-gray-50); }
tbody tr:last-child td { border-bottom: none; }

.num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  background: var(--cs-blue);
  color: #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace;
  padding: 0 6px;
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge-verde   { background: #DCFCE7; color: #166534; }
.badge-vermelho { background: #FEE2E2; color: #991B1B; }
.badge-amarelo { background: #FEF9C3; color: #92400E; }
.badge-cinza   { background: var(--cs-gray-100); color: var(--cs-gray-500); }
.badge-azul    { background: #DBEAFE; color: #1E40AF; }

/* ── Botões ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: filter .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:hover  { filter: brightness(1.08); }

.btn-primary  { background: var(--cs-blue-light); color: #fff; }
.btn-success  { background: var(--cs-green); color: #fff; }
.btn-danger   { background: var(--cs-red); color: #fff; }
.btn-warning  { background: var(--cs-yellow); color: #fff; }
.btn-ghost    { background: transparent; color: var(--cs-gray-700); border: 1px solid var(--cs-gray-300); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }

/* ── Formulários ─────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--cs-gray-700);
  text-transform: uppercase;
  letter-spacing: .5px;
}

input, select, textarea {
  border: 1px solid var(--cs-gray-300);
  border-radius: 6px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--cs-gray-900);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--cs-blue-light);
  box-shadow: 0 0 0 3px rgba(45, 111, 217, .12);
}

input::placeholder { color: var(--cs-gray-300); }

.input-hint {
  font-size: 11px;
  color: var(--cs-gray-500);
}

/* ── Alertas flash ───────────────────────────────────────────────────────── */
.flash-wrap { margin-bottom: 16px; }

.flash {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.flash.ok    { background: #DCFCE7; color: #166534; border: 1px solid #86EFAC; }
.flash.erro  { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }
.flash.aviso { background: #FEF9C3; color: #92400E; border: 1px solid #FDE047; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--cs-gray-900);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ── Paginação ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.page-btn {
  padding: 5px 11px;
  border: 1px solid var(--cs-gray-300);
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  color: var(--cs-gray-700);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.page-btn:hover, .page-btn.active {
  background: var(--cs-blue-light);
  color: #fff;
  border-color: var(--cs-blue-light);
}

/* ── Eventos recentes ────────────────────────────────────────────────────── */
.event-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--cs-gray-100);
}
.event-row:last-child { border-bottom: none; }

.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.dot-verde   { background: var(--cs-green); }
.dot-vermelho { background: var(--cs-red); }
.dot-amarelo { background: var(--cs-yellow); }
.dot-azul    { background: var(--cs-accent); }

.event-body { flex: 1; }
.event-msg  { font-size: 13px; color: var(--cs-gray-700); }
.event-ts   { font-size: 11px; color: var(--cs-gray-500); margin-top: 2px; }

/* ── Toolbar de listagem ─────────────────────────────────────────────────── */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  max-width: 260px;
}

/* ── Responsivo ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .topbar-nav { display: none; }
  .page { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--cs-blue) 0%, var(--cs-blue-mid) 60%, var(--cs-blue-light) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 48px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo-img {
  max-width: 260px;
  width: 100%;
  height: auto;
}

.login-form .form-group { margin-bottom: 14px; }
.login-form label { display: block; margin-bottom: 5px; }
.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: var(--cs-gray-500);
  line-height: 1.6;
}

/* ── Indicador de status de monitoramento ────────────────────────────────── */
.monitor-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--cs-green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(1.3); }
}

/* Print para PDF */
@media print {
  .topbar, .page-header .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: 100%; }
  table { font-size: 11px; }
}

/* Rodapé de copyright */
.rodape {
  text-align: center;
  padding: 18px 20px;
  margin-top: 40px;
  font-size: 12px;
  color: var(--cs-gray-500, #8a94a6);
  border-top: 1px solid var(--cs-gray-200, #e5e8ee);
  background: var(--cs-gray-50, #f7f8fa);
}

/* Copyright na tela de login (sobre o fundo azul) */
.login-copyright {
  text-align: center;
  margin-top: 20px;
  font-size: 11px;
  color: rgba(255,255,255,.85);
}

/* ─── Monitoramento do servidor (velocímetros + hardware) ─── */
.servidor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 20px;
  align-items: center;
}
@media (max-width: 900px) {
  .servidor-grid { grid-template-columns: 1fr; }
}
.gauge-card {
  text-align: center;
}
.gauge-svg { width: 100%; max-width: 200px; }
.gauge-num {
  font-size: 30px;
  font-weight: 800;
  fill: var(--cs-gray-900, #1a2233);
}
.gauge-lbl {
  font-size: 13px;
  font-weight: 600;
  fill: var(--cs-gray-500, #8a94a6);
}
#gauge-cpu-arc, #gauge-ram-arc {
  transition: stroke-dashoffset .6s ease, stroke .3s ease;
}
.gauge-sub {
  font-size: 12px;
  color: var(--cs-gray-500, #8a94a6);
  margin-top: -8px;
}
.hw-card {
  background: var(--cs-gray-50, #f7f8fa);
  border: 1px solid var(--cs-gray-200, #e5e8ee);
  border-radius: 10px;
  padding: 14px 18px;
}
.hw-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--cs-gray-100, #eef0f4);
  gap: 12px;
}
.hw-row:last-child { border-bottom: none; }
.hw-lbl {
  font-size: 12px;
  color: var(--cs-gray-500, #8a94a6);
  font-weight: 600;
  white-space: nowrap;
}
.hw-val {
  font-size: 13px;
  color: var(--cs-gray-900, #1a2233);
  font-weight: 500;
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════
   MODO ESCURO — ativado por [data-tema="escuro"] no <html>
   Inverte a escala de cinzas e ajusta superfícies. As cores
   de marca (azul, verde, vermelho) permanecem.
   ═══════════════════════════════════════════════════════════ */
:root { --cs-surface: #fff; }

html[data-tema="escuro"] {
  --cs-gray-50:  #1a1f2b;
  --cs-gray-100: #161b25;
  --cs-gray-200: #2a3140;
  --cs-gray-300: #3a4256;
  --cs-gray-500: #9aa5b5;
  --cs-gray-700: #c9d2de;
  --cs-gray-900: #f1f5f9;
  --cs-surface:  #212836;
}
html[data-tema="escuro"] { background: #12161f; }
html[data-tema="escuro"] body { background: #12161f; color: var(--cs-gray-900); }

/* Superfícies que eram #fff fixo passam a usar a variável */
html[data-tema="escuro"] .card,
html[data-tema="escuro"] .stat-card,
html[data-tema="escuro"] .hw-card,
html[data-tema="escuro"] table,
html[data-tema="escuro"] .login-card,
html[data-tema="escuro"] input,
html[data-tema="escuro"] select,
html[data-tema="escuro"] textarea {
  background: var(--cs-surface) !important;
  color: var(--cs-gray-900);
}
html[data-tema="escuro"] input,
html[data-tema="escuro"] select,
html[data-tema="escuro"] textarea {
  border-color: var(--cs-gray-200);
}
html[data-tema="escuro"] thead th {
  background: var(--cs-gray-100) !important;
  color: var(--cs-gray-700);
}
html[data-tema="escuro"] tbody tr:hover { background: var(--cs-gray-100); }
html[data-tema="escuro"] .gauge-num { fill: var(--cs-gray-900); }
html[data-tema="escuro"] .hw-card { border-color: var(--cs-gray-200); }
/* Corrige typo de cor e garante superfície do velocímetro de fundo */
html[data-tema="escuro"] .gauge-svg path[stroke="#e5e8ee"] { stroke: #2a3140; }

/* ─── Switch (interruptor) para o modo escuro ─── */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--cs-gray-300, #cbd5e1);
  border-radius: 26px;
  transition: background .2s;
}
.switch-slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.switch input:checked + .switch-slider { background: var(--cs-accent, #00AAFF); }
.switch input:checked + .switch-slider:before { transform: translateX(22px); }

/* ─── Painel de progresso da varredura ─── */
.vp-barra {
  height: 8px;
  background: var(--cs-gray-200, #e5e8ee);
  border-radius: 6px;
  overflow: hidden;
}
.vp-barra-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cs-blue, #0A2D6E), var(--cs-accent, #00AAFF));
  border-radius: 6px;
  transition: width .3s ease;
}
.vp-metricas {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 10px;
}
.vp-chip {
  font-size: 12px;
  color: var(--cs-gray-500, #8a94a6);
  background: var(--cs-gray-50, #f7f8fa);
  border: 1px solid var(--cs-gray-200, #e5e8ee);
  border-radius: 20px;
  padding: 3px 11px;
}
.vp-chip b {
  color: var(--cs-gray-900, #1a2233);
  font-variant-numeric: tabular-nums;
}
.vp-chip.vp-ok b    { color: #16a34a; }
.vp-chip.vp-prob b  { color: #dc2626; }
.vp-chip.vp-falha b { color: #d97706; }

/* Feed de equipamentos passando */
.vp-feed {
  height: 148px;
  overflow: hidden;
  background: var(--cs-gray-50, #f7f8fa);
  border: 1px solid var(--cs-gray-200, #e5e8ee);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: 'Courier New', monospace;
  font-size: 11.5px;
  line-height: 1.75;
}
.vp-linha {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cs-gray-700, #5a6478);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: vp-entra .18s ease-out;
}
@keyframes vp-entra {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.vp-ico {
  display: inline-block;
  width: 15px;
  text-align: center;
  font-weight: 800;
  flex-shrink: 0;
}
.vp-linha.vp-ok .vp-ico       { color: #16a34a; }
.vp-linha.vp-problema .vp-ico { color: #dc2626; }
.vp-linha.vp-problema         { color: #dc2626; font-weight: 600; }
.vp-linha.vp-falha .vp-ico    { color: #d97706; }
.vp-linha.vp-falha            { color: #b45309; }
