/* ============================================================
   ACCESO VIAL — Estilos principales
   v2.0 — Bootstrap 5 compatible
   ============================================================ */

/* ----
   Con Bootstrap 5 activo, box-sizing y resets básicos ya
   los aplica Bootstrap Reboot. Sólo añadimos lo específico.
   ---- */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: #f4f6f8;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; margin: 0; }
button, select, input { font-family: inherit; font-size: inherit; }

/* ============================================================
   Banners
   ============================================================ */
.banner { width: 100%; overflow: hidden; }
.banner img { width: 100%; display: block; }

/* ============================================================
   Header compartido
   ============================================================ */
.site-header {
  background: var(--color-primario);
  color: var(--color-texto-header);
  padding: 0;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 54px;
}

.header-marca {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-escudo {
  height: 34px;
  width: auto;
  object-fit: contain;
}

.header-nombre {
  font-size: 15px;
  font-weight: 500;
  opacity: 0.95;
  white-space: nowrap;
}

.header-sep { opacity: 0.35; margin: 0 3px; }

.header-app {
  display: flex;
  align-items: center;
  gap: 7px;
  opacity: 0.85;
}
.app-logo { flex-shrink: 0; }
.app-nombre { font-size: 14px; font-weight: 500; letter-spacing: .2px; }

/* Nav buttons (usados en todas las páginas admin) */
.btn-logout,
.av-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 6px;
  color: var(--color-texto-header);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-logout:hover,
.av-nav-btn:hover {
  background: rgba(255,255,255,.15);
  color: var(--color-texto-header);
}

.header-usuario {
  font-size: 13px;
  color: var(--color-texto-header);
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.rol-badge {
  background: rgba(255,255,255,.22);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
}

/* Nav container responsive */
.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ============================================================
   Layout principal (index.php — mapa público)
   ============================================================ */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  align-items: stretch;
  height: calc(100vh - 54px - 44px);
}

/* ============================================================
   Panel lateral (index.php)
   ============================================================ */
.panel-lateral {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #dde2e8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #eef0f3;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.panel-titulo  { font-size: 14px; font-weight: 600; color: #1a1a1a; }
.panel-contador { font-size: 12px; color: #6b7280; }

.filtros {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid #eef0f3;
}

.filtro-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.filtro-select:focus { outline: 2px solid var(--color-secundario); outline-offset: 1px; }

.panel-reportar {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid #eef0f3;
  background: #f8fafc;
}

.btn-reportar {
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: 10px;
  color: #fff;
  background: var(--color-primario);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: filter .15s;
}
.btn-reportar:hover { filter: brightness(1.08); }

.reportar-texto { color: #475569; font-size: 13px; line-height: 1.4; }

/* ============================================================
   Modal overlay (sistema custom — index.php, panel.php)
   No usa Bootstrap modal; override de Bootstrap .modal
   ============================================================ */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(15,23,42,.45) !important;
  /* display se controla por JS — NO añadir display aquí */
  align-items: center;
  justify-content: center;
  padding: 1rem !important;
  overflow-y: auto !important;
  z-index: 300 !important;
}
.modal-overlay.report-mode { pointer-events: none; }
.modal-overlay.report-mode .modal { pointer-events: auto; }

/* Override Bootstrap .modal para el sistema custom */
body .modal {
  width: min(560px, 100%) !important;
  max-height: calc(100vh - 2rem) !important;
  overflow-y: auto !important;
  background: #ffffff !important;
  border-radius: 18px !important;
  box-shadow: 0 24px 60px rgba(15,23,42,.18) !important;
  padding: 1.5rem !important;
  position: static !important;
  display: block !important;
  border: none !important;
  opacity: 1 !important;
}

body .modal-sm { max-width: 560px !important; }

body .modal-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 14px !important;
  margin-bottom: 1rem !important;
  padding: 0 !important;
  border-bottom: none !important;
}

body .modal-titulo {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: #111827 !important;
}

.modal-cerrar {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #6b7280;
}

/* ============================================================
   Formularios (index.php)
   ============================================================ */
.form-fila { margin-bottom: 1rem; }

.form-fila-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.form-campo {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.form-campo label {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

.form-campo input,
.form-campo select,
.form-campo textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  color: #111827;
  background: #fff;
}
.form-campo textarea { resize: vertical; }
.form-campo small { color: #6b7280; font-size: 12px; }

.ubicacion-info {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  color: #475569;
  font-size: 13px;
  min-height: 56px;
}

.btn-seleccionar-ubicacion,
.btn-cancelar,
.btn-guardar {
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn-seleccionar-ubicacion { padding: 10px 14px; background: #eff6ff; color: #1d4ed8; }
.btn-cancelar { padding: 11px 14px; background: #f1f5f9; color: #334155; }
.btn-guardar  { padding: 11px 14px; background: var(--color-primario); color: #fff; }
.btn-guardar:hover { filter: brightness(1.08); }

.captcha-row { display: flex; gap: .5rem; align-items: center; }
.btn-captcha-refrescar {
  padding: 0 12px;
  min-height: 44px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #f8fafc;
  color: #1d4ed8;
  cursor: pointer;
}
.btn-captcha-refrescar:hover { background: #eff6ff; }

.form-acciones { display: flex; justify-content: flex-end; gap: 10px; }
.form-acciones-vertical { flex-direction: column; }

/* ============================================================
   Lista de incidencias (index.php)
   ============================================================ */
.lista-incidencias {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.lista-placeholder { color: #9ca3af; font-size: 13px; text-align: center; padding: 2rem 0; }

.incidencia-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.incidencia-item:hover   { border-color: var(--color-secundario); background: #f0f7ff; }
.incidencia-item.activo  { border-color: var(--color-primario);   background: #eaf2fb; }

.inc-cabecera { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.inc-dot      { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.inc-titulo   { font-size: 13px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inc-fecha    { font-size: 11px; color: #9ca3af; white-space: nowrap; }
.inc-descripcion {
  font-size: 12px; color: #6b7280; line-height: 1.4; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.inc-badges { display: flex; gap: 4px; flex-wrap: wrap; }

/* Badges de estado/gravedad (alta especificidad para no chocar con Bootstrap) */
.inc-badges .badge,
.badge-gravedad-baja,
.badge-gravedad-media,
.badge-gravedad-alta,
.badge-gravedad-critica,
.badge-estado-programada,
.badge-estado-activa,
.badge-estado-resuelta,
.badge-estado-cancelada {
  font-size: 10px !important;
  padding: 2px 7px !important;
  border-radius: 10px !important;
  font-weight: 500 !important;
  display: inline-block !important;
}
.badge-gravedad-baja     { background: #ecfdf5; color: #065f46; }
.badge-gravedad-media    { background: #fffbeb; color: #92400e; }
.badge-gravedad-alta     { background: #fff7ed; color: #9a3412; }
.badge-gravedad-critica  { background: #fef2f2; color: #991b1b; }
.badge-estado-programada { background: #eff6ff; color: #1e40af; }
.badge-estado-activa     { background: #fef2f2; color: #991b1b; }
.badge-estado-resuelta   { background: #f9fafb; color: #6b7280; }
.badge-estado-cancelada  { background: #f9fafb; color: #9ca3af; }

/* ============================================================
   Leyenda
   ============================================================ */
.leyenda {
  padding: 12px 16px;
  border-top: 1px solid #eef0f3;
  flex-shrink: 0;
}
.leyenda-titulo { font-size: 11px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.leyenda-item   { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #4b5563; margin-bottom: 4px; }
.leyenda-dot    { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ============================================================
   Mapa
   ============================================================ */
.mapa-wrapper {
  flex: 1;
  position: relative;
  background: #e8edf0;
  min-height: 55vh;
}
#mapa { width: 100%; height: 100%; min-height: 55vh; }

.mapa-aviso {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: #f4f6f8;
  color: #6b7280;
  font-size: 14px;
  text-align: center;
  padding: 2rem;
}
.mapa-aviso code { background: #e5e7eb; padding: 2px 6px; border-radius: 4px; font-size: 13px; color: #374151; }

.seleccion-ubicacion-aviso {
  position: absolute;
  bottom: 16px; left: 16px; right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.95);
  border: 1px solid #d1d5db;
  box-shadow: 0 12px 28px rgba(15,23,42,.08);
  color: #111827;
  font-size: 13px;
}
.seleccion-ubicacion-aviso p { margin: 6px 0 0; color: #475569; line-height: 1.4; }
.seleccion-ubicacion-aviso button { flex-shrink: 0; }

/* Popup Google Maps */
.gm-popup { font-family: 'Segoe UI', system-ui, sans-serif; min-width: 200px; max-width: 280px; }
.gm-popup-tipo  { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #9ca3af; margin-bottom: 4px; }
.gm-popup-titulo { font-size: 15px; font-weight: 600; color: #111827; margin-bottom: 6px; }
.gm-popup-desc  { font-size: 13px; color: #4b5563; line-height: 1.5; margin-bottom: 8px; }
.gm-popup-meta  { font-size: 11px; color: #9ca3af; border-top: 1px solid #f3f4f6; padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  min-height: 44px;
  background: #fff;
  border-top: 1px solid #dde2e8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #9ca3af;
  flex-shrink: 0;
  padding: 6px 16px;
}
.footer-sep   { opacity: .4; }
.footer-link  { color: var(--color-secundario); font-weight: 500; }
.footer-link:hover { text-decoration: underline; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  /* Mapa público */
  .app-main { flex-direction: column; height: auto; overflow: visible; }
  .panel-lateral { width: 100%; height: auto; border-right: none; border-bottom: 1px solid #dde2e8; }
  .lista-incidencias { max-height: 240px; }
  .mapa-wrapper { height: 55vh; }

  /* Header */
  .header-nombre { font-size: 14px; }
  .header-inner  { padding: 8px 12px; }
  .header-nav    { gap: 5px; }

  /* Formularios */
  .form-fila-2 { grid-template-columns: 1fr; }

  /* Footer */
  .site-footer { justify-content: flex-start; padding: 8px 16px; }
  .footer-sep  { display: none; }
}

@media (max-width: 480px) {
  .header-inner { padding: 8px 12px; }
}

/* ============================================================
   Hamburger — menú de navegación admin responsive
   Visible en tablets y móviles (< 992px)
   ============================================================ */

/* El header necesita position:relative para que el dropdown
   absoluto se posicione relativo a él (no desplaza el mapa) */
.site-header { position: relative; }

/* ── Botón hamburguesa ──────────────────────────────────── */
.nav-toggler {
  display: none; /* oculto en desktop, Bootstrap d-lg-none lo muestra */
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 7px;
  color: var(--color-texto-header, #fff);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.nav-toggler:hover    { background: rgba(255,255,255,.25); }
.nav-toggler:focus    { outline: none; box-shadow: 0 0 0 2px rgba(255,255,255,.4); }

/* Icono × cuando está abierto */
.nav-toggler[aria-expanded="true"] .bi::before { content: "\F659"; }

/* ── Dropdown nav (mobile / tablet) ────────────────────── */
.admin-nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--color-primario);
  border-top: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
}

.admin-nav-list {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav-list .btn-logout,
.admin-nav-list .av-nav-btn {
  width: 100%;
  justify-content: flex-start !important;
  padding: 10px 14px !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-weight: 500;
  gap: 9px;
}
.admin-nav-list .btn-logout:hover,
.admin-nav-list .av-nav-btn:hover {
  background: rgba(255,255,255,.18) !important;
}

/* Divider opcional entre grupos */
.admin-nav-divider {
  height: 1px;
  background: rgba(255,255,255,.15);
  margin: 6px 0;
}
