/* ============================================================
   Araujo RC — Sistema DETRAN · CSS baseado no detran-sistema.html
   Mantém 100% de fidelidade visual ao original
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --azul: #1a3a5c;
  --azul2: #2a5298;
  --azul-bg: #e8f0fe;
  --ambar: #c97d0a;
  --ambar-bg: #fff8e1;
  --verde: #1a7a4a;
  --verde-bg: #e6f4ed;
  --vermelho: #c0392b;
  --verm-bg: #fdecea;
  --roxo: #6d28d9;
  --roxo-bg: #f5f3ff;
  --c1: #f8f9fa;
  --c2: #f1f3f5;
  --c3: #dee2e6;
  --c4: #adb5bd;
  --c5: #6c757d;
  --c6: #343a40;
  --txt: #1e293b;
  --sw: 230px;
  --th: 56px;
}

html, body {
  font-family: 'Inter', sans-serif;
  background: var(--c1);
  color: var(--txt);
  font-size: 14px;
  height: 100%;
}

/* ─── LAYOUT PRINCIPAL ──────────────────────────────────────── */

#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── SIDEBAR ───────────────────────────────────────────────── */

#sb {
  width: var(--sw);
  background: var(--azul);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.logo {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.logo h1 { color: #fff; font-size: 13px; font-weight: 600; }
.logo p { color: rgba(255, 255, 255, .45); font-size: 11px; margin-top: 2px; }

.ns {
  padding: 8px 18px 3px;
  color: rgba(255, 255, 255, .3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 6px;
}

.ni {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  color: rgba(255, 255, 255, .65);
  cursor: pointer;
  font-size: 12.5px;
  border-left: 3px solid transparent;
  transition: all .12s;
  text-decoration: none;
}
.ni:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.ni.on { background: rgba(255, 255, 255, .11); color: #fff; border-left-color: var(--ambar); }
.ni svg { width: 15px; height: 15px; flex-shrink: 0; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: .12s;
}
.user-pill:hover { background: rgba(255,255,255,.07); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--azul2);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── MAIN ──────────────────────────────────────────────────── */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#tb {
  background: #fff;
  border-bottom: 1px solid var(--c3);
  padding: 0 24px;
  height: var(--th);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#tb-title { font-size: 15px; font-weight: 600; }
#tb-act { display: flex; gap: 8px; }

#ct {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ─── BOTÕES ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .12s;
  line-height: 1;
  font-family: inherit;
}
.bp { background: var(--azul); color: #fff; }
.bp:hover { background: var(--azul2); }
.bs { background: #fff; color: var(--txt); border: 1px solid var(--c3); }
.bs:hover { background: var(--c2); }
.bd { background: var(--vermelho); color: #fff; }
.bd:hover { opacity: .88; }
.bv { background: var(--verde); color: #fff; }
.bv:hover { opacity: .9; }
.brx { background: var(--roxo); color: #fff; }
.brx:hover { opacity: .9; }
.bsm { padding: 4px 10px; font-size: 11.5px; }

/* ─── METRIC CARDS ──────────────────────────────────────────── */

.mc { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }

.mc-card {
  background: #fff;
  border: 1px solid var(--c3);
  border-radius: 10px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.mc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.mc-card.az::before { background: var(--azul); }
.mc-card.am::before { background: var(--ambar); }
.mc-card.vd::before { background: var(--verde); }
.mc-card.rx::before { background: var(--roxo); }

.ml { font-size: 10.5px; color: var(--c5); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.mv { font-size: 26px; font-weight: 600; line-height: 1; }
.ms { font-size: 11px; color: var(--c5); margin-top: 5px; }

/* ─── CARD / TABLE ──────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid var(--c3);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.ch {
  padding: 14px 18px;
  border-bottom: 1px solid var(--c3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ct2 { font-size: 13px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--c5);
  text-transform: uppercase;
  letter-spacing: .4px;
  background: var(--c1);
  border-bottom: 1px solid var(--c3);
}
td {
  padding: 11px 14px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--c2);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.es { padding: 36px; text-align: center; color: var(--c4); font-size: 12.5px; }

/* ─── BADGES ────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.b-pend    { background: #fff8e1; color: #92600a; }
.b-aprov   { background: var(--verde-bg); color: var(--verde); }
.b-cont    { background: var(--azul-bg); color: var(--azul2); }
.b-capt    { background: var(--roxo-bg); color: var(--roxo); }
.b-desc    { background: var(--c2); color: var(--c5); }
.b-alta    { background: var(--verm-bg); color: var(--vermelho); }
.b-media   { background: var(--ambar-bg); color: var(--ambar); }
.b-baixa   { background: var(--c2); color: var(--c5); }
.b-adv     { background: var(--azul-bg); color: var(--azul); }
.b-ass     { background: var(--verde-bg); color: var(--verde); }
.b-cor     { background: var(--ambar-bg); color: var(--ambar); }
.b-jefp    { background: var(--verde-bg); color: var(--verde); }
.b-vfp     { background: var(--azul-bg); color: var(--azul); }
.b-ativo   { background: var(--verde-bg); color: var(--verde); }
.b-enc     { background: var(--c2); color: var(--c5); }

/* ─── MODAL ─────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .42);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 600px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .18);
  display: flex;
  flex-direction: column;
}

.mh {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--c3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}
.mh h2 { font-size: 14px; font-weight: 600; }

.mx {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c5);
  padding: 3px;
  border-radius: 5px;
  display: flex;
}
.mx:hover { background: var(--c2); }

.mb { padding: 22px; flex: 1; }

.mf {
  padding: 14px 22px;
  border-top: 1px solid var(--c3);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: #fff;
}

/* ─── FORMS ─────────────────────────────────────────────────── */

.fg { margin-bottom: 16px; }
.fr { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fr3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--c6);
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--c3);
  border-radius: 7px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--txt);
  background: #fff;
  transition: border .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--azul2);
  box-shadow: 0 0 0 3px rgba(42, 82, 152, .08);
}
textarea { resize: vertical; min-height: 72px; }
.fh { font-size: 10.5px; color: var(--c5); margin-top: 3px; }

/* ─── FILTROS ───────────────────────────────────────────────── */

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.sb-wrap { position: relative; flex: 1; min-width: 180px; max-width: 300px; }
.sb-wrap svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--c4);
  pointer-events: none;
}
.sb-wrap input { padding-left: 30px; }
.filters select { min-width: 150px; width: auto; }

/* ─── TABS ──────────────────────────────────────────────────── */

.tabs { display: flex; border-bottom: 1px solid var(--c3); margin-bottom: 20px; }
.tab {
  padding: 9px 18px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c5);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .12s;
}
.tab.on { color: var(--azul); border-bottom-color: var(--azul); }
.tab:hover { color: var(--txt); }

/* ─── TABLE ACTIONS ─────────────────────────────────────────── */

.ta { display: flex; gap: 5px; }

/* ─── ALERTA ────────────────────────────────────────────────── */

.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.al-info { background: var(--azul-bg); color: var(--azul); }
.al-warn { background: var(--ambar-bg); color: var(--ambar); }
.al-err  { background: var(--verm-bg); color: var(--vermelho); }

/* ─── PETIÇÃO ───────────────────────────────────────────────── */

#pet-area {
  background: #fff;
  border: 1px solid var(--c3);
  border-radius: 10px;
  padding: 32px 40px;
  font-family: 'Times New Roman', Times, serif;
  font-size: 13px;
  line-height: 1.85;
  white-space: pre-wrap;
  min-height: 400px;
  color: #000;
}
.pet-controls { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }

/* ─── AGENDA ────────────────────────────────────────────────── */

.cal-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.cal-grid { background: #fff; border: 1px solid var(--c3); border-radius: 10px; overflow: hidden; }
.cal-header { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--azul); color: #fff; text-align: center; font-size: 11.5px; font-weight: 600; }
.cal-header div { padding: 8px 4px; }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day { min-height: 80px; border-right: 1px solid var(--c2); border-bottom: 1px solid var(--c2); padding: 4px; cursor: pointer; transition: .1s; position: relative; }
.cal-day:hover { background: var(--azul-bg); }
.cal-day.outro-mes { background: var(--c1); opacity: .55; }
.cal-day.hoje .cal-dn { background: var(--azul); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.cal-day.sel { background: var(--azul-bg); outline: 2px solid var(--azul2); }
.cal-dn { font-size: 12px; font-weight: 600; margin-bottom: 3px; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.cal-ev { font-size: 9.5px; padding: 1px 5px; border-radius: 3px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cal-ev.ag-pendente   { background: #fff3e0; color: #b45309; }
.cal-ev.ag-confirmado { background: var(--verde-bg); color: var(--verde); }
.cal-ev.ag-realizado  { background: var(--c2); color: var(--c5); }
.cal-ev.ag-cancelado  { background: var(--verm-bg); color: var(--vermelho); text-decoration: line-through; }
.cal-ev.ag-reagendado { background: var(--roxo-bg); color: var(--roxo); }

.ag-lista { background: #fff; border: 1px solid var(--c3); border-radius: 10px; overflow: hidden; }
.ag-lista-header { padding: 12px 16px; border-bottom: 1px solid var(--c3); font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.ag-item { padding: 12px 16px; border-bottom: 1px solid var(--c2); cursor: pointer; transition: .1s; }
.ag-item:last-child { border-bottom: none; }
.ag-item:hover { background: var(--c1); }
.ag-hora { font-size: 11px; font-weight: 700; color: var(--azul); margin-bottom: 3px; }
.ag-nome { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.ag-det  { font-size: 11.5px; color: var(--c5); }
.ag-nav  { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.ag-nav button { background: #fff; border: 1px solid var(--c3); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--txt); transition: .1s; }
.ag-nav button:hover { background: var(--c2); }
.ag-nav .mes-label { font-size: 16px; font-weight: 700; flex: 1; text-align: center; }

/* ─── LOGIN ─────────────────────────────────────────────────── */

.login-page {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 9999;
  display: flex;
}

.lw-inner { display: flex; height: 100vh; width: 100%; }

.lw-left {
  flex: 0 0 60%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1a2a6c 0%, #2a4298 50%, #3a5bc7 100%);
}
.lw-left-img {
  position: absolute;
  inset: 0;
  background: url('https://images.unsplash.com/photo-1589829545856-d10d557cf95f?w=1200&q=80') center/cover no-repeat;
  opacity: .35;
}
.lw-left-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
}
.lw-brand { text-align: center; }
.lw-brand h1 { color: #fff; font-size: 38px; font-weight: 800; letter-spacing: 2px; text-shadow: 0 2px 8px rgba(0,0,0,.3); }
.lw-brand p { color: #c9a84c; font-size: 14px; font-weight: 600; letter-spacing: 3px; text-transform: uppercase; margin-top: 4px; }

.lw-right { flex: 0 0 40%; display: flex; align-items: center; justify-content: center; background: #fff; padding: 40px; }
.lw-box { width: 100%; max-width: 360px; }
.lw-box h2 { font-size: 22px; font-weight: 700; color: #1a2a6c; margin-bottom: 6px; }
.lw-box .lw-sub { font-size: 13px; color: var(--c5); margin-bottom: 28px; }

.lw-field { margin-bottom: 14px; }
.lw-field label { display: block; font-size: 12px; font-weight: 500; color: #555; margin-bottom: 5px; }
.lw-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e0e4ef;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #f4f6fb;
  color: var(--txt);
  transition: border .15s;
}
.lw-field input:focus { outline: none; border-color: #1a2a6c; background: #fff; }

.lw-btn {
  width: 100%;
  padding: 13px;
  background: #1a2a6c;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
  margin-top: 6px;
  letter-spacing: .3px;
  font-family: inherit;
}
.lw-btn:hover { background: #2a3a8c; }
.lw-btn:disabled { opacity: .5; cursor: default; }

.lw-link { text-align: center; font-size: 12.5px; color: #888; margin-top: 14px; cursor: pointer; }
.lw-link span { color: #1a2a6c; font-weight: 600; cursor: pointer; }
.lw-link span:hover { text-decoration: underline; }
.lw-link-disabled { color: var(--c4) !important; font-weight: 500 !important; cursor: default !important; }
.lw-link-disabled:hover { text-decoration: none !important; }

.lw-err {
  background: #fdecea;
  color: #c0392b;
  border-radius: 6px;
  padding: 9px 13px;
  font-size: 12.5px;
  margin-bottom: 14px;
  border-left: 3px solid #c0392b;
}
.lw-ok {
  background: #e6f4ed;
  color: #1a7a4a;
  border-radius: 6px;
  padding: 9px 13px;
  font-size: 12.5px;
  margin-bottom: 14px;
  border-left: 3px solid #1a7a4a;
}

.code-boxes { display: flex; gap: 8px; justify-content: center; margin: 18px 0 6px; }
.code-box {
  width: 46px;
  height: 54px;
  border: 2px solid #e0e4ef;
  border-radius: 8px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: #1a2a6c;
  background: #f4f6fb;
  transition: .15s;
  font-family: inherit;
}
.code-box:focus { outline: none; border-color: #1a2a6c; background: #fff; }
.lw-timer { text-align: center; font-size: 12px; color: #888; margin-top: 4px; }

@media (max-width: 768px) {
  .lw-left { display: none; }
  .lw-right { flex: 1; padding: 24px; }
  .mc { grid-template-columns: repeat(2, 1fr); }
  .cal-wrap { grid-template-columns: 1fr; }
}

/* ─── TOGGLE MÓDULOS (usuários) ─────────────────────────────── */

.modulos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.mod-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--c1);
  border: 1px solid var(--c3);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}

.mod-toggle:hover {
  border-color: var(--c4);
  background: #fff;
}

.mod-toggle.on {
  background: var(--azul-bg);
  border-color: #b8cce8;
}

.mod-toggle-text {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--txt);
}

.mod-toggle.on .mod-toggle-text {
  color: var(--azul);
  font-weight: 600;
}

.mod-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.mod-toggle-switch {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  background: var(--c3);
  border-radius: 11px;
  transition: background .2s;
}

.mod-toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .2s;
}

.mod-toggle-input:checked + .mod-toggle-switch {
  background: var(--azul2);
}

.mod-toggle-input:checked + .mod-toggle-switch::after {
  transform: translateX(18px);
}

.mod-toggle-input:focus-visible + .mod-toggle-switch {
  outline: 2px solid var(--azul2);
  outline-offset: 2px;
}

.modulos-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--c5);
}

.modulos-toolbar button {
  background: none;
  border: none;
  color: var(--azul2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.modulos-toolbar button:hover {
  text-decoration: underline;
}

/* ─── SPIN ANIMATION ────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }
.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--c3);
  border-top-color: var(--azul2);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ─── LOADING OVERLAY ───────────────────────────────────────── */

.loading-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  color: var(--c5);
  font-size: 13px;
}
