/* =====================================================
   TowerManager — Estilos Globais
   ===================================================== */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --info: #0891b2;
  --neutral: #6b7280;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --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,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ── */
.navbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.navbar-brand a {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}
.navbar-menu { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
  background: #f1f5f9;
  color: var(--text);
  text-decoration: none;
}
.navbar-user { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 500; }

/* ── Main content ── */
.main-content { padding: 24px; max-width: 1200px; margin: 0 auto; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title { font-size: 24px; font-weight: 700; }
.page-title small { font-size: 14px; font-weight: 400; color: var(--text-muted); margin-left: 8px; }
.page-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.meta-item { font-size: 13px; color: var(--text-muted); }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
}
.section-title { font-size: 18px; font-weight: 600; }
.secao-equipamentos {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 28px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary   { background: var(--primary); color: white; }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--danger); color: white; }
.btn-sm  { padding: 5px 10px; font-size: 13px; }
.btn-xs  { padding: 3px 8px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}
.badge-principal    { background: #dbeafe; color: #1d4ed8; }
.badge-repetidora   { background: #ede9fe; color: #5b21b6; }
.badge-cliente_fixo { background: #d1fae5; color: #065f46; }
.badge-success      { background: #d1fae5; color: #065f46; }
.badge-neutral      { background: #f1f5f9; color: #475569; }
.badge-info         { background: #cffafe; color: #155e75; }
.badge-admin        { background: #fee2e2; color: #991b1b; }
.badge-tecnico      { background: #dbeafe; color: #1e40af; }
.badge-atendente    { background: #f3f4f6; color: #374151; }

/* Fabricante badges */
.badge-fab-mikrotik  { color: #cc0000; }
.badge-fab-ubiquiti  { color: #004eff; }
.badge-fab-mimosa    { color: #00875a; }
.badge-fab-intelbras { color: #003f8a; }
.badge-fab-outro     { color: #6b7280; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.form-card { padding: 28px; max-width: 760px; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table td.actions { display: flex; gap: 6px; }
.data-table td.mono { font-family: monospace; font-size: 13px; }

/* ── Device cards ── */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.device-card.device-inactive { opacity: .55; }
.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
}
.device-fabricante { font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.device-tipo { color: var(--text-muted); font-size: 11px; }
.device-nome { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.device-modelo { color: var(--text-muted); font-size: 13px; }
.device-ip { font-family: monospace; font-size: 13px; color: var(--info); }
.device-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.device-actions { display: flex; gap: 4px; }

/* ── Forms ── */
.form-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.form-fieldset legend {
  padding: 0 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-weight: 500; font-size: 13px; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-check-group { justify-content: flex-end; }
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  padding-top: 22px;
}
.check-label input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.coords-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 8px; }

/* ── Alerts ── */
.alert {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p { margin-bottom: 16px; font-size: 15px; }

/* ── Login page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f1f5f9;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.login-logo   { font-size: 48px; margin-bottom: 8px; }
.login-title  { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 28px; }
.login-form   { text-align: left; }
.login-form .form-group { margin-bottom: 18px; }

/* ── Link style ── */
.link-primary { color: var(--primary); font-weight: 500; }

/* ── Mono ── */
.mono { font-family: 'SFMono-Regular', 'Consolas', monospace; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .devices-grid { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
}

/* ═══════════════════════════════════════════════════
   Etapa 5 — Dashboard, Relatórios, Alertas
   ═══════════════════════════════════════════════════ */

/* ── Stat cards ── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.stat-card-value { font-size: 32px; font-weight: 700; line-height: 1.1; }
.stat-card-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card-icon  { font-size: 20px; margin-bottom: 6px; }
.stat-card.stat-success .stat-card-value { color: var(--success); }
.stat-card.stat-danger  .stat-card-value { color: var(--danger); }
.stat-card.stat-warning .stat-card-value { color: var(--warning); }

/* ── Status dot ── */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online  { background: var(--success); }
.status-dot.offline { background: var(--danger); animation: pulse-dot 2s infinite; }
.status-dot.unknown { background: var(--neutral); }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ── Dashboard layout ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  margin-bottom: 16px;
}
.dashboard-map {
  height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.events-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 420px;
}
.events-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.events-list { overflow-y: auto; flex: 1; }
.event-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.event-item:last-child { border-bottom: none; }
.event-msg  { font-size: 13px; line-height: 1.4; }
.event-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sev-critico { border-left: 3px solid var(--danger); }
.sev-atencao { border-left: 3px solid #f59e0b; }
.sev-aviso   { border-left: 3px solid var(--warning); }
.sev-info    { border-left: 3px solid var(--info); }

/* ── Chart cards ── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.charts-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
}
.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
  text-decoration: none;
  user-select: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Filter bar ── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}
.filter-group select,
.filter-group input[type="text"],
.filter-group input[type="date"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

/* ── Severity badges ── */
.badge-critico { background: #fee2e2; color: #991b1b; }
.badge-atencao { background: #fef9c3; color: #854d0e; }
.badge-aviso   { background: #fef3c7; color: #92400e; }
.badge-info    { background: #cffafe; color: #155e75; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ── Interface status badges ── */
.badge-ok   { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-down { background: #fee2e2; color: #991b1b; }

/* ── Painel capacity indicator ── */
.painel-atencao { color: #d97706; font-weight: 600; }
.painel-critico { color: var(--danger); font-weight: 600; }

/* ── PTP device card ── */
.badge-ptp { background: #d1fae5; color: #065f46; }
.device-art { color: var(--text-muted); text-align: center; margin: 8px 0 4px; transition: opacity .3s; }
.device-art-offline { opacity: 0.3; }
.device-art svg,
.ptp-antenna-svg {
  max-width: 220px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ── Responsive Etapa 5 ── */
@media (max-width: 900px) {
  .stat-cards    { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .charts-2col   { grid-template-columns: 1fr; }
}

/* ── PoE port grid (G.5) ── */
.poe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.poe-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.poe-port {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  user-select: none;
  transition: transform .1s;
}

.poe-port:hover {
  transform: scale(1.08);
}

.poe-port-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.poe-port-voltage {
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  opacity: 0.95;
}

.poe-port-verde    { background: #16a34a; color: #ffffff; }
.poe-port-laranja  { background: #f59e0b; color: #1a1a1a; }
.poe-port-vermelha { background: #dc2626; color: #ffffff; }
.poe-port-cinza    { background: #d1d5db; color: #6b7280; }

.poe-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.poe-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.poe-legend-item::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.poe-legend-verde::before    { background: #16a34a; }
.poe-legend-laranja::before  { background: #f59e0b; }
.poe-legend-vermelha::before { background: #dc2626; }
.poe-legend-cinza::before    { background: #d1d5db; }

@media (max-width: 480px) {
  .poe-port {
    width: 56px;
    height: 56px;
  }
  .poe-port-label   { font-size: 11px; }
  .poe-port-voltage { font-size: 10px; }
}

/* === Módulo OLT (Onda 2) === */
.info-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.info-table th { width: 40%; font-weight: 600; color: var(--text-muted); padding: 5px 8px 5px 0; vertical-align: top; }
.info-table td { padding: 5px 0; }

.stat-row { display: flex; gap: 1.5rem; }
.stat-item { text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.font-mono { font-family: monospace; }
.text-success { color: #16a34a; }
.text-danger  { color: #dc2626; }

.row-offline { opacity: 0.6; }

.table-responsive { overflow-x: auto; }
.badge-secondary { background: #e2e8f0; color: #475569; }
.badge-epon { background: #dbeafe; color: #1e40af; }
.badge-gpon { background: #ede9fe; color: #4c1d95; }

.alert { padding: 0.75rem 1rem; border-radius: 6px; font-size: 14px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #cffafe; color: #155e75; }


.temp-na { color: var(--text-muted); cursor: help; font-style: italic; }
