:root {
  /* Paleta alinhada ao site institucional (capyone.com.br): capybara (laranja/terracota),
     earth (marrons neutros) e moss (verde). */
  --navy: #3a2718;
  --navy-2: #593b2c;
  --accent: #d4822f;
  --accent-2: #c06a24;
  --accent-soft: #fdf8f0;
  --bg: #faf6f1;
  --text: #593b2c;
  --dot-ok: #537238;
  --dot-alert: #ef4444;
  --dot-info: #3b82f6;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(89, 59, 44, .08);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.app-shell {
  min-height: 100vh;
}

/* Páginas de autenticação (login, recuperação de senha) */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--navy) 0%, #23160d 100%);
}

.auth-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 1.3rem;
}

/* Sidebar */
.sidebar {
  background: linear-gradient(190deg, var(--navy) 0%, #23160d 100%);
  width: 250px;
  max-width: 82vw;
  flex-shrink: 0;
  color: #d7c3b3;
}

/* Mobile: menu vira off-canvas (escondido fora da tela até abrir pelo hambúrguer) */
@media (max-width: 767.98px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 32px rgba(0, 0, 0, .3);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 12, 6, .45);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 768px) {
  .sidebar {
    min-height: 100vh;
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .sidebar-backdrop {
    display: none;
  }
}

.sidebar-toggle {
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  padding: .25rem .5rem;
  border: 0;
  background: transparent;
}

.sidebar-toggle:hover,
.sidebar-toggle:active {
  color: var(--accent);
}

.sidebar-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .2px;
}

.sidebar-brand i {
  color: var(--accent-2);
}

.sidebar .nav-link {
  color: #d7c3b3;
  border-radius: 10px;
  font-size: .92rem;
  padding: .55rem .75rem;
  transition: background .15s ease, color .15s ease;
}

.sidebar .nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(212, 130, 47, .35);
}

.sidebar .nav-link:not(.active):hover {
  color: #fff;
  background: rgba(255, 255, 255, .06);
}

.sidebar-divider {
  border-color: rgba(255, 255, 255, .08);
  margin: .5rem 0;
}

.sidebar .logout-link {
  color: #ff9c94;
}

.sidebar .logout-link:hover {
  color: #fff;
  background: var(--dot-alert);
}

/* Top navbar */
.navbar-top {
  background: #fff;
  border-bottom: 1px solid #f0e8db;
  box-shadow: 0 1px 0 rgba(89, 59, 44, .02);
}

.navbar-top .page-title {
  color: var(--text);
  font-weight: 600;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}

/* Cards */
.card {
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card h6.mb-3 {
  font-weight: 700;
  color: var(--navy-2);
  padding-bottom: .6rem;
  margin-bottom: 1rem !important;
  border-bottom: 1px solid #f0e8db;
}

/* Variante do cabeçalho do card quando ele leva algo além do título (ex.: a caixa de
   "Mostrar N" dos eventos recentes) — mesmo visual do h6.mb-3 acima, só que na linha toda. */
.card-heading-row {
  padding-bottom: .6rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #f0e8db;
}

.card-heading-row h6 {
  font-weight: 700;
  color: var(--navy-2);
}

.btn-brand {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 0;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 4px 14px rgba(212, 130, 47, .3);
}

.btn-brand:hover {
  filter: brightness(1.08);
  color: #fff;
}

.btn-outline-secondary {
  border-color: #e0d4ba;
  color: var(--text);
}

.btn-outline-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Tables */
.table thead th {
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .04em;
  color: #bc9363;
  border-bottom-width: 1px;
  font-weight: 600;
}

.table > tbody > tr:hover {
  background: var(--accent-soft);
}

.badge.bg-success {
  background: #e5eddb !important;
  color: #41592e;
  font-weight: 600;
}

.badge.bg-secondary {
  background: #f0e8db !important;
  color: #825337;
  font-weight: 600;
}

/* Status dots */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.dot-ok { background: var(--dot-ok); }
.status-dot.dot-alert { background: var(--dot-alert); }
.status-dot.dot-info { background: var(--dot-info); }

/* Dashboard */
.evento-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--accent-soft);
}

.evento-thumb-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #cab28a;
  font-size: 1.3rem;
}

.stat-card {
  padding: 1.15rem 1.25rem 1.15rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(89, 59, 44, .12);
}

.stat-card .valor {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  transition: color .2s ease;
}

.stat-card small.text-muted {
  text-transform: uppercase;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .05em;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--accent-soft);
  color: var(--accent-2);
  margin-bottom: .65rem;
}

/* Faixa de destaque no topo do dashboard do admin */
.dash-hero {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  border-radius: var(--radius);
  color: #fdf8f0;
  padding: 1.5rem 1.75rem;
  position: relative;
  overflow: hidden;
}

.dash-hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 130, 47, .35), transparent 70%);
}

.dash-hero h4 {
  color: #fff;
  margin-bottom: .15rem;
}

.dash-hero p {
  color: #e7d9c9;
  margin-bottom: 0;
}

.stat-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

/* Indicador "ao vivo" no topo do dashboard */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #52713a;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-ok);
  box-shadow: 0 0 0 0 rgba(83, 114, 56, .55);
  animation: live-pulse 1.8s ease-in-out infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(83, 114, 56, .5); }
  70% { box-shadow: 0 0 0 7px rgba(83, 114, 56, 0); }
  100% { box-shadow: 0 0 0 0 rgba(83, 114, 56, 0); }
}

.destaque-foto {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 12px;
}

.evento-item {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .65rem .75rem;
  margin: 0 0 .5rem;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid #f0e8db;
  transition: background .15s ease, border-color .3s ease, transform .15s ease, box-shadow .3s ease, opacity .4s ease;
}

/* Sem isso, o filho flex-grow-1 não encolhe abaixo da largura natural do conteúdo (mínimo
   padrão do flexbox é "auto", não 0) — com placa + modelo + vários badges na mesma linha, o
   card overflowa/corta em vez de quebrar a linha. */
.evento-item > .flex-grow-1 {
  min-width: 0;
}

.evento-item:last-child {
  margin-bottom: 0;
}

.evento-item:hover {
  background: var(--accent-soft);
  border-color: #e8bc7d;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(89, 59, 44, .1);
}

small[title] {
  cursor: help;
  border-bottom: 1px dotted #cab28a;
}

.ultima-captura-wrap {
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: border-color .3s ease, box-shadow .3s ease, opacity .4s ease;
  cursor: pointer;
}

/* Realce de evento novo chegando via atualização automática do dashboard.
   Cards pequenos (lista) recebem um leve "pop"; a foto grande (última captura)
   só recebe um fade suave, pra não parecer um salto brusco numa imagem grande. */
@keyframes evento-piscar {
  0% { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(212, 130, 47, .35); opacity: 0; transform: translateY(-3px); }
  30% { opacity: 1; transform: translateY(0); }
  100% { border-color: #f0e8db; box-shadow: none; }
}

@keyframes captura-realce {
  0% { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(212, 130, 47, .3); opacity: 0; }
  40% { opacity: 1; }
  100% { border-color: #f0e8db; box-shadow: none; opacity: 1; }
}

.evento-item.evento-novo {
  animation: evento-piscar 1.3s ease-out;
}

.ultima-captura-wrap.evento-novo {
  animation: captura-realce 1.3s ease-in-out;
}

/* Piscar mais chamativo quando dá match com a placa de um veículo cadastrado
   (evento tipo "alerta") — mais forte e repetido que o realce de "evento novo" acima. */
@keyframes placa-match-piscar {
  0%, 100% { border-color: #f0e8db; box-shadow: none; }
  25%, 75% { border-color: var(--dot-alert); box-shadow: 0 0 0 5px rgba(239, 68, 68, .45); }
  50% { border-color: #f0e8db; box-shadow: none; }
}

.evento-item.placa-match-piscar,
.ultima-captura-wrap.placa-match-piscar {
  /* infinito de propósito: o alerta deve continuar chamando atenção até alguém abrir
     o evento (o que remove a classe via JS) — ver piscarCardsDoEvento/abrirEventoModal */
  animation: placa-match-piscar 1.1s ease-in-out infinite;
}

.border-alerta .modal-header {
  border-bottom-color: rgba(239, 68, 68, .25);
}

/* Botão de zoom sobreposto na foto do evento (modal de detalhe e de match de placa) */
.foto-zoom-wrap {
  position: relative;
}

.foto-zoom-btn {
  position: absolute;
  bottom: .6rem;
  right: .6rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(20, 12, 6, .55);
  color: #fff;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}

.foto-zoom-btn:hover {
  background: rgba(20, 12, 6, .8);
  transform: scale(1.06);
}

/* Lightbox: foto do evento em tamanho grande, sobre fundo escuro do próprio modal */
#fotoZoomModal.modal {
  padding: 0 !important;
}

#fotoZoomModal .modal-dialog {
  max-width: 99vw;
  width: 99vw;
  height: 99vh;
  margin: .5vh auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fotoZoomModal .modal-content {
  width: auto;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  /* recorta a imagem ampliada (transform: scale no hover) nos limites da própria foto,
     em vez de deixá-la vazar por cima do resto da tela */
  overflow: hidden;
  border-radius: 12px;
}

.foto-zoom-imagem {
  display: block;
  width: auto;
  height: auto;
  max-width: 99vw;
  max-height: 99vh;
  object-fit: contain;
  margin: 0 auto;
  cursor: zoom-in;
  transform: scale(1);
  transition: transform .15s ease-out;
}

/* Enquanto o mouse está sobre a foto: acompanha o cursor (transform-origin setado via JS
   a cada mousemove) e amplia — solta ao tirar o mouse de cima. */
.foto-zoom-imagem.foto-zoom-ativo {
  cursor: zoom-out;
  transform: scale(2.5);
  transition: transform .1s ease-out;
}

/* Botão fixo na viewport (não dentro do modal-content, que agora tem overflow:hidden e
   ocupa quase a tela inteira) — sempre visível, independente do tamanho da foto. */
.foto-zoom-fechar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1060;
}

/* Foto do veículo — cadastro */
.foto-widget {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.foto-preview-box {
  width: 110px;
  height: 110px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px dashed #e8bc7d;
}

.foto-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.foto-placeholder-icon {
  font-size: 2.2rem;
  color: #cab28a;
}

.webcam-video {
  width: 100%;
  max-width: 320px;
  border-radius: 10px;
  background: #000;
}

.veiculo-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  display: inline-flex;
}

.veiculo-thumb-placeholder {
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: #cab28a;
  font-size: 1.1rem;
}

.autocomplete-wrap {
  position: relative;
}

.autocomplete-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(89, 59, 44, .15);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.autocomplete-item {
  padding: 7px 10px;
  border-radius: 6px;
  font-size: .9rem;
  cursor: pointer;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-soft);
  color: var(--accent-2);
}

[data-bs-toggle="collapse"] .bi-chevron-down {
  transition: transform .2s ease;
}

[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down {
  transform: rotate(180deg);
}
