/* Top Terra Gestão — design system (tema dark, acento terra/âmbar).
   Tabelas, cards, badges e botões portados do T3RRA, na paleta terra. */
:root {
  --sidebar-width: 240px;
  --sidebar-bg: #0a1120;
  --bg-dark:   #0f172a;
  --bg-card:   #1e293b;
  --bg-input:  #0f172a;
  --border:    #334155;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  --accent:    #d97706;
  --accent-h:  #b45309;
  --accent-rgb: 217,119,6;
}

body { background: var(--bg-dark); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; }

/* ── SIDEBAR ── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar-bg); border-right: 1px solid var(--border);
  z-index: 1000; transition: transform .25s ease; overflow-y: auto;
}
.sidebar-header { padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logo-text { font-size: 1.35rem; font-weight: 800; letter-spacing: 2px; color: var(--accent); }
.nav-section { padding: .6rem 1.2rem .2rem; font-size: .65rem; text-transform: uppercase; letter-spacing: 1.5px; color: #475569; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1.2rem; color: var(--muted) !important; font-size: .875rem;
  border-left: 3px solid transparent; transition: all .15s; border-radius: 0;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active {
  color: var(--text) !important; background: rgba(var(--accent-rgb),.12); border-left-color: var(--accent);
}
.sidebar .nav-link i { font-size: 1rem; width: 18px; }
.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--muted); }
.sidebar-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex-shrink: 0; }

/* ── TOPBAR + CONTEÚDO ── */
.top-bar {
  margin-left: var(--sidebar-width);
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem; height: 56px; position: sticky; top: 0; z-index: 900;
}
.top-bar-title { margin-left: .75rem; }
#sidebarToggle { display: none; }
.main-content { margin-left: var(--sidebar-width); padding: 1.5rem; }

/* ── CARDS ── */
.card, .card-dark {
  background: var(--bg-card) !important; border: 1px solid var(--border) !important;
  border-radius: 12px; color: var(--text); overflow: hidden;
}
.card-body { color: var(--text); }
.card-header {
  background: rgba(var(--accent-rgb),.1) !important;
  border-bottom: 1px solid rgba(var(--accent-rgb),.25) !important;
  color: var(--text) !important; font-weight: 600; font-size: .9rem; padding: .75rem 1.25rem;
}

/* ── FORMS ── */
.form-control, .form-select {
  background: var(--bg-input) !important; border: 1px solid var(--border) !important;
  color: var(--text) !important; border-radius: 8px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important; box-shadow: 0 0 0 .2rem rgba(var(--accent-rgb),.2) !important;
}
.form-label { color: var(--muted); font-size: .85rem; margin-bottom: .35rem; }
.form-select option { background: var(--bg-card); color: var(--text); }
.form-control::placeholder { color: #475569 !important; }

/* ── BOTÕES ── */
.btn-primary { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.btn-primary:hover { background: var(--accent-h) !important; border-color: var(--accent-h) !important; }
.btn-accent { background: var(--accent); border: none; color: #fff !important; border-radius: 8px; }
.btn-accent:hover { background: var(--accent-h); color: #fff !important; }
.btn-xs { padding: .2rem .5rem; font-size: .75rem; }

/* ── TABELAS ── */
.table { --bs-table-bg: transparent; color: var(--text); margin-bottom: 0; }
.table th {
  background: #0a1120; color: var(--muted);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .8px;
  padding: .65rem 1rem; border-color: var(--border) !important; white-space: nowrap;
}
.table td { padding: .75rem 1rem; border-color: rgba(51,65,85,.5) !important; font-size: .875rem; vertical-align: middle; }
.table-hover tbody tr:hover td { background: rgba(var(--accent-rgb),.06) !important; }
/* Cantos arredondados no cabeçalho de tabelas dentro de cards */
.card .table thead tr:first-child th:first-child { border-top-left-radius: 11px; }
.card .table thead tr:first-child th:last-child { border-top-right-radius: 11px; }
.card .table tbody tr:last-child td { border-bottom: 0; }

/* Tabela ordenável (setas nos cabeçalhos) */
table.sortable thead th[data-col] { cursor: pointer; user-select: none; white-space: nowrap; }
table.sortable thead th[data-col]:hover { background: rgba(255,255,255,.06); }
table.sortable thead th[data-col]::after { content: ' ⇅'; font-size: .7em; opacity: .35; }
table.sortable thead th[data-col].sort-asc::after  { content: ' ↑'; opacity: .9; color: var(--accent); }
table.sortable thead th[data-col].sort-desc::after { content: ' ↓'; opacity: .9; color: var(--accent); }

/* ── BADGES / STATUS PILLS ── */
.status-pill {
  font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  padding: .2rem .6rem; border-radius: 20px; text-transform: uppercase;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04);
  white-space: nowrap; display: inline-flex; align-items: center;
}
.status-pill.ok       { background: rgba(34,197,94,.15);  color: #86efac; border-color: rgba(34,197,94,.35); }
.status-pill.off      { background: rgba(148,163,184,.1); color: #94a3b8; border-color: rgba(148,163,184,.25); }
.status-pill.warn     { background: rgba(251,191,36,.15); color: #fbbf24; border-color: rgba(251,191,36,.3); }
.status-pill.info     { background: rgba(96,165,250,.15); color: #93c5fd; border-color: rgba(96,165,250,.3); }

/* ── PILLS DE FILTRO (toolbars "Todos | Ativos | ...") ── */
.filtro-pills { display: flex; gap: .5rem; flex-wrap: wrap; }
.filtro-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .7rem; border-radius: .4rem; font-size: .78rem;
  border: 1px solid var(--border); color: var(--text); text-decoration: none;
  cursor: pointer; transition: all .15s; user-select: none; background: transparent;
}
.filtro-pill:hover { filter: brightness(1.2); border-color: var(--accent); }
.filtro-pill.active { background: rgba(var(--accent-rgb),.15); border-color: var(--accent); color: #fff; }
.filtro-pill .pill-count { font-size: .68rem; font-weight: 700; background: rgba(0,0,0,.3); padding: .05rem .35rem; border-radius: .25rem; min-width: 1.2rem; text-align: center; }

/* ── BOTÕES DE AÇÃO (semáforo, ícones nas linhas) ── */
.action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; font-size: .9rem; line-height: 1; text-decoration: none;
  transition: transform .12s, background .15s, border-color .15s; background: transparent;
}
.action-btn:hover { transform: translateY(-1px); }
.action-btn.grey   { background: rgba(148,163,184,.12); color: #cbd5e1; border-color: rgba(148,163,184,.3); }
.action-btn.grey:hover { background: rgba(148,163,184,.22); }
.action-btn.blue   { background: rgba(59,130,246,.18); color: #93c5fd; border-color: rgba(59,130,246,.45); }
.action-btn.blue:hover { background: rgba(59,130,246,.32); }
.action-btn.green  { background: rgba(34,197,94,.18); color: #86efac; border-color: rgba(34,197,94,.45); }
.action-btn.green:hover { background: rgba(34,197,94,.3); }
.action-btn.red    { background: rgba(248,113,113,.18); color: #fca5a5; border-color: rgba(248,113,113,.45); }
.action-btn.red:hover { background: rgba(248,113,113,.3); }
.action-btn.amber  { background: rgba(251,191,36,.18); color: #fbbf24; border-color: rgba(251,191,36,.45); }
.action-btn.amber:hover { background: rgba(251,191,36,.32); }

/* ── ALERTS ── */
.alert { border-radius: 10px; border: none; }

/* ── OVERLAY MOBILE ── */
#sidebarOverlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 999; }
#sidebarOverlay.active { display: block; }

/* ── RESPONSIVO ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.sidebar-open { transform: translateX(0); }
  .top-bar { margin-left: 0; }
  .main-content { margin-left: 0; padding: 1rem; }
  #sidebarToggle { display: inline-flex !important; }
  #topBar { position: relative; }
  #topBar .top-bar-title { margin-left: .75rem; }
  .table th, .table td { padding: .5rem .5rem; font-size: .8rem; }
}
/* iOS: evita zoom automático em inputs com fonte < 16px */
@media (max-width: 767.98px) {
  input, select, textarea, .form-control, .form-select { font-size: 16px !important; }
}
