/* ============================================================
   SISTEMA ATENDIMENTOS SPM — CSS Principal
   Design inspirado no original (Tailwind → CSS puro)
   ============================================================ */

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

:root {
  --purple-900: #4c1d95;
  --purple-800: #5b21b6;
  --blue-500:   #3b82f6;
  --blue-600:   #2563eb;
  --blue-900:   #1e3a8a;
  --blue-950:   #172554;
  --blue-100:   #dbeafe;
  --blue-50:    #eff6ff;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-500:   #6b7280;
  --gray-700:   #374151;
  --gray-950:   #030712;
  --white:      #ffffff;
  --red-500:    #ef4444;
  --red-600:    #dc2626;
  --green-500:  #22c55e;
  --green-600:  #16a34a;
  --yellow-500: #eab308;
  --yellow-600: #ca8a04;
  --cyan-500:   #06b6d4;
  --cyan-600:   #0891b2;
  --sidebar-w:  256px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--gray-950);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ── NAVBAR ─────────────────────────────────────────────── */
.nav-dashboard {
  background: var(--purple-900);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 52px;
}

.botao-sidebar {
  background: none; border: none;
  color: #f9fafb; font-size: 20px; cursor: pointer;
  display: none;
}

.botao-dropdown {
  background: var(--purple-900);
  border: none; color: #f9fafb;
  padding: 6px 12px;
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  border-radius: 4px;
}
.botao-dropdown:hover { background: #6d28d9; }

#dropdownConteudo {
  position: absolute; top: 44px; right: 0;
  background: white; border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  min-width: 160px; z-index: 200;
  display: none;
}
#dropdownConteudo.open { display: block; }

.title-dashboard {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--gray-700);
  transition: background .15s;
}
.title-dashboard:hover { background: var(--gray-100); }
.title-dashboard button {
  background: none; border: none;
  color: var(--blue-500); text-decoration: underline;
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; gap: 4px;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 52px; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--blue-950);
  transform: translateX(0);
  transition: transform .2s ease;
  z-index: 90;
  overflow-y: auto;
}

#sidebar .sidebar-brand {
  padding: 14px 16px;
  border-bottom: 2px solid #1e3a8a;
}
#sidebar .sidebar-brand h2 {
  color: #60a5fa; font-size: 17px; font-weight: 700; letter-spacing: .5px;
}

.title-sidebar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  color: #f9fafb;
  font-size: 14px;
  transition: background .15s;
}
.title-sidebar:hover, .title-sidebar.active { background: var(--purple-900); }
.title-sidebar svg { flex-shrink: 0; width: 20px; height: 20px; }

#closeSidebar {
  display: none;
  background: none; border: none;
  color: #f9fafb; font-size: 22px; cursor: pointer;
  position: absolute; top: 12px; right: 14px;
}

/* ── MAIN CONTENT ────────────────────────────────────────── */
.main-conteudo {
  margin-left: var(--sidebar-w);
  margin-top: 52px;
  padding: 16px;
  min-height: calc(100vh - 52px);
}

.conteudo-box {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0,0,0,.1);
  padding: 20px;
  color: var(--gray-950);
}

.conteudo-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--gray-100);
  padding-bottom: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.conteudo-box-titulo {
  font-size: 18px;
  font-weight: 600;
  color: var(--blue-900);
}

.conteudo-box-btn {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── GRÁFICOS ─────────────────────────────────────────────── */
.graficos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.grafico-box {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.grafico-box h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

/* Cards do dashboard */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.dash-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.dash-card-num {
  font-size: 36px;
  font-weight: 700;
  color: var(--blue-600);
}
.dash-card-label {
  font-size: 13px;
  color: var(--gray-500);
  text-align: center;
}

/* ── FORMULÁRIOS ─────────────────────────────────────────── */
.form-group { margin-top: 16px; }

.form-group-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.form-group-checkbox input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.form-input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 2px solid var(--blue-100);
  border-radius: 6px;
  font-size: 14px;
  color: var(--gray-950);
  background: white;
  transition: border .15s;
  outline: none;
}
.form-input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(147,197,253,.3); }
select.form-input { cursor: pointer; }

.form-check-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  margin-top: 6px;
}
.form-check-input { width: 16px; height: 16px; cursor: pointer; }
.form-check-label { font-size: 14px; }

.form-search {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.form-search-input {
  padding: 8px 12px;
  border: 2px solid var(--blue-100);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  width: 100%;
}
.form-search-buttons { display: flex; gap: 8px; align-items: center; }

/* ── BOTÕES ──────────────────────────────────────────────── */
.btn-primary, .btn-primary-md, .btn-info, .btn-success,
.btn-warning, .btn-danger, .btn-secondary, .btn-login {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 600; border: none; cursor: pointer;
  border-radius: 5px; transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn-primary    { background: var(--blue-500);   color: white; padding: 4px 12px; font-size: 13px; }
.btn-primary:hover { background: var(--blue-600); }
.btn-primary-md { background: var(--blue-500);   color: white; padding: 8px 16px; font-size: 14px; margin-top: 16px; }
.btn-primary-md:hover { background: var(--blue-600); }
.btn-info    { background: var(--cyan-500);   color: white; padding: 4px 12px; font-size: 13px; }
.btn-info:hover { background: var(--cyan-600); }
.btn-success { background: var(--green-500);  color: white; padding: 4px 12px; font-size: 13px; }
.btn-success:hover { background: var(--green-600); }
.btn-warning { background: var(--yellow-500); color: white; padding: 4px 12px; font-size: 13px; }
.btn-warning:hover { background: var(--yellow-600); }
.btn-danger  { background: var(--red-500);    color: white; padding: 4px 12px; font-size: 13px; }
.btn-danger:hover { background: var(--red-600); }
.btn-secondary { background: var(--gray-500); color: white; padding: 4px 12px; font-size: 13px; }
.btn-secondary:hover { background: #4b5563; }
.btn-login {
  width: 100%; background: var(--blue-500); color: white;
  padding: 10px; font-size: 15px; border-radius: 6px;
  margin-top: 20px; margin-bottom: 12px; justify-content: center;
}
.btn-login:hover { background: var(--blue-600); }

/* ── TABELAS ─────────────────────────────────────────────── */
.table-container { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table-row-header { background: var(--gray-50); }
.table-header {
  padding: 10px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.table-body {
  padding: 8px 16px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-950);
}
.table-row-body:hover { background: var(--gray-100); }
.table-actions {
  padding: 6px 12px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

/* ── ALERTAS ─────────────────────────────────────────────── */
.alert-error, .alert-success, .alert-warning {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 6px;
  font-size: 14px; font-weight: 500;
  margin-bottom: 12px;
}
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.alert-error svg, .alert-success svg, .alert-warning svg { flex-shrink: 0; width: 18px; height: 18px; }

/* ── LOGIN ───────────────────────────────────────────────── */
.bg-login {
  background: linear-gradient(135deg, #3b0764 0%, #4c1d95 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.card-login {
  background: white;
  border-radius: 10px;
  padding: 32px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.title-login {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue-500);
  text-align: center;
  margin: 16px 0;
}
.link-login { font-size: 13px; color: var(--blue-500); }
.link-login:hover { text-decoration: underline; }

/* ── PAGINAÇÃO ───────────────────────────────────────────── */
.paginacao {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
}
.pag-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px;
  padding: 0 8px;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  font-size: 13px;
  color: var(--gray-700);
  background: white;
  transition: all .15s;
}
.pag-link:hover { background: var(--blue-500); color: white; border-color: var(--blue-500); }
.pag-link.pag-active { background: var(--blue-500); color: white; border-color: var(--blue-500); font-weight: 700; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge-sim {
  background: #dcfce7; color: #166534;
  padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.badge-nao {
  background: #fee2e2; color: #991b1b;
  padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600;
}

/* ── SHOW / DETALHE ──────────────────────────────────────── */
.show-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.show-field { margin-bottom: 10px; }
.show-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.show-value {
  font-size: 14px;
  color: var(--gray-950);
  margin-top: 2px;
}
.show-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue-900);
  border-bottom: 2px solid var(--blue-100);
  padding-bottom: 6px;
  margin: 20px 0 12px;
}

/* ── PARENTES (formulário dinâmico) ──────────────────────── */
.parente-box {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  position: relative;
}
.parente-box .btn-remove-parente {
  position: absolute; top: 12px; right: 12px;
  background: var(--red-500); color: white;
  border: none; border-radius: 4px;
  padding: 2px 8px; font-size: 12px; cursor: pointer;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  .main-conteudo {
    margin-left: 0;
  }
  .botao-sidebar { display: block; }
  #closeSidebar { display: block; }

  .hidden-mobile { display: none !important; }
}

/* ── IMPRESSÃO / PDF ─────────────────────────────────────── */
@media print {
  #sidebar, .nav-dashboard, .conteudo-box-btn,
  .btn-primary, .btn-danger, .btn-warning, .btn-success,
  .btn-info, .btn-secondary, .no-print { display: none !important; }
  .main-conteudo { margin: 0; padding: 10px; }
  body { background: white; }
}
