/**
 * ============================================================================
 * ARCHIVO: src/public/css/map.css
 * PROPOSITO: Estilos del Visor de Mapa Interactivo (map.html) y Selector de
 *            Coordenadas (picker.html).
 *            Replica el diseno limpio de las 5 capturas de referencia:
 *            - Circulos de cluster blancos con borde coloreado y numero negrita
 *            - Selector "Map | Satélite" flotante arriba a la izquierda
 *            - Tarjeta emergente blanca (Popup) con imagen, subtitulo coloreado
 *              en mayusculas, titulo en negrita y boton de accion
 *            - Soporte completo para modo incrustado (?embed=1 -> body.is-embed)
 * ============================================================================
 */

:root {
  --as-primary: #0d9488;
  --as-primary-dark: #0f766e;
  --as-blue: #2563eb;
  --as-danger: #e11d48;
  --as-text: #0f172a;
  --as-muted: #64748b;
  --as-border: #e2e8f0;
  --as-surface: #ffffff;
  --as-bg: #f8fafc;
  --as-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08);
  --as-shadow-md: 0 10px 28px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--as-text);
  background: var(--as-bg);
}

body.as-map-page {
  height: 100%;
  overflow: hidden;
}

/* Modo incrustado (?embed=1): SOLO el mapa puro, sin barra superior ni barra de filtros */
body.is-embed {
  background: transparent;
}

body.is-embed .as-top-navbar,
body.is-embed .as-filter-bar {
  display: none !important;
}

/* Si se pasa ?embed=1&filtros=1 permite mostrar la barra de filtros sin el menu superior */
body.is-embed.show-embed-filters .as-filter-bar {
  display: flex !important;
}

body.is-embed .as-app-shell {
  height: 100vh;
}

.as-app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
}

/* Barra de navegacion superior (solo visible cuando NO es embed) */
.as-top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--as-surface);
  border-bottom: 1px solid var(--as-border);
  z-index: 1000;
  flex-shrink: 0;
}

.as-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--as-text);
  text-decoration: none;
}

.as-brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0d9488, #0284c7);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.as-nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.as-nav-link {
  text-decoration: none;
  color: var(--as-muted);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.as-nav-link:hover {
  background: #f1f5f9;
  color: var(--as-text);
}

.as-nav-link.is-active {
  background: #ccfbf1;
  color: #0f766e;
}

/* Barra de filtros dinamicos sobre el mapa */
.as-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--as-border);
  z-index: 900;
}

.as-cat-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.as-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--as-border);
  background: #ffffff;
  color: var(--as-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.as-cat-pill:hover {
  border-color: #94a3b8;
}

.as-cat-pill.is-active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.as-cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.as-cat-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(100, 116, 139, 0.16);
}

.as-cat-pill.is-active .as-cat-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.as-filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.as-select,
.as-input {
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--as-border);
  background: #ffffff;
  font-size: 13px;
  color: var(--as-text);
  outline: none;
}

.as-select:focus,
.as-input:focus {
  border-color: var(--as-primary);
}

/* Contenedor principal del mapa */
.as-map-stage {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
}

#map-canvas,
#picker-map-canvas {
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #a5ded8;
}

/* Filtro de color estilo Joomla YOOtheme "Design Escapes" (agua turquesa y tierra verde menta) */
.as-design-escapes-tiles {
  filter: hue-rotate(-26deg) saturate(1.22) brightness(1.01) contrast(0.97);
}

/* Boton "Map | Satélite" identico a las Imagenes 1 a 5 */
.as-map-type-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 500;
  display: inline-flex;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.as-map-type-btn {
  border: none;
  background: #ffffff;
  color: #475569;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-right: 1px solid #e2e8f0;
}

.as-map-type-btn:last-child {
  border-right: none;
}

.as-map-type-btn.is-active {
  font-weight: 700;
  color: #0f172a;
  background: #f8fafc;
}

/* Clusters circulares blancos con borde coloreado (Imagenes 1, 2 y 4) */
.as-cluster-wrapper {
  background: transparent;
  border: none;
}

.as-cluster-circle {
  background: #ffffff;
  border: 3.5px solid var(--as-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.25);
  transition: transform 0.15s ease;
}

.as-cluster-circle:hover {
  transform: scale(1.08);
}

.as-cluster-count {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1;
}

/* Pin individual tipo gota con punto blanco central (Imagenes 2 a 5) */
.as-pin-marker {
  background: transparent;
  border: none;
}

.as-pin-svg {
  transition: transform 0.15s ease;
}

.as-pin-marker:hover .as-pin-svg {
  transform: translateY(-3px) scale(1.07);
}

/* Tarjeta emergente Popup (Imagenes 3 y 5) */
.as-clean-popup .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--as-shadow-md);
  overflow: hidden;
}

.as-clean-popup .leaflet-popup-content {
  margin: 0;
  width: 295px !important;
}

.as-clean-popup .leaflet-popup-close-button {
  top: 10px !important;
  right: 10px !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92) !important;
  color: #334155 !important;
  font-size: 20px !important;
  line-height: 28px !important;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.as-popup-card {
  display: flex;
  flex-direction: column;
}

.as-popup-image-wrap {
  position: relative;
  padding: 14px 14px 0 14px;
}

.as-popup-image {
  width: 100%;
  height: 148px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  background: #e2e8f0;
}

.as-popup-badge {
  position: absolute;
  bottom: 8px;
  left: 22px;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
}

.as-popup-body {
  padding: 14px 16px 16px 16px;
}

.as-popup-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.as-popup-title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.28;
  margin-bottom: 6px;
}

.as-popup-summary {
  font-size: 13px;
  color: #475569;
  line-height: 1.45;
  margin-bottom: 10px;
}

.as-popup-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #64748b;
  margin-bottom: 12px;
}

.as-popup-verified {
  color: #0f766e;
  font-weight: 600;
}

.as-popup-btn {
  width: 100%;
  border: none;
  border-radius: 6px;
  padding: 9px 12px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.as-popup-btn:hover {
  opacity: 0.92;
}

/* Estados de pantalla (cargando, sin resultados, error, sin conexion) */
.as-status-overlay {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 650;
  max-width: 340px;
}

.as-status-overlay.is-hidden {
  display: none;
}

.as-status-box {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--as-border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--as-shadow-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13.5px;
}

.as-status-box.is-warning {
  border-left: 4px solid #f59e0b;
}

.as-status-box.is-error {
  border-left: 4px solid var(--as-danger);
}

.as-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #cbd5e1;
  border-top-color: var(--as-primary);
  border-radius: 50%;
  animation: asSpin 0.75s linear infinite;
}

@keyframes asSpin {
  to {
    transform: rotate(360deg);
  }
}

.as-btn-secondary {
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--as-border);
  background: #f8fafc;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Drawer lateral de vista previa de historia (en modo no-embed) */
.as-story-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 92vw;
  height: 100%;
  background: #ffffff;
  box-shadow: -6px 0 24px rgba(15, 23, 42, 0.16);
  z-index: 800;
  transform: translateX(105%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.as-story-drawer.is-open {
  transform: translateX(0);
}

.as-drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--as-border);
}

.as-drawer-close {
  border: none;
  background: #f1f5f9;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

.as-drawer-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.as-drawer-cover {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
}

.as-drawer-kicker {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.as-drawer-title {
  font-size: 19px;
  margin-bottom: 10px;
}

.as-drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.as-tag {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #334155;
}

.as-drawer-desc {
  font-size: 14px;
  line-height: 1.55;
  color: #334155;
  margin-bottom: 14px;
}

.as-drawer-list {
  margin: 6px 0 14px 18px;
  font-size: 13.5px;
}

.as-bridge-notice {
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  font-size: 12px;
  color: #0f766e;
}

/* Panel lateral del Selector de Coordenadas (picker.html) */
.as-picker-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.as-picker-sidebar {
  background: #ffffff;
  border-right: 1px solid var(--as-border);
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 400;
}

.as-picker-sidebar h1 {
  font-size: 18px;
}

.as-picker-hint {
  font-size: 13px;
  color: var(--as-muted);
  line-height: 1.45;
}

.as-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.as-field-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
}

.as-search-row {
  display: flex;
  gap: 6px;
}

.as-search-row .as-input {
  flex: 1;
}

.as-btn-primary {
  padding: 9px 14px;
  border-radius: 8px;
  border: none;
  background: var(--as-primary);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.as-btn-primary:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.as-geocode-results {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.as-geocode-btn {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--as-border);
  background: #f8fafc;
  font-size: 12px;
  cursor: pointer;
}

.as-geocode-btn:hover {
  background: #ccfbf1;
}

.as-coords-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--as-border);
  border-radius: 8px;
}

.as-coord-item span {
  display: block;
  font-size: 11px;
  color: var(--as-muted);
  text-transform: uppercase;
}

.as-coord-item strong {
  font-size: 15px;
  font-family: monospace;
}

.as-picker-feedback {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}

.as-picker-feedback.is-valid {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.as-picker-feedback.is-invalid {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .as-picker-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}
