/* ApoyoVE - Bootstrap 5 con estética tipo Tailwind */
:root {
  --av-primary: #0d9488;
  --av-primary-dark: #0f766e;
  --av-danger: #dc2626;
  --av-warning: #d97706;
  --av-success: #16a34a;
  --av-info: #0284c7;
  --av-bg: #f8fafc;
  --av-surface: #ffffff;
  --av-text: #0f172a;
  --av-muted: #64748b;
  --av-border: #e2e8f0;
  --av-radius: 0.75rem;
  --av-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --av-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--av-bg);
  color: var(--av-text);
  -webkit-font-smoothing: antialiased;
}

/* Utilidades tipo Tailwind */
.text-muted { color: var(--av-muted) !important; }
.text-teal { color: var(--av-primary) !important; }
.rounded-xl { border-radius: var(--av-radius) !important; }
.shadow-sm { box-shadow: var(--av-shadow) !important; }
.shadow-lg { box-shadow: var(--av-shadow-lg) !important; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }

/* Navbar */
.navbar-apoyo {
  background: var(--av-surface);
  border-bottom: 1px solid var(--av-border);
  backdrop-filter: blur(8px);
}
.navbar-apoyo .navbar-brand {
  font-weight: 700;
  color: var(--av-primary-dark);
  letter-spacing: -0.02em;
}
.navbar-apoyo .nav-link {
  color: var(--av-muted);
  font-weight: 500;
  font-size: .875rem;
  padding: .5rem .75rem !important;
  border-radius: .5rem;
  transition: all .15s;
}
.navbar-apoyo .nav-link:hover,
.navbar-apoyo .nav-link.active {
  color: var(--av-primary-dark);
  background: rgba(13,148,136,.08);
}

/* Sidebar móvil (offcanvas derecha → izquierda) */
.nav-sidebar {
  width: min(85vw, 320px);
  border-left: 1px solid var(--av-border);
  z-index: 1060;
}
.offcanvas-backdrop {
  z-index: 1055;
}
.nav-sidebar .offcanvas-header {
  padding: 1rem 1.25rem;
}
.nav-sidebar .offcanvas-body {
  padding: 1rem 1.25rem 1.5rem;
}
.nav-sidebar-list .nav-sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem !important;
  font-size: 1rem;
  font-weight: 500;
  color: var(--av-text);
  border-radius: .625rem;
  margin-bottom: .25rem;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(13,148,136,.15);
  touch-action: manipulation;
}
.nav-sidebar-list .nav-sidebar-link .bi {
  font-size: 1.125rem;
  color: var(--av-primary);
  width: 1.25rem;
  text-align: center;
}
.nav-sidebar-list .nav-sidebar-link:hover,
.nav-sidebar-list .nav-sidebar-link.active {
  color: var(--av-primary-dark);
  background: rgba(13,148,136,.08);
}

/* Cards */
.card-apoyo {
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  box-shadow: var(--av-shadow);
  transition: box-shadow .2s, transform .2s;
}
.card-apoyo:hover { box-shadow: var(--av-shadow-lg); }

/* Badges */
.badge-necesidad { background: #fef2f2; color: #dc2626; }
.badge-donacion { background: #f0fdf4; color: #16a34a; }
.badge-voluntario { background: #eff6ff; color: #2563eb; }
.badge-verdadero { background: #f0fdf4; color: #16a34a; }
.badge-falso { background: #fef2f2; color: #dc2626; }
.badge-enganoso { background: #fffbeb; color: #d97706; }
.badge-pendiente { background: #f1f5f9; color: #64748b; }

/* Previsualización de enlaces (noticias) */
.link-preview {
  display: block;
  border: 1px solid var(--av-border);
  border-radius: .625rem;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: var(--av-bg);
  transition: box-shadow .15s, border-color .15s;
}
.link-preview:hover {
  border-color: rgba(13,148,136,.35);
  box-shadow: var(--av-shadow);
  color: inherit;
}
.link-preview-image {
  aspect-ratio: 1.91 / 1;
  background: #e2e8f0;
  overflow: hidden;
}
.link-preview-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.link-preview-image--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--preview-color, #0d9488) 0%, rgba(0,0,0,.15) 100%);
  min-height: 120px;
}
.link-preview-image--fallback .bi {
  font-size: 2.5rem;
  color: #fff;
  opacity: .9;
}
.link-preview-body {
  padding: .75rem .875rem;
}
.link-preview-site {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--preview-color, var(--av-primary));
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-bottom: .375rem;
}
.link-preview-site .bi { font-size: .875rem; }
.link-preview-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--av-text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-preview-desc {
  font-size: .8125rem;
  color: var(--av-muted);
  margin-top: .25rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#enlace-preview-box .link-preview { margin-top: .75rem; }

/* Alerta informativa por módulo */
.module-alert {
  background: linear-gradient(135deg, #ecfeff 0%, #f0fdfa 100%);
  color: #0f766e;
  border-radius: var(--av-radius);
  padding: .875rem 1rem;
}
.module-alert .bi-heart-fill { color: var(--av-primary); }

/* Noticias marcadas como falsas por la comunidad */
.noticia-card {
  position: relative;
  overflow: hidden;
}
.noticia-card--falsa {
  border: 3px solid #dc2626 !important;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, .15), var(--av-shadow-lg);
}
.noticia-falsa-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: #fff;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: .15em;
  padding: .75rem 1rem;
  margin: -1rem -1rem 1rem;
  text-transform: uppercase;
}
.noticia-falsa-banner .bi { font-size: 1.75rem; }
.noticia-falsa-reportes {
  border-top: 1px dashed #fecaca;
  padding-top: .75rem;
  margin-top: auto;
}
.noticia-falsa-reportes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 140px;
  overflow-y: auto;
}
.noticia-falsa-reporte-item {
  padding: .375rem 0;
  border-bottom: 1px solid var(--av-border);
  font-size: .8125rem;
}
.noticia-falsa-reporte-item:last-child { border-bottom: none; }
.noticia-falsa-reporte-item span { display: block; color: var(--av-text); }
.noticia-mini-card--falsa {
  border: 2px solid #dc2626 !important;
  position: relative;
}
.noticia-mini-falsa {
  position: absolute;
  top: .25rem;
  right: .25rem;
  z-index: 2;
  background: #dc2626;
  color: #fff;
  font-size: .5625rem;
  font-weight: 800;
  padding: .15em .35em;
  border-radius: .25rem;
  letter-spacing: .05em;
}

.link-preview--compact { margin-top: .5rem; }
.link-preview-image--compact {
  aspect-ratio: 2 / 1;
  min-height: 72px;
}
.link-preview--compact .link-preview-body { padding: .5rem .625rem; }
.link-preview--compact .link-preview-title {
  font-size: .8125rem;
  -webkit-line-clamp: 1;
}
.link-preview--compact .link-preview-site {
  font-size: .6875rem;
  margin-bottom: .25rem;
}

/* Mini cards noticias — inicio */
.noticias-inicio-grid .noticia-mini-col:nth-child(n+5) { display: none; }
@media (min-width: 992px) {
  .noticias-inicio-grid .noticia-mini-col:nth-child(n+5) { display: block; }
  .noticias-inicio-grid .noticia-mini-col:nth-child(n+13) { display: none; }
}

.noticia-mini-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  border-radius: .625rem;
  overflow: hidden;
  height: 100%;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.noticia-mini-card:hover {
  color: inherit;
  border-color: rgba(13,148,136,.35);
  box-shadow: var(--av-shadow);
  transform: translateY(-1px);
}
.noticia-mini-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #e2e8f0;
  overflow: hidden;
}
.noticia-mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.noticia-mini-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--preview-color, #0d9488), rgba(0,0,0,.12));
}
.noticia-mini-thumb-fallback .bi {
  font-size: 1.5rem;
  color: #fff;
}
.noticia-mini-badge {
  position: absolute;
  top: .375rem;
  left: .375rem;
  font-size: .625rem;
  padding: .2em .45em;
}
.noticia-mini-body {
  padding: .5rem .625rem .625rem;
}
.noticia-mini-title {
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.noticia-mini-date {
  font-size: .6875rem;
  display: block;
  margin-top: .25rem;
}
@media (min-width: 992px) {
  .noticia-mini-title { font-size: .8125rem; }
  .noticia-mini-thumb-fallback .bi { font-size: 1.75rem; }
}

/* Botones */
.btn-apoyo {
  background: var(--av-primary);
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: .5rem;
  padding: .625rem 1.25rem;
  transition: background .15s;
}
.btn-apoyo:hover { background: var(--av-primary-dark); color: #fff; }
.btn-outline-apoyo {
  border: 1.5px solid var(--av-primary);
  color: var(--av-primary);
  background: transparent;
  font-weight: 600;
  border-radius: .5rem;
}
.btn-outline-apoyo:hover { background: rgba(13,148,136,.08); color: var(--av-primary-dark); }

/* Hero */
.hero-apoyo {
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 50%, #14b8a6 100%);
  color: #fff;
  border-radius: var(--av-radius);
  padding: 2.5rem 2rem;
}
.hero-apoyo h1 { font-weight: 800; letter-spacing: -0.03em; }

/* Mapas */
#map, .map-container {
  height: 420px;
  border-radius: var(--av-radius);
  border: 1px solid var(--av-border);
  z-index: 1;
}
@media (min-width: 768px) {
  #map, .map-container { height: 520px; }
}

/* Stat cards */
.stat-card {
  text-align: center;
  padding: 1.25rem;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--av-primary-dark);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: .75rem;
  color: var(--av-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .25rem;
}

/* Service status indicators */
.servicio-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.servicio-funcionando { background: var(--av-success); }
.servicio-intermitente { background: var(--av-warning); }
.servicio-falla { background: var(--av-danger); }
.servicio-desconocido { background: var(--av-muted); }

.servicio-rank-total {
  margin-bottom: .75rem;
}
.servicio-rank-row {
  display: grid;
  grid-template-columns: minmax(5.5rem, 6.5rem) 1fr auto;
  align-items: center;
  gap: .5rem;
  margin-bottom: .65rem;
}
.servicio-rank-row:last-child {
  margin-bottom: 0;
}
.servicio-rank-row--empty .servicio-rank-bar-fill {
  background: var(--av-border);
}
.servicio-rank-row--empty .servicio-rank-count {
  color: var(--av-muted);
  font-weight: 500;
}
.servicio-rank-label {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  font-weight: 500;
  line-height: 1.2;
}
.servicio-rank-label .bi {
  color: var(--av-primary);
  flex-shrink: 0;
}
.servicio-rank-bar-wrap {
  height: 1.25rem;
  background: var(--av-border);
  border-radius: .375rem;
  overflow: hidden;
}
.servicio-rank-bar-fill {
  height: 100%;
  min-width: 4px;
  background: linear-gradient(90deg, var(--av-primary), #14b8a6);
  border-radius: .375rem;
  transition: width .35s ease;
}
.servicio-rank-count {
  min-width: 1.75rem;
  font-size: .875rem;
  font-weight: 700;
  text-align: right;
  color: var(--av-primary-dark);
}

.internados-table th {
  font-size: .7rem;
  white-space: nowrap;
}
.hospital-card .internados-block {
  background: var(--av-bg);
  border-radius: .5rem;
  padding: .5rem .65rem;
}

/* Offline banner */
.offline-banner {
  background: #fef3c7;
  color: #92400e;
  padding: .5rem 1rem;
  font-size: .875rem;
  text-align: center;
  display: none;
}
.offline-banner.show { display: block; }

/* Forms */
.form-control, .form-select {
  border-radius: .5rem;
  border-color: var(--av-border);
  font-size: .9375rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--av-primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,.15);
}
.form-label { font-weight: 600; font-size: .875rem; color: var(--av-text); }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: .5rem;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Footer */
.footer-apoyo {
  border-top: 1px solid var(--av-border);
  padding: 2rem 0;
  margin-top: 3rem;
  font-size: .875rem;
  color: var(--av-muted);
}

/* PWA install button */
.install-pwa-btn {
  display: none;
}

/* Map picker en modal */
.map-picker {
  height: 220px;
  border-radius: var(--av-radius);
  border: 1px solid var(--av-border);
  z-index: 1;
}

/* Multimedia en reportes */
.report-media {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
}
.report-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: .375rem;
  border: 1px solid var(--av-border);
}
.report-videos {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.report-video {
  width: 100%;
  max-height: 160px;
  border-radius: .375rem;
  background: #000;
}
.report-popup {
  max-width: 300px;
  font-size: .875rem;
}
.report-nav .btn {
  font-size: .75rem;
}

/* Card teléfono */
.card-telefono {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: .5rem;
  padding: .5rem .75rem;
  font-size: .875rem;
}
.card-telefono .bi-telephone-fill { color: var(--av-primary); }
.card-telefono-num {
  font-weight: 700;
  color: var(--av-primary-dark);
  text-decoration: none;
}
.card-telefono-num:hover { text-decoration: underline; }

/* Modal detalle */
.detalle-row {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .75rem;
  padding: .625rem 0;
  border-bottom: 1px solid var(--av-border);
}
.detalle-label {
  font-weight: 600;
  font-size: .8125rem;
  color: var(--av-muted);
  min-width: 120px;
}
.detalle-value {
  flex: 1;
  font-size: .9375rem;
}
.detalle-telefono {
  font-weight: 700;
  color: var(--av-primary-dark);
  text-decoration: none;
  font-size: 1.1rem;
}
.report-media-detalle {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .5rem;
}
.report-img-detalle {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: .5rem;
  border: 1px solid var(--av-border);
}
.report-video-detalle {
  width: 100%;
  max-height: 280px;
  border-radius: .5rem;
  background: #000;
  margin-bottom: .5rem;
}
.report-videos-detalle { margin-top: .5rem; }

/* Emergencias por estado */
.emergencia-tabs .nav-link {
  font-weight: 600;
  font-size: .875rem;
  color: var(--av-muted);
  border-radius: 2rem !important;
  padding: .5rem 1rem;
}
.emergencia-tabs .nav-link.active {
  background: var(--av-primary);
  color: #fff;
}
.estado-header {
  padding: .75rem 1rem;
  background: linear-gradient(135deg, #0f766e, #0d9488);
  color: #fff;
  border-radius: var(--av-radius);
}
.organismo-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: #dc2626;
  color: #fff;
  font-weight: 700;
  font-size: .875rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: .5rem 1rem;
  border-radius: 2rem;
  margin-bottom: .75rem;
  box-shadow: 0 2px 4px rgba(220,38,38,.25);
}
.organismo-block {
  background: var(--av-surface);
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  padding: 1rem 1.25rem;
}
.contacto-item {
  padding: .625rem 0;
  border-bottom: 1px solid var(--av-border);
}
.contacto-item:last-child { border-bottom: none; }
.contacto-ubicacion {
  font-weight: 600;
  font-size: .875rem;
  color: var(--av-text);
  margin-bottom: .375rem;
}
.contacto-telefonos {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
}
.btn-tel-emergencia {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  color: var(--av-primary-dark);
  font-weight: 600;
  font-size: .8125rem;
  padding: .375rem .75rem;
  border-radius: .5rem;
  text-decoration: none;
  transition: background .15s;
}
.btn-tel-emergencia:hover {
  background: #ccfbf1;
  color: var(--av-primary-dark);
}
.btn-tel-emergencia.btn-wa {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}
.btn-tel-emergencia.btn-wa:hover { background: #dcfce7; }

/* Botón flotante reportar bug */
.fab-bug {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1030;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #64748b;
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, background .15s;
  cursor: pointer;
}
.fab-bug:hover {
  background: #475569;
  transform: scale(1.05);
  color: #fff;
}
@media (max-width: 576px) {
  .fab-bug { bottom: 1rem; right: 1rem; width: 48px; height: 48px; }
  .footer-apoyo { padding-bottom: 4rem; }
}

/* Acopio — árbol estado / municipio */
.acopio-arbol .accordion-item {
  border: 1px solid var(--av-border);
  border-radius: .625rem !important;
  overflow: hidden;
  margin-bottom: .5rem;
}
.acopio-estado-item > .accordion-header .accordion-button {
  font-size: 1rem;
  background: #f0fdfa;
  color: var(--av-primary-dark);
}
.acopio-estado-item > .accordion-header .accordion-button:not(.collapsed) {
  background: #ccfbf1;
  box-shadow: none;
}
.acopio-municipio-item {
  border: none !important;
  border-top: 1px solid var(--av-border) !important;
  border-radius: 0 !important;
  margin-bottom: 0 !important;
}
.acopio-municipio-btn {
  font-size: .9375rem;
  padding: .625rem 1rem;
  background: var(--av-surface);
}
.acopio-municipio-btn:not(.collapsed) {
  background: rgba(13,148,136,.06);
  color: var(--av-primary-dark);
}
.acopio-centro-card {
  background: var(--av-bg);
  border: 1px solid var(--av-border);
  border-radius: .625rem;
  padding: .875rem;
  height: 100%;
}

.leaflet-container { font-family: inherit; z-index: 1; }
.leaflet-pane { z-index: 400; }

/* Compact table */
.table-apoyo { font-size: .875rem; }
.table-apoyo th {
  font-weight: 600;
  color: var(--av-muted);
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .04em;
  border-bottom-width: 1px;
}

/* Privacy notice */
.privacy-notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: .5rem;
  padding: .75rem 1rem;
  font-size: .8125rem;
  color: #1e40af;
}

/* Module icon grid on home */
.module-icon {
  width: 48px; height: 48px;
  border-radius: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: .75rem;
}
.module-icon-teal { background: rgba(13,148,136,.12); color: var(--av-primary); }
.module-icon-red { background: rgba(220,38,38,.1); color: var(--av-danger); }
.module-icon-blue { background: rgba(2,132,199,.1); color: var(--av-info); }
.module-icon-amber { background: rgba(217,119,6,.1); color: var(--av-warning); }
