/* --- CONFIGURACIÓN GLOBAL Y COLORES BASE --- */
:root {
    --color-acento: #d6a354;
    --color-fondo: #0f172a;
    --color-texto-principal: #f8fafc;
    --color-texto-secundario: #cbd5e1;
    --color-tarjeta-bg: #1e253a;
    --color-borde: rgba(255, 255, 255, 0.1);
    
    /* Variables PWA / Mobile */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);

    /* Z-Index Controlados Centralmente */
    --z-map: 1;
    --z-floating: 1000;
    --z-context: 2000;
    --z-header: 3000;
    --z-overlay: 3500;
    --z-sidebar: 4000;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto-principal);
    overflow: hidden;
    position: fixed;
    overscroll-behavior-y: none;
}

/* --- CABECERA NATIVA (HEADER) --- */
.app-header {
    position: fixed !important;
    top: 0; left: 0; width: 100%;
    height: calc(60px + var(--safe-area-top));
    padding-top: var(--safe-area-top);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    z-index: var(--z-header);
    display: flex; justify-content: space-between; align-items: center;
    padding-left: 15px; padding-right: 15px;
    border-bottom: 1px solid var(--color-borde);
}

.header-brand {
    display: flex; align-items: center; overflow: hidden; flex-grow: 1;
    text-decoration: none; color: inherit; cursor: pointer;
}
.app-logo { height: 35px; margin-right: 10px; }
.app-title {
    font-size: 0.95rem; font-weight: 600; margin: 0; color: var(--color-acento);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.lang-switcher { display: flex; gap: 8px; }
.lang-switcher a { width: 22px; opacity: 0.4; transition: 0.2s; display: flex; align-items: center; }
.lang-switcher a:hover { opacity: 0.8; }
.lang-switcher a.active { opacity: 1; transform: scale(1.15); }
.lang-switcher img { width: 100%; border-radius: 2px; }

.menu-toggle-btn {
    background: transparent; border: 1px solid var(--color-borde); color: white;
    width: 40px; height: 40px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; cursor: pointer;
}

/* --- PANEL DE CONTROL (IZQUIERDA) --- */
.control-panel {
    position: fixed !important;
    top: 0; left: -320px;
    width: 300px !important; max-width: 80vw;
    height: 100% !important; max-height: 100% !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-sidebar);
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.5);
    overflow-y: auto; background-color: var(--color-tarjeta-bg);
    padding: calc(20px + var(--safe-area-top)) 20px 20px 20px;
}
.control-panel.open { left: 0; }

.menu-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: var(--z-overlay);
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease;
}
.menu-overlay.active { opacity: 1; visibility: visible; }

/* Contenido del Panel Izquierdo */
.control-panel h2 { color: var(--color-texto-secundario); margin: 20px 0 10px; font-size: 1.1rem; text-transform: uppercase; }
.layer-toggle { display: flex; align-items: center; margin-bottom: 12px; cursor: pointer; padding: 10px; border-radius: 6px; transition: 0.2s; }
.layer-toggle:hover { background-color: rgba(255, 255, 255, 0.05); }
.layer-toggle.zone-toggle:has(input:checked) { background-color: rgba(214, 163, 84, 0.1); }
.toggle-icon { width: 40px; height: 40px; border-radius: 50%; border: 2px solid white; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-right: 12px; flex-shrink: 0; background: var(--color-acento); color: var(--color-fondo); }
.zone-icon { border-radius: 50% !important; }
.toggle-label { font-size: 0.95rem; font-weight: 500; flex-grow: 1; }

.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { display: none; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #3a3a3c; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--color-acento); }
input:checked + .slider:before { transform: translateX(20px); }

.help-text-zones { font-size: 0.85rem; color: var(--color-texto-secundario); background: rgba(255, 255, 255, 0.03); padding: 10px; border-radius: 6px; margin-bottom: 15px; border-left: 3px solid var(--color-acento); }

/* --- MAPA --- */
.container { display: flex; flex-direction: column; height: 100vh; width: 100vw; padding-top: calc(60px + var(--safe-area-top)); }
.map-container { flex-grow: 1; width: 100%; position: relative; }
#map { width: 100%; height: 100%; z-index: var(--z-map); background-color: #555; }

.floating-actions { position: absolute; bottom: calc(30px + var(--safe-area-bottom)); left: 50%; transform: translateX(-50%); z-index: var(--z-floating); display: flex; flex-direction: column; gap: 10px; }
.btn-float { width: 55px; height: 55px; background: var(--color-acento); color: var(--color-fondo); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); border: 2px solid rgba(255, 255, 255, 0.2); cursor: pointer; }

/* Callouts Cartográficos */
.zone-callout { pointer-events: none; }
.callout-dot { width: 8px; height: 8px; background: var(--color-acento); border: 2px solid white; border-radius: 50%; box-shadow: 0 0 5px rgba(0,0,0,0.5); flex-shrink: 0; z-index: 3; margin-left: -4px; }
.callout-line { width: 50px; height: 2px; background: rgba(255,255,255,0.8); box-shadow: 0 1px 2px rgba(0,0,0,0.5); margin-left: -2px; flex-shrink: 0; z-index: 2; }
.map-zone-label { background: rgba(15,23,42,0.9); border: 1px solid rgba(214,163,84,0.5); color: white; border-radius: 6px; padding: 5px 12px; font-weight: 600; font-size: 0.85rem; text-transform: uppercase; box-shadow: 0 4px 10px rgba(0,0,0,0.4); white-space: nowrap; flex-shrink: 0; margin-left: 2px; z-index: 1; }
.leaflet-tooltip-left.map-zone-label::before, .leaflet-tooltip-right.map-zone-label::before, .leaflet-tooltip-top.map-zone-label::before, .leaflet-tooltip-bottom.map-zone-label::before { display: none !important; }

/* --- POPUPS LEAFLET --- */
.leaflet-popup-content-wrapper { background-color: var(--color-tarjeta-bg); color: var(--color-texto-principal); border: 1px solid var(--color-borde); border-radius: 8px; }
.leaflet-popup-content { margin: 15px !important; width: auto !important; }
.leaflet-popup-tip { background: var(--color-tarjeta-bg); }
.leaflet-popup-close-button { color: var(--color-texto-secundario) !important; }
.popup-img { width: 100%; height: 120px; object-fit: cover; border-radius: 5px; margin-bottom: 10px; background-color: #444; }
.popup-title { font-weight: bold; margin-bottom: 5px; color: var(--color-acento); }
.popup-type { color: var(--color-texto-secundario); font-size: 0.9rem; margin-bottom: 10px; }
.popup-btn { display: block; width: 100%; padding: 8px; background-color: var(--color-acento); color: var(--color-fondo); border: none; border-radius: 4px; cursor: pointer; text-align: center; text-decoration: none; font-size: 0.9rem; font-weight: bold; }
.custom-marker { background: white; border: 3px solid var(--color-acento); border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--color-acento); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.custom-icon { background: none !important; border: none !important; }

/* --- PANEL DE CONTEXTO (DERECHA) --- */
.context-panel { position: absolute; top: 0; right: -450px; width: 420px; height: 100%; background-color: var(--color-tarjeta-bg); border-left: 1px solid var(--color-borde); box-shadow: -5px 0 20px rgba(0,0,0,0.3); z-index: var(--z-context); transition: right 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); display: flex; flex-direction: column; }
.context-panel.visible { right: 0; }
.panel-header { height: 220px; position: relative; flex-shrink: 0; background-color: #444; }
.panel-header-image { width: 100%; height: 100%; object-fit: cover; mask-image: linear-gradient(to top, transparent 0%, black 40%); }
.close-panel-btn { position: absolute; top: 15px; right: 15px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2); color: white; font-size: 1.5rem; cursor: pointer; width: 40px; height: 40px; border-radius: 50%; line-height: 40px; text-align: center; padding: 0; transition: 0.2s; }
.panel-header-content { position: absolute; bottom: 20px; left: 20px; right: 20px; }
.panel-header-content h2 { margin: 0 0 5px 0; color: white; font-size: 1.8rem; text-shadow: 0 2px 4px rgba(0,0,0,0.7); }
.panel-tag { background-color: var(--color-acento); color: var(--color-fondo); padding: 4px 10px; border-radius: 12px; font-size: 0.85rem; font-weight: bold; display: inline-block; }
.panel-content-scroll { padding: 0 20px 20px 20px; overflow-y: auto; flex-grow: 1; }
.panel-content-scroll h3 { color: var(--color-acento); font-size: 1rem; text-transform: uppercase; border-bottom: 1px solid var(--color-borde); padding-bottom: 5px; margin: 20px 0 15px 0; }
.wysiwyg-content p { color: var(--color-texto-secundario); line-height: 1.6; font-size: 0.95rem; margin-bottom: 1em; }

.horizontal-scroll-list { display: flex; overflow-x: auto; padding-bottom: 15px; }
.h-scroll-item { text-align: center; margin-right: 20px; flex-shrink: 0; width: 80px; text-decoration: none; }
.h-scroll-item img { width: 80px; height: 80px; border-radius: 50%; border: 3px solid white; object-fit: cover; margin-bottom: 8px; }
.h-scroll-item span { font-size: 0.85rem; color: var(--color-texto-secundario); display: block; }
.vertical-list-item { display: flex; align-items: center; margin-bottom: 15px; padding: 10px; border-radius: 6px; text-decoration: none; color: inherit; transition: 0.2s; }
.vertical-list-item:hover { background-color: rgba(255,255,255,0.05); }
.vertical-list-item img { width: 60px; height: 60px; border-radius: 50%; border: 2px solid white; object-fit: cover; margin-right: 15px; flex-shrink: 0; }
.item-info h4 { margin: 0 0 2px 0; font-size: 1rem; color: var(--color-texto-principal); }
.item-info p { margin: 0; font-size: 0.9rem; color: var(--color-texto-secundario); }

/* Fix de SweetAlert para el Visor */
.swal2-container { z-index: 10600 !important; }
.tutorial-popup { font-size: 0.95rem !important; border-radius: 12px !important; border: 1px solid var(--color-borde) !important; }

@media (max-width: 768px) {
    .container { flex-direction: column; }
    .control-panel { width: 100% !important; }
    .context-panel { width: 100%; right: -100%; }
}
/* --- EFECTO FOCO PARA EL TUTORIAL INTERACTIVO --- */
.tutorial-highlight {
    /* Crea la cortina oscura usando una sombra gigante */
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75) !important;
    /* Se pone por encima del sidebar (4000) pero por debajo de SweetAlert (10600) */
    z-index: 4500 !important; 
    position: relative !important;
    /* Evita que el usuario toque botones por error mientras lee el tutorial */
    pointer-events: none !important; 
    border-radius: 8px;
}