/* ═══════════════════════════════════════════
   CAC System — Stylesheet
   Paleta: Verde militar escuro + cinza grafite
   ═══════════════════════════════════════════ */

:root {
  --verde-escuro: #1a2e1a;
  --verde-medio: #2d4a2d;
  --verde-claro: #3d6b3d;
  --verde-accent: #4a8c4a;
  --verde-hover: #5aaa5a;
  --cinza-bg: #0f1410;
  --cinza-card: #1c2419;
  --cinza-borda: #2a3a28;
  --texto-primario: #e8f0e8;
  --texto-secundario: #9ab09a;
  --texto-muted: #5a705a;
  --alerta-vermelho: #c0392b;
  --alerta-amarelo: #d4a017;
  --alerta-verde: #27ae60;
  --fonte-mono: 'JetBrains Mono', 'Courier New', monospace;
  --fonte-sans: 'Inter', system-ui, sans-serif;
  --radius: 6px;
  --sombra: 0 2px 12px rgba(0,0,0,0.4);
}

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

body {
  background: var(--cinza-bg);
  color: var(--texto-primario);
  font-family: var(--fonte-sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

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

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--cinza-bg); }
::-webkit-scrollbar-thumb { background: var(--verde-medio); border-radius: 3px; }

/* ── Layout ─────────────────────────────── */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--verde-escuro);
  border-right: 1px solid var(--cinza-borda);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-logo {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--cinza-borda);
  text-align: center;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 20px 4px;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--texto-muted);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--texto-secundario);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  font-size: 13px;
}

.nav-item:hover {
  background: var(--verde-medio);
  color: var(--texto-primario);
  border-left-color: var(--verde-accent);
}

.nav-item.active {
  background: var(--verde-medio);
  color: var(--verde-hover);
  border-left-color: var(--verde-hover);
}

.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--cinza-borda);
  font-size: 11px;
  color: var(--texto-muted);
}

.sidebar-footer strong { color: var(--texto-secundario); }

/* ── Main Content ───────────────────────── */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.main-content::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 420px;
  height: 420px;
  background-image: url('/static/cachub-logo.png');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}

.topbar {
  background: var(--cinza-card);
  border-bottom: 1px solid var(--cinza-borda);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.page {
  padding: 28px;
  flex: 1;
  display: none;
  position: relative;
  z-index: 1;
}
.page.active { display: block; }

/* ── Cards ──────────────────────────────── */
.card {
  background: var(--cinza-card);
  border: 1px solid var(--cinza-borda);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--sombra);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--texto-secundario);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

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

.stat-card {
  background: var(--cinza-card);
  border: 1px solid var(--cinza-borda);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.stat-card:hover { border-color: var(--verde-accent); transform: translateY(-2px); }
.stat-card.card-selected { border-color: var(--verde-hover); box-shadow: 0 0 0 2px var(--verde-accent); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--verde-accent);
}

.stat-card.alerta::before { background: var(--alerta-amarelo); }
.stat-card.perigo::before { background: var(--alerta-vermelho); }

.stat-number {
  font-size: 36px;
  font-weight: 700;
  font-family: var(--fonte-mono);
  color: var(--verde-hover);
  line-height: 1;
}

.stat-card.alerta .stat-number { color: var(--alerta-amarelo); }
.stat-card.perigo .stat-number { color: var(--alerta-vermelho); }

.stat-label {
  font-size: 11px;
  color: var(--texto-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 6px;
}

/* ── Tabela ─────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--cinza-borda);
}

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

thead tr { background: var(--verde-escuro); }

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--texto-secundario);
  font-weight: 700;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-top: 1px solid var(--cinza-borda);
  color: var(--texto-primario);
}

tbody tr:hover { background: rgba(255,255,255,0.03); }
.mono { font-family: var(--fonte-mono); font-size: 12px; }

/* ── Badges ─────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-ok { background: rgba(39,174,96,0.15); color: #27ae60; border: 1px solid rgba(39,174,96,0.3); }
.badge-alerta { background: rgba(212,160,23,0.15); color: #d4a017; border: 1px solid rgba(212,160,23,0.3); }
.badge-vencida { background: rgba(192,57,43,0.15); color: #e74c3c; border: 1px solid rgba(192,57,43,0.3); }

/* ── Botões ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-primary { background: var(--verde-accent); color: white; }
.btn-primary:hover { background: var(--verde-hover); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--cinza-borda);
  color: var(--texto-secundario);
}
.btn-outline:hover { border-color: var(--verde-accent); color: var(--verde-hover); }

.btn-danger {
  background: transparent;
  border: 1px solid rgba(192,57,43,0.4);
  color: #e74c3c;
}
.btn-danger:hover { background: rgba(192,57,43,0.15); }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-icon { padding: 6px 8px; }
.btn-link { background:none; border:none; color:var(--verde-hover); cursor:pointer; font-size:13px; padding:0; text-decoration:underline; }

/* ── Formulários ────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--texto-muted);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  background: var(--cinza-bg);
  border: 1px solid var(--cinza-borda);
  border-radius: var(--radius);
  color: var(--texto-primario);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--verde-accent);
}

/* ── Upload Zone ────────────────────────── */
.upload-zone {
  border: 2px dashed var(--cinza-borda);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--texto-muted);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--verde-accent);
  background: rgba(74,140,74,0.05);
  color: var(--verde-hover);
}

.upload-zone .icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone p { font-size: 13px; }
.upload-zone small { font-size: 11px; opacity: 0.6; }

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

.modal-overlay.open { display: flex; }

.modal {
  background: var(--cinza-card);
  border: 1px solid var(--cinza-borda);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--texto-muted); cursor: pointer; font-size: 20px; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--texto-primario); }

/* ── Alertas inline ─────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 12px; margin-bottom: 12px; }
.alert-success { background: rgba(39,174,96,0.1); border: 1px solid rgba(39,174,96,0.3); color: #27ae60; }
.alert-error { background: rgba(192,57,43,0.1); border: 1px solid rgba(192,57,43,0.3); color: #e74c3c; }
.alert-warning { background: rgba(212,160,23,0.1); border: 1px solid rgba(212,160,23,0.3); color: #d4a017; }

/* ── Login Page ─────────────────────────── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cinza-bg);
}

.login-box {
  background: var(--cinza-card);
  border: 1px solid var(--cinza-borda);
  border-radius: var(--radius);
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sombra);
}

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

/* ── Perfil ─────────────────────────────── */
.perfil-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--verde-medio);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 20px;
  border: 2px solid var(--verde-accent);
}

.perfil-section { border-top: 1px solid var(--cinza-borda); margin-top: 20px; padding-top: 20px; }
.perfil-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--texto-muted); margin-bottom: 14px; }

/* ── Auth divider ───────────────────────── */
.auth-divider {
  text-align: center; color: var(--texto-muted); font-size: 11px;
  margin: 12px 0; position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--cinza-borda);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* ── Toast ──────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--cinza-card);
  border: 1px solid var(--cinza-borda);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  min-width: 260px; max-width: 380px;
  box-shadow: var(--sombra);
  animation: slideIn 0.2s ease;
}

.toast.success { border-left: 3px solid #27ae60; }
.toast.error { border-left: 3px solid #e74c3c; }
.toast.warning { border-left: 3px solid #d4a017; }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Hamburguer mobile ──────────────────── */
.menu-toggle {
  display: none;
  background: none; border: none;
  color: var(--texto-primario);
  font-size: 22px; cursor: pointer;
}

/* ── Responsivo ─────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card { padding: 14px; }
  .stat-number { font-size: 26px; }
  .stat-label { font-size: 11px; }
  .page { padding: 12px; }
  .main-content::before { width: 260px; height: 260px; opacity: 0.03; }
}


/* ── Mobile fino (até 480px) ───────────── */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 12px 10px;
  }

  .stat-number {
    font-size: 32px;
  }

  .stat-label {
    font-size: 12px;
    color: var(--texto-secundario);
  }

  th { padding: 8px 6px; font-size: 9px; }
  td { padding: 8px 6px; font-size: 12px; }
  .mono { font-size: 11px; }

  .topbar { padding: 10px 12px; }
  .card { padding: 12px; }
  .card-title { font-size: 11px; }
  .badge { padding: 2px 6px; font-size: 9px; }

  .topbar-actions .btn-primary { display: none; }
  .main-content::before { width: 180px; height: 180px; opacity: 0.02; }
}
