/* =============================================================
   ISP Manager — Main Stylesheet
   Design: Dark/Light theme, grafite elegante, ISP Network aesthetic
   ============================================================= */

:root {
  /* Cores primárias — azul-ciano técnico */
  --primary:      #0ea5e9;
  --primary-dark: #0284c7;
  --primary-light:#38bdf8;
  --accent:       #6366f1;  /* indigo - destaque UI */
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --info:         #6366f1;

  /* Tipografia */
  --font-main: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Transições */
  --transition: 0.2s ease;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 4px 24px rgba(0,0,0,0.12);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.08);
}

/* ---- TEMA ESCURO (padrão em :root) ---- */
:root {
  --bg:           #111827;
  --bg-card:      #1f2937;
  --bg-secondary: #111827;
  --bg-sidebar:   #0f172a;
  --bg-header:    #1f2937;
  --bg-input:     #374151;
  --text:         #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted:   #94a3b8;
  --text-sidebar: #94a3b8;
  --border:       #374151;
  --border-color: #374151;
  --border-focus: #0ea5e9;
  --hover:        #374151;
  --scrollbar:    #374151;
  --success:      #10b981;
  --status-online: #10b981;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #0ea5e9 100%);
}

/* ---- TEMA ESCURO explícito (mesmas vars do :root, para clareza) ---- */
html[data-theme="dark"] {
  --bg:           #111827;
  --bg-card:      #1f2937;
  --bg-secondary: #111827;
  --bg-sidebar:   #0f172a;
  --bg-header:    #1f2937;
  --bg-input:     #374151;
  --text:         #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted:   #94a3b8;
  --text-sidebar: #94a3b8;
  --border:       #374151;
  --border-color: #374151;
  --border-focus: #0ea5e9;
  --hover:        #374151;
  --scrollbar:    #374151;
}

/* ---- TEMA CLARO (declarado por último, com especificidade html[...]) ---- */
html[data-theme="light"] {
  --bg:           #f1f5f9;
  --bg-card:      #ffffff;
  --bg-secondary: #f1f5f9;
  --bg-sidebar:   #1e293b;
  --bg-header:    #ffffff;
  --bg-input:     #f8fafc;
  --text:         #1e293b;
  --text-secondary: #475569;
  --text-muted:   #64748b;
  --text-sidebar: #cbd5e1;
  --border:       #e2e8f0;
  --border-color: #e2e8f0;
  --border-focus: #0ea5e9;
  --hover:        #f0f9ff;
  --scrollbar:    #cbd5e1;
  --success:      #10b981;
  --status-online: #10b981;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #0ea5e9 100%);
}

/* ============================================================= */
*  { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--transition), color var(--transition);
}

/* ============================================================= */
/* LAYOUT                                                         */
/* ============================================================= */
.app-wrapper { display: flex; min-height: 100vh; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform var(--transition), width var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand .logo {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff;
  flex-shrink: 0;
}
.sidebar-brand .brand-text { flex: 1; overflow: hidden; }
.sidebar-brand .brand-name {
  font-weight: 700; font-size: .95rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand .brand-version {
  font-size: .7rem; color: var(--text-sidebar); margin-top: 1px;
}

.sidebar-section {
  padding: 20px 12px 8px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
}

.nav-item { list-style: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 2px 8px;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 12px rgba(14,165,233,0.35);
}
.nav-link .nav-icon { width: 18px; text-align: center; font-size: .9rem; }
.nav-link .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--transition);
}

/* ---- TOPBAR ---- */
.topbar {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 500;
}
.topbar-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 1.2rem; padding: 6px;
}
.topbar-title {
  font-size: 1rem; font-weight: 600; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-icon {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); font-size: .9rem;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); background: var(--hover); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px 4px 6px;
  cursor: pointer; text-decoration: none; color: var(--text);
  font-size: .82rem;
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: .75rem; font-weight: 700;
}

/* ---- PAGE CONTENT ---- */
.page-content { flex: 1; padding: 24px; }

/* ---- FOOTER ---- */
.app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  font-size: .78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================================= */
/* COMPONENTES                                                    */
/* ============================================================= */

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600;
}
.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }
.stat-card .stat-trend { font-size: .75rem; margin-top: 6px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; border: none;
  cursor: pointer; text-decoration: none;
  transition: all var(--transition); white-space: nowrap;
}
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: .95rem; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover   { background: #059669; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover    { background: #dc2626; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-info      { background: var(--info); color: #fff; }
.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover   { border-color: var(--primary); color: var(--primary); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover     { background: var(--hover); color: var(--text); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-online   { background: rgba(16,185,129,.15); color: #10b981; }
.badge-offline  { background: rgba(239,68,68,.15);  color: #ef4444; }
.badge-unknown  { background: rgba(100,116,139,.15); color: #94a3b8; }
.badge-phase1   { background: rgba(14,165,233,.15); color: #0ea5e9; }
.badge-phase2   { background: rgba(139,92,246,.15); color: #a78bfa; }
.badge-success  { background: rgba(16,185,129,.15); color: #10b981; }
.badge-danger   { background: rgba(239,68,68,.15);  color: #ef4444; }
.badge-warning  { background: rgba(245,158,11,.15); color: #f59e0b; }
.badge-info     { background: rgba(99,102,241,.15); color: #6366f1; }

/* Status dot animado */
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
}
.status-dot.online  { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.2); animation: pulse-green 2s infinite; }
.status-dot.offline { background: #ef4444; }
.status-dot.unknown { background: #94a3b8; }
@keyframes pulse-green {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}
@keyframes blink-red {
  0%,100% { opacity: 1; }
  50%      { opacity: .2; }
}
.blink-offline { animation: blink-red 1s infinite; }

/* Formulários */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: 6px; color: var(--text-muted); }
.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .875rem; transition: border-color var(--transition);
  font-family: var(--font-main);
}
.form-control:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Tabelas */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  padding: 11px 14px; text-align: left; font-weight: 600;
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  background: var(--bg-input); white-space: nowrap;
}
.table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:hover td { background: var(--hover); }
.table tr:last-child td { border-bottom: none; }

/* Alertas */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .875rem; margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3); color: #10b981; }
.alert-danger  { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #ef4444; }
.alert-warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); color: #f59e0b; }
.alert-info    { background: rgba(14,165,233,.12); border: 1px solid rgba(14,165,233,.3); color: #0ea5e9; }

/* Modais */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 640px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  animation: modal-in .2s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes modal-in { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:scale(1); } }
.modal-header {
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-body  { padding: 20px; }
.modal-footer{ padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.2rem; }

/* Mapa */
#main-map { height: 100%; width: 100%; border-radius: var(--radius); }
.map-container { height: calc(100vh - 140px); position: relative; }

/* Search bar */
.search-bar {
  position: relative;
}
.search-bar input {
  padding-left: 36px;
}
.search-bar .search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .85rem; pointer-events: none;
}

/* Toast */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 99999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow); font-size: .85rem;
  display: flex; align-items: center; gap: 10px;
  min-width: 280px; max-width: 360px;
  animation: toast-in .25s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
@keyframes toast-in { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }

/* Tabela responsiva — scroll horizontal */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .page-content { padding: 16px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .hide-mobile { display: none !important; }
  .topbar-title { font-size: .88rem; }
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.5);
}
.sidebar-overlay.active { display: block; }

/* Grid helpers */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-2,.grid-3,.grid-4,.grid-5 { grid-template-columns: 1fr; }
}

/* Utilitários */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-mono); font-size: .82rem; }
.w-100 { width: 100%; }
.rounded { border-radius: var(--radius); }
.border { border: 1px solid var(--border); }
.overflow-hidden { overflow: hidden; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Progress bar */
.progress { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress-bar { height: 100%; border-radius: 4px; transition: width .4s ease; }
.progress-bar.online  { background: var(--success); }
.progress-bar.offline { background: var(--danger); }

/* Leaflet custom markers */
.map-pin-ph1 { background: #0ea5e9; }
.map-pin-ph2 { background: #a78bfa; }
.map-pin-offline { animation: blink-red 1s infinite; }

/* ============================================================= */
/* COMPATIBILIDADE BOOTSTRAP-LIKE (grid, forms, cards, tabelas)  */
/* Necessário pois as views usam classes utilitárias do Bootstrap */
/* ============================================================= */

/* ---- Contenção global anti-scroll-horizontal (mobile) ---- */
html, body { max-width: 100%; overflow-x: hidden; }
* { min-width: 0; }
img, svg, video, canvas, table { max-width: 100%; }

/* ---- GRID (row / col) ---- */
.row { display: flex; flex-wrap: wrap; margin-left: -8px; margin-right: -8px; }
.row > [class*="col-"], .row > .col { padding-left: 8px; padding-right: 8px; }
.col { flex: 1 0 0%; }
.g-1 { gap: 4px; } .g-2 { gap: 8px; } .g-3 { gap: 16px; } .g-4 { gap: 24px; }
.row.g-1, .row.g-2, .row.g-3, .row.g-4 { margin: 0; }
.row.g-1 > *, .row.g-2 > *, .row.g-3 > *, .row.g-4 > * { padding: 0; }
.row.g-1 { gap: 4px; } .row.g-2 { gap: 8px; } .row.g-3 { gap: 16px; } .row.g-4 { gap: 24px; }

/* Colunas base (12 cols) */
.col-1{flex:0 0 8.333%;max-width:8.333%}.col-2{flex:0 0 16.666%;max-width:16.666%}
.col-3{flex:0 0 25%;max-width:25%}.col-4{flex:0 0 33.333%;max-width:33.333%}
.col-5{flex:0 0 41.666%;max-width:41.666%}.col-6{flex:0 0 50%;max-width:50%}
.col-7{flex:0 0 58.333%;max-width:58.333%}.col-8{flex:0 0 66.666%;max-width:66.666%}
.col-9{flex:0 0 75%;max-width:75%}.col-10{flex:0 0 83.333%;max-width:83.333%}
.col-11{flex:0 0 91.666%;max-width:91.666%}.col-12{flex:0 0 100%;max-width:100%}

/* Quando há gap no row, usar width em vez de flex-basis com padding */
.row[class*="g-"] > [class*="col-"] { padding-left: 0; padding-right: 0; }

/* Breakpoint md (>= 768px) */
@media (min-width: 768px) {
  .col-md-1{flex:0 0 8.333%;max-width:8.333%}.col-md-2{flex:0 0 16.666%;max-width:16.666%}
  .col-md-3{flex:0 0 25%;max-width:25%}.col-md-4{flex:0 0 33.333%;max-width:33.333%}
  .col-md-5{flex:0 0 41.666%;max-width:41.666%}.col-md-6{flex:0 0 50%;max-width:50%}
  .col-md-7{flex:0 0 58.333%;max-width:58.333%}.col-md-8{flex:0 0 66.666%;max-width:66.666%}
  .col-md-9{flex:0 0 75%;max-width:75%}.col-md-10{flex:0 0 83.333%;max-width:83.333%}
  .col-md-11{flex:0 0 91.666%;max-width:91.666%}.col-md-12{flex:0 0 100%;max-width:100%}
}
/* Breakpoint lg (>= 992px) */
@media (min-width: 992px) {
  .col-lg-3{flex:0 0 25%;max-width:25%}.col-lg-4{flex:0 0 33.333%;max-width:33.333%}
  .col-lg-5{flex:0 0 41.666%;max-width:41.666%}.col-lg-6{flex:0 0 50%;max-width:50%}
  .col-lg-7{flex:0 0 58.333%;max-width:58.333%}.col-lg-8{flex:0 0 66.666%;max-width:66.666%}
}
/* Colunas mobile (col-6 vale em qualquer largura por padrão; abaixo de md viram fluidas) */
@media (max-width: 767px) {
  .col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,
  .col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12 { flex: 0 0 100%; max-width: 100%; }
  .col-6 { flex: 0 0 50%; max-width: 50%; } /* mantém 2 col no mobile p/ stat cards */
}

.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.align-items-center { align-items: center; }
.flex-grow-1 { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.d-flex { display: flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100% !important; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* ---- CARDS ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 1rem; font-weight: 600; margin: 0; }
.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }
.card-body.py-2 { padding-top: 8px; padding-bottom: 8px; }

/* ---- FORMS ---- */
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-text { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-control, .form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color var(--transition);
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 72px; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%2394a3b8' d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
}

/* Input group */
.input-group { display: flex; align-items: stretch; }
.input-group > .form-control { border-radius: 0; }
.input-group > :first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.input-group > :last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.input-group-text {
  display: flex; align-items: center;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-right: none;
  color: var(--text-muted);
  font-size: .85rem;
}
.input-group .btn { border: 1px solid var(--border); }

/* Switch / checkbox */
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.form-switch .form-check-input { width: 36px; height: 20px; border-radius: 20px; appearance: none; background: var(--border); position: relative; transition: .2s; }
.form-switch .form-check-input:checked { background: var(--accent); }
.form-switch .form-check-input::before { content:''; position:absolute; width:16px; height:16px; border-radius:50%; background:#fff; top:2px; left:2px; transition:.2s; }
.form-switch .form-check-input:checked::before { left: 18px; }
.form-check-label { font-size: .88rem; cursor: pointer; }

/* ---- SEARCH BOX ---- */
.search-box { position: relative; width: 100%; }
.search-box .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .85rem; pointer-events: none;
}
.search-box .form-control { padding-left: 34px; }

/* ---- TABLES ---- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: middle; }
.table thead th {
  background: var(--bg-input);
  color: var(--text-muted);
  font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: none; }
.table-hover tbody tr:hover { background: var(--hover); }
.table.table-sm th, .table.table-sm td { padding: 7px 10px; }
.table .table-warning { background: rgba(245,158,11,.12); }
.mb-0 { margin-bottom: 0 !important; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; line-height: 1.4;
  white-space: nowrap;
}
.bg-primary   { background: var(--primary); color: #fff; }
.bg-secondary { background: #64748b; color: #fff; }
.bg-success   { background: var(--success); color: #fff; }
.bg-danger    { background: var(--danger); color: #fff; }
.bg-warning   { background: var(--warning); color: #1a1a1a; }
.bg-info      { background: var(--info); color: #fff; }
.phase-1 { background: var(--primary); color: #fff; }
.phase-2 { background: #8b5cf6; color: #fff; }

/* ---- BUTTONS (compat) ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: .88rem; font-weight: 500; cursor: pointer;
  text-decoration: none; transition: all var(--transition);
  font-family: inherit; line-height: 1.4;
}
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg-input); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--hover); }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-secondary { border-color: var(--border); color: var(--text-muted); background: transparent; }
.btn-outline-secondary:hover { background: var(--hover); color: var(--text); }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-outline-warning { border-color: var(--warning); color: var(--warning); background: transparent; }
.btn-outline-warning:hover { background: var(--warning); color: #1a1a1a; }
.btn-outline-success { border-color: var(--success); color: var(--success); background: transparent; }
.btn-outline-success:hover { background: var(--success); color: #fff; }
.btn-outline-info { border-color: var(--info); color: var(--info); background: transparent; }
.btn-outline-info:hover { background: var(--info); color: #fff; }
.btn.btn-icon { width: 32px; height: 32px; padding: 0; }

/* ---- ALERTS ---- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .88rem; border: 1px solid transparent; }
.alert-info    { background: rgba(99,102,241,.1);  border-color: rgba(99,102,241,.3);  color: var(--text); }
.alert-danger  { background: rgba(239,68,68,.1);   border-color: rgba(239,68,68,.3);   color: var(--text); }
.alert-success { background: rgba(16,185,129,.1);  border-color: rgba(16,185,129,.3);  color: var(--text); }
.alert-warning { background: rgba(245,158,11,.1);  border-color: rgba(245,158,11,.3);  color: var(--text); }
.alert ul { margin: 0; padding-left: 18px; }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; display: block; }
.empty-state h4 { font-size: 1.05rem; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: .88rem; margin-bottom: 16px; }

/* ---- PAGINATION ---- */
.pagination { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.pagination .page-link {
  display: flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: .85rem;
  background: var(--bg-card);
}
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .page-link:hover { background: var(--hover); }

/* ---- HELPERS de texto/cor ---- */
.text-muted { color: var(--text-muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.text-info { color: var(--info) !important; }
.text-end { text-align: right !important; }
.text-center { text-align: center !important; }
.text-decoration-none { text-decoration: none !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.fw-mono, .fw-monospace { font-family: var(--font-mono); }

/* ---- SPACING UTILITIES ---- */
.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:16px}.mt-4{margin-top:24px}
.mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:16px}.mb-4{margin-bottom:24px}
.me-1{margin-right:4px}.me-2{margin-right:8px}.ms-1{margin-left:4px}.ms-2{margin-left:8px}
.p-0{padding:0}.p-2{padding:8px}.p-3{padding:16px}.py-2{padding-top:8px;padding-bottom:8px}
.py-3{padding-top:16px;padding-bottom:16px}.py-5{padding-top:48px;padding-bottom:48px}
.g-2{gap:8px}.g-3{gap:16px}
.border-top { border-top: 1px solid var(--border) !important; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
code { font-family: var(--font-mono); font-size: .82em; color: var(--primary-light); background: rgba(14,165,233,.1); padding: 2px 5px; border-radius: 4px; }

/* ---- PAGE HEADER (usado nas views novas) ---- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-subtitle { font-size: .9rem; color: var(--text-muted); margin: 4px 0 0; }

/* ---- STAT CARDS (compat) ---- */
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-bottom: 12px; }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* ---- MODAL OVERLAY (logs diff) ---- */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.6); align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.active { display: flex; }
.modal-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-header-box { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header-box h4 { margin: 0; font-size: 1.05rem; }
.modal-body-box { padding: 18px; overflow-y: auto; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; }

/* ---- RESPONSIVO: page-header e tabelas no mobile ---- */
@media (max-width: 767px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn, .page-header > div:last-child { width: 100%; }
  .page-title { font-size: 1.2rem; }
  .card-body { padding: 14px; }
  .table th, .table td { padding: 9px 10px; font-size: .82rem; }
  .d-flex.gap-2 { flex-wrap: wrap; }
}
