:root {
  /* Paleta institucional — Morena (guinda) */
  --guinda: #a4161a;
  --guinda-dark: #7c0f13;
  --guinda-2: #c11e23;
  --rojo: #d00000;
  --ambar: #f59e0b;
  --ambar-light: #fbbf24;

  --primary: #a4161a;
  --primary-2: #8b1317;
  --accent: #c11e23;
  --gold: #f59e0b;

  --bg: #f5f1ef;
  --surface: #ffffff;
  --border: #e6dbd7;
  --text: #241613;
  --muted: #7a6b66;
  --nav-h: 62px;

  --grad-brand: linear-gradient(135deg, #7c0f13 0%, #b5261e 60%, #c11e23 100%);
  --grad-gold: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

body {
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(45deg, rgba(164,22,26,0.035) 0, rgba(164,22,26,0.035) 1px, transparent 1px, transparent 14px),
    repeating-linear-gradient(-45deg, rgba(164,22,26,0.025) 0, rgba(164,22,26,0.025) 1px, transparent 1px, transparent 14px),
    radial-gradient(1100px 500px at 100% -8%, rgba(193,30,35,0.10), transparent 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: calc(var(--nav-h) + 24px);
  font-size: 16px;
  min-height: 100vh;
}

/* --------------------------- Topbar móvil --------------------------- */
.mobile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--grad-brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(124,15,19,0.25);
}
.mobile-topbar .brand {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-topbar .brand i { color: var(--gold); }
.mobile-topbar .logout { color: rgba(255,255,255,0.9); text-decoration: none; font-size: 1.1rem; }

/* --------------------------- Navbar desktop --------------------------- */
.desktop-nav {
  display: none;
  background: var(--grad-brand) !important;
  box-shadow: 0 4px 16px rgba(23,42,70,0.25);
  padding-top: 4px;
  padding-bottom: 4px;
}
.desktop-nav .navbar-brand { font-weight: 800; letter-spacing: 0.3px; }
.desktop-nav .nav-link { color: rgba(255,255,255,0.9); font-weight: 500; border-radius: 10px; padding: 8px 14px !important; }
.desktop-nav .nav-link:hover { background: rgba(255,255,255,0.12); color: #fff; }
.desktop-nav .nav-link.active { color: #fff; font-weight: 700; background: rgba(255,255,255,0.16); }

/* --------------------------- Bottom nav (táctil) ---------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex; z-index: 1000;
  box-shadow: 0 -4px 20px rgba(23,42,70,0.08);
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); text-decoration: none; font-size: 0.68rem;
  border-top: 3px solid transparent;
}
.bottom-nav a i { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--guinda); border-top-color: var(--gold); font-weight: 700; }

/* ------------------------------- Cards ------------------------------- */
.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(23,42,70,0.06);
}
.card-header {
  background: linear-gradient(135deg, #f8fafd, #fff);
  border-bottom: 1px solid var(--border);
  font-weight: 700; color: var(--primary);
}

.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 10px;
  text-decoration: none; color: var(--text);
  box-shadow: 0 2px 8px rgba(23,42,70,0.04);
  transition: transform .12s ease, box-shadow .12s ease;
}
.list-item:active { transform: scale(0.99); background: #f3f6fb; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; }
/* Nombres de archivo largos (evidencia) no deben romper la fila */
.list-item .sub { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; word-break: break-word; }
.icon-badge {
  width: 44px; height: 44px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}

/* Botones */
.btn { border-radius: 12px; font-weight: 600; }
.btn-lg { padding: 14px; font-size: 1.05rem; font-weight: 700; }
.btn-primary { background: var(--grad-brand); border: none; color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--guinda-dark); color: #fff; }
.btn-accent { background: var(--grad-gold); border: none; color: #422006; }
.btn-accent:hover { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #422006; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px);
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--grad-gold);
  color: #3d1d00;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem; font-weight: 700;
  box-shadow: 0 6px 18px rgba(245,158,11,0.45);
  z-index: 900; text-decoration: none;
}
.fab:active { transform: scale(0.94); }

/* Formularios */
.form-control, .form-select {
  border-radius: 11px; padding: 12px 14px; font-size: 16px;
  border-color: var(--border);
}
.form-control:focus, .form-select:focus {
  border-color: var(--guinda);
  box-shadow: 0 0 0 3px rgba(164,22,26,0.15);
}
.form-label { font-weight: 600; color: var(--primary); }

/* Badges de estado */
.badge { font-weight: 700; padding: 6px 11px; border-radius: 999px; letter-spacing: 0.2px; }
.badge-status-borrador { background: #e7ebf1; color: #5b6678; }
.badge-status-agendado { background: #e3f0ff; color: #1e4b8f; }
.badge-status-confirmado { background: #d4f3e6; color: #0d7a5a; }
.badge-status-cancelado { background: #fde2e2; color: #b02a37; }
.badge-status-realizado { background: #fdf0d3; color: #9a6700; }
.badge-status-pendiente { background: #fdf0d3; color: #9a6700; }
.badge-status-aprobado { background: #d4f3e6; color: #0d7a5a; }
.badge-status-rechazado { background: #fde2e2; color: #b02a37; }

/* Estadísticas */
.stat-card {
  flex: 1 1 30%; min-width: 100px;
  background: linear-gradient(160deg, #fff, #f6f9fd);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 14px; padding: 14px;
}
.stat-card:nth-child(2) { border-top-color: var(--gold); }
.stat-card:nth-child(3) { border-top-color: var(--primary); }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { color: var(--muted); font-size: 0.8rem; }

/* Mapa */
#map { height: 60vh; min-height: 400px; border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(23,42,70,0.10); }

/* Calendario */
.calendar { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; box-shadow: 0 4px 14px rgba(23,42,70,0.06); }
.calendar-head { background: var(--grad-brand); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; }
.calendar-head .month { font-weight: 800; font-size: 1.1rem; }
.calendar-head .btn { background: rgba(255,255,255,0.14); border: 0; color: #fff; }
.calendar-weekdays { background: #f7fafc; }
.calendar-weekdays, .calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-weekdays div { text-align: center; font-size: 0.72rem; color: var(--muted); padding: 8px 0; font-weight: 700; text-transform: uppercase; }
.calendar-days .day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  position: relative; cursor: pointer; border-radius: 8px; font-size: 0.95rem; font-weight: 500;
}
.calendar-days .day.has-events::after {
  content: ''; position: absolute; bottom: 7px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
}
.calendar-days .day.today { background: var(--accent); color: #fff; font-weight: 800; }
.calendar-days .day.selected { background: var(--grad-brand); color: #fff; font-weight: 800; }

.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}
.auth-wrap .card {
  width: 100%;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 14px 44px rgba(124,15,19,0.16);
  overflow: hidden;
}

.page-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-title h4 { font-weight: 800; color: var(--primary); font-size: 1.4rem; }

/* ------------------------- Datepicker ------------------------- */
.calendar-popup {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 34px rgba(23,42,70,0.30); padding: 14px;
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1200;
  width: min(calc(100vw - 32px), 340px);
  max-height: 85vh;
  overflow-y: auto;
}
.calendar-popup .cp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calendar-popup .cp-head .cp-month { font-weight: 700; }
.calendar-popup .cp-weekdays, .calendar-popup .cp-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-popup .cp-weekdays div { text-align: center; font-size: 0.7rem; color: var(--muted); padding: 4px 0; }
.calendar-popup .cp-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; font-size: 0.9rem; }
.calendar-popup .cp-day:hover { background: #eef2fb; }
.calendar-popup .cp-day.selected { background: var(--primary); color: #fff; font-weight: 700; }
.calendar-popup .cp-day.today { border: 2px solid var(--gold); }

/* Sección de ubicación */
.location-tools { display: flex; flex-direction: column; gap: 8px; }
.accent-bg {
  background: var(--grad-gold); border: none; color: #422006;
  font-weight: 700; border-radius: 12px;
}
.accent-bg:hover { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #422006; }

@media (min-width: 768px) {
  body { padding-bottom: 20px; }
  .bottom-nav { display: none; }
  .mobile-topbar { display: none; }
  .desktop-nav { display: flex; }
  .fab { bottom: 24px; }
}
/* Overlay para el datepicker (modal) */
.date-overlay {
  position: fixed; inset: 0;
  background: rgba(12,8,7,0.45);
  z-index: 1150;
}

/* Puntos de la leyenda del mapa */
.map-dot {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  vertical-align: middle;
  margin-right: 4px;
}

/* Los marcadores del mapa usan un círculo más grande y notorio */
.leaflet-interactive {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}

/* Campana de notificaciones (admin) */
.badge-notif {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626; color: #fff;
  font-size: 11px; font-weight: 700;
  line-height: 18px; text-align: center;
}

/* Distintivo del perfil activo */
.cand-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.18); color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 0 1 auto; min-width: 0;
}
.cand-chip img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.cand-thumb { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

/* Miniatura de evidencia (foto) y botón de video en el detalle del evento */
.ev-thumb {
  width: 64px; height: 64px;
  max-width: 64px; max-height: 64px;  /* seguro anti-desborde si el CSS carga */
  object-fit: cover; border-radius: 10px;
  cursor: zoom-in; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.08);
  background: #f3f4f6;
}
.ev-thumb-video {
  display: flex; align-items: center; justify-content: center;
  background: var(--guinda, #a4161a); color: #fff; font-size: 1.3rem;
  cursor: pointer; border: none; padding: 0;
}
.ev-thumb-video:hover { filter: brightness(1.15); color: #fff; }
