/* ============================================================
   TEA Identifica - Estilo Principal
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --azul:      #1e3a5f;
  --azul-med:  #2563a8;
  --azul-claro:#dbeafe;
  --verde:     #059669;
  --verde-cl:  #d1fae5;
  --laranja:   #d97706;
  --laranja-cl:#fef3c7;
  --vermelho:  #dc2626;
  --verm-cl:   #fee2e2;
  --roxo:      #7c3aed;
  --cinza:     #64748b;
  --cinza-cl:  #f1f5f9;
  --branco:    #ffffff;
  --borda:     #e2e8f0;
  --sombra:    0 2px 12px rgba(30,58,95,.12);
  --radius:    12px;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  min-height: 100vh;
}

/* NAVBAR */
.navbar {
  background: var(--azul);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 800;
}
.navbar-brand .logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg,#60a5fa,#3b82f6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.navbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar-nav a {
  color: #94a3b8;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  transition: all .2s;
}
.navbar-nav a:hover, .navbar-nav a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.navbar-nav .btn-sair {
  background: rgba(220,38,38,.15);
  color: #fca5a5;
  border: 1px solid rgba(220,38,38,.3);
}
.navbar-nav .btn-sair:hover { background: rgba(220,38,38,.3); }

/* SIDEBAR (admin/user) */
.layout {
  display: flex;
  min-height: calc(100vh - 64px);
}
.sidebar {
  width: 240px;
  background: var(--branco);
  border-right: 1px solid var(--borda);
  padding: 20px 12px;
  flex-shrink: 0;
}
.sidebar-title {
  font-size: .7rem;
  font-weight: 800;
  color: var(--cinza);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 12px 4px;
  margin-top: 8px;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #475569;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  transition: all .2s;
  margin-bottom: 2px;
}
.sidebar a:hover, .sidebar a.active {
  background: var(--azul-claro);
  color: var(--azul-med);
}
.sidebar a .ico { font-size: 1.1rem; width: 22px; text-align: center; }

/* MAIN CONTENT */
.main-content {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--azul);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* CARDS */
.card {
  background: var(--branco);
  border-radius: var(--radius);
  box-shadow: var(--sombra);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--borda);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--borda);
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--azul);
}

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(180px,1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--branco);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--borda);
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-num  { font-size: 1.8rem; font-weight: 900; color: var(--azul); line-height: 1; }
.stat-label{ font-size: .8rem; color: var(--cinza); font-weight: 600; margin-top: 2px; }

/* TABELA */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--cinza-cl);
  color: var(--cinza);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 14px;
  text-align: left;
}
tbody tr { border-bottom: 1px solid var(--borda); transition: background .15s; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 12px 14px; color: #334155; vertical-align: middle; }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  gap: 4px;
}
.badge-verde  { background: var(--verde-cl);   color: var(--verde);   }
.badge-azul   { background: var(--azul-claro); color: var(--azul-med);}
.badge-laranja{ background: var(--laranja-cl); color: var(--laranja); }
.badge-verm   { background: var(--verm-cl);    color: var(--vermelho);}
.badge-cinza  { background: var(--cinza-cl);   color: var(--cinza);   }
.badge-roxo   { background: #ede9fe;           color: var(--roxo);    }

/* FORMULÁRIOS */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}
.form-label span.req { color: var(--vermelho); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-family: inherit;
  font-size: .9rem;
  color: #1e293b;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--azul-med);
  box-shadow: 0 0 0 3px rgba(37,99,168,.12);
}
.form-control.is-invalid { border-color: var(--vermelho); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* BOTÕES */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .2s;
}
.btn-primary  { background: var(--azul-med); color: #fff; }
.btn-primary:hover  { background: var(--azul); }
.btn-success  { background: var(--verde);    color: #fff; }
.btn-success:hover  { background: #047857; }
.btn-danger   { background: var(--vermelho); color: #fff; }
.btn-danger:hover   { background: #b91c1c; }
.btn-warning  { background: var(--laranja);  color: #fff; }
.btn-warning:hover  { background: #b45309; }
.btn-light    { background: var(--cinza-cl); color: #475569; border: 1px solid var(--borda); }
.btn-light:hover    { background: #e2e8f0; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity:.6; cursor:not-allowed; }

/* ALERTAS */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 16px;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-danger  { background: var(--verm-cl);    border-color: var(--vermelho); color: #991b1b; }
.alert-success { background: var(--verde-cl);   border-color: var(--verde);   color: #065f46; }
.alert-warning { background: var(--laranja-cl); border-color: var(--laranja); color: #92400e; }
.alert-info    { background: var(--azul-claro); border-color: var(--azul-med);color: var(--azul); }

/* ALERTA ATIVO - destaque vermelho pulsante */
.alerta-banner {
  background: linear-gradient(135deg,#dc2626,#991b1b);
  color: #fff;
  padding: 14px 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  animation: pulse-red 2s infinite;
}
@keyframes pulse-red {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50%      { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
}

/* LOGIN PAGE */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg,#1e3a5f 0%,#2563a8 50%,#1e40af 100%);
  padding: 20px;
}
.login-box {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .circle {
  width: 72px; height: 72px;
  background: linear-gradient(135deg,var(--azul),var(--azul-med));
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 10px;
}
.login-logo h1 { font-size: 1.4rem; font-weight: 900; color: var(--azul); }
.login-logo p  { font-size: .85rem; color: var(--cinza); }

/* TELA PÚBLICA (CRACHÁ) */
.cracha-page {
  min-height: 100vh;
  background: linear-gradient(160deg,#eff6ff 0%,#dbeafe 100%);
  padding: 20px;
  display: flex;
  justify-content: center;
}
.cracha-container {
  width: 100%;
  max-width: 500px;
  padding-top: 20px;
}
.cracha-header {
  background: var(--azul);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  color: #fff;
  text-align: center;
}
.cracha-body {
  background: #fff;
  border-radius: 0 0 16px 16px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(30,58,95,.15);
}
.cracha-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--azul-claro);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 10px;
  border: 3px solid var(--azul-med);
}
.info-row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--borda);
  align-items: flex-start;
}
.info-row:last-child { border-bottom: none; }
.info-label { font-size: .78rem; font-weight: 700; color: var(--cinza); min-width: 110px; }
.info-value { font-size: .9rem; font-weight: 600; color: #1e293b; }
.emergencia-box {
  background: #fff7ed;
  border: 2px solid #fed7aa;
  border-radius: 10px;
  padding: 14px;
  margin: 16px 0;
}
.emergencia-box h4 { color: var(--laranja); font-size: .9rem; margin-bottom: 6px; }
.emergencia-box p  { font-size: .88rem; line-height: 1.5; }

/* MODAL */
.modal-overlay {
  isolation: isolate;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--azul);
  margin-bottom: 16px;
}

/* DIAGNÓSTICO CHIPS */
.diag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.diag-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
}
.chip-tea1   { background: #dcfce7; color: #15803d; }
.chip-tea2   { background: #fef9c3; color: #a16207; }
.chip-tea3   { background: #fee2e2; color: #b91c1c; }
.chip-tdah   { background: #ede9fe; color: #6d28d9; }
.chip-toc    { background: #cffafe; color: #0e7490; }
.chip-outro  { background: #f1f5f9; color: #475569; }

/* MAPA */
#mapa { width: 100%; height: 220px; border-radius: 10px; border: 1px solid var(--borda); }

/* RESPONSIVO */
@media(max-width:768px){
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* CHECKBOX CUSTOMIZADO */
.check-group { display: flex; flex-wrap: wrap; gap: 10px; }
.check-item  {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: .88rem; font-weight: 600;
}
.check-item input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--azul-med); }

/* FOTO UPLOAD */
.foto-upload-area {
  border: 2px dashed var(--borda);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s;
}
.foto-upload-area:hover { border-color: var(--azul-med); }

/* APROVAÇÃO PENDENTE */
.pendente-badge {
  background: linear-gradient(135deg,#fef3c7,#fde68a);
  color: #92400e;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 700;
  border: 1px solid #fcd34d;
}

/* TOGGLE SWITCH */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative; display: inline-block;
  width: 46px; height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer;
  inset: 0; background: #cbd5e1;
  border-radius: 24px; transition: .3s;
}
.toggle-slider:before {
  position: absolute; content: "";
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: .3s;
}
.toggle input:checked + .toggle-slider { background: var(--vermelho); }
.toggle input:checked + .toggle-slider:before { transform: translateX(22px); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
