/* =============================================================
   SISTEMA DE DISEÑO SOBRIO - GUÍA DE NAVEGACIÓN HORNOS DE LONQUÉN
   Alineado a los Colores y Estética de memorialonquen.cl
   ============================================================= */

/* Paleta de Colores Institucional */
:root {
    --bg-light: #F9FAFB;
    --bg-white: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --border-color: #E5E7EB;
    
    --brand-fuchsia: #BA4186;
    --brand-fuchsia-hover: #9E3771;
    --brand-fuchsia-glow: rgba(186, 65, 134, 0.15);
    
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    
    --accent-red: #EF4444;
    --accent-green: #10B981;
    
    --font-main: 'Inter', sans-serif;
    --panel-width: 380px;
}

/* Reset de Estilos */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100vw;
}

.app-container {
    display: flex;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100vw;
    position: relative;
}

/* =============================================================
   PANEL LATERAL IZQUIERDO (Aside)
   ============================================================= */
.control-panel {
    width: var(--panel-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    flex-shrink: 0;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.02);
}

/* Cabecera */
.panel-header {
    padding: 10px 16px 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.brand-text {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-primary);
    text-transform: uppercase;
}

.text-fuchsia {
    color: var(--brand-fuchsia);
    font-size: 14px;
}

.panel-header h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
    letter-spacing: -0.5px;
}

.panel-header p {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Tarjeta de Instrucción Dinámica (Estilo Limpio y Sobrio) */
.instruction-card {
    margin: 8px 16px;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.card-header {
    margin-bottom: 6px;
}

.step-badge {
    background-color: rgba(255, 46, 147, 0.08);
    color: var(--brand-fuchsia);
    border: 1px solid rgba(255, 46, 147, 0.15);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
}

.step-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.direction-badge {
    width: 24px;
    height: 24px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.step-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.step-desc {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Caja de Referencia Visual */
.landmark-box {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 6px;
    font-size: 11px;
}

.landmark-icon {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.landmark-content strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 1px;
}

.landmark-content span {
    color: var(--text-secondary);
}

/* Controles de Navegación */
.navigation-controls {
    display: flex;
    gap: 8px;
    padding: 0 16px 8px 16px;
}

.btn {
    flex: 1;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--brand-fuchsia);
    border-color: var(--brand-fuchsia);
    color: var(--bg-white);
}

.btn-primary:hover {
    background-color: var(--brand-fuchsia-hover);
    border-color: var(--brand-fuchsia-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-white);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-light);
    border-color: #D1D5DB;
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

.progress-wrapper {
    height: 3px;
    background-color: var(--bg-light);
    margin: 0 16px 8px 16px;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--brand-fuchsia);
    transition: width 0.4s ease;
}

/* Lista de Pasos Lateral */
.steps-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 8px 16px;
}

.steps-nav::-webkit-scrollbar {
    width: 4px;
}

.steps-nav::-webkit-scrollbar-track {
    background: transparent;
}

.steps-nav::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.steps-nav h3 {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.steps-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.steps-nav li {
    padding: 4px 8px;
    border-radius: 4px;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.steps-nav li:hover {
    background-color: var(--bg-white);
    border-color: #C4B5FD; /* Resalte suave */
    transform: translateX(2px);
}

.steps-nav li.active {
    background-color: var(--bg-white);
    border-color: var(--brand-fuchsia);
    color: var(--brand-fuchsia);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.01);
}

.step-num-icon {
    width: 15px;
    height: 15px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: bold;
    flex-shrink: 0;
}

.active .step-num-icon {
    background-color: var(--brand-fuchsia);
    border-color: var(--brand-fuchsia);
    color: var(--bg-white);
}

/* Footer (Deprecated/Removed to maximize space) */
.panel-footer {
    display: none;
}

/* Cabecera Flex Row */
.header-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.header-title-box {
    flex: 1;
}

.brand-logo-wrapper {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-logo {
    height: 38px;
    max-width: 90px;
    object-fit: contain;
}

.institutional-utilities {
    padding: 6px 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-light);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.utility-row {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.utility-row-bottom {
    display: flex;
    width: 100%;
}

.utility-link, .utility-link-full {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 8px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.utility-link {
    flex: 1;
}

.utility-link-full {
    width: 100%;
    background-color: var(--bg-white);
    border-color: var(--border-color);
}

.utility-link:hover, .utility-link-full:hover {
    background-color: var(--bg-light);
    border-color: var(--text-muted);
    color: var(--brand-fuchsia);
}


/* =============================================================
   ÁREA DE NAVEGACIÓN Y MAPA (Main)
   ============================================================= */
.map-viewport {
    flex: 1;
    position: relative;
    height: 100%;
    background-color: #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Controles de Utilidad Flotantes */
.map-overlay-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 15;
    display: flex;
    gap: 8px;
}

.map-btn {
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 9px 14px;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.2s ease;
}

.map-btn:hover {
    background-color: var(--bg-light);
    border-color: var(--text-muted);
}


/* Contenedor del Mapa SVG */
.svg-map-wrapper {
    width: 95%;
    height: 95%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#interactive-svg-map {
    max-width: 100%;
    max-height: 100%;
    /* Transición suave para el paneo/zoom de la cámara */
    transition: viewBox 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}


/* =============================================================
   MICRO-ANIMACIONES Y EFECTOS DEL MAPA SVG
   ============================================================= */

/* Animación de la Flama del Destino */
@keyframes destination-glow {
    0% {
        transform: scale(1);
        opacity: 0.15;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.3;
    }
    100% {
        transform: scale(1);
        opacity: 0.15;
    }
}

.pulse-destination {
    transform-origin: center;
    animation: destination-glow 2.5s infinite ease-in-out;
}

/* Nodos Interactivos del Mapa */
.map-node-circle {
    fill: var(--bg-white);
    stroke: var(--text-muted);
    stroke-width: 1.5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.map-node-circle:hover {
    fill: var(--brand-fuchsia);
    stroke: var(--brand-fuchsia);
    r: 8px;
}

.map-node-circle.active {
    fill: var(--brand-fuchsia);
    stroke: var(--brand-fuchsia);
    stroke-width: 2.5px;
    r: 9px;
}

/* Texto de Nodos */
.map-node-text {
    font-family: var(--font-main);
    font-size: 8px;
    font-weight: 700;
    fill: var(--text-secondary);
    pointer-events: none;
    transition: fill 0.3s ease;
}

.map-node-text.active {
    fill: var(--brand-fuchsia);
}


.paradero-hover {
    transition: all 0.3s ease;
}

.paradero-hover:hover circle:nth-child(2) {
    fill: #2563EB;
    r: 10.5px;
}

.paradero-hover:hover rect {
    stroke: #2563EB;
    fill: #EFF6FF;
}

.paradero-hover:hover text {
    fill: #2563EB;
}

.streetview-inline-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 3px 6px;
    background-color: rgba(59, 130, 246, 0.08);
    color: #2563EB;
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
}

.streetview-inline-btn:hover {
    background-color: #2563EB;
    color: #FFFFFF;
    border-color: #2563EB;
}


/* =============================================================
   ADAPTACIÓN MÓVIL Y RESPONSIVIDAD
   ============================================================= */

@media (max-width: 1024px) {
    :root {
        --panel-width: 320px;
    }
}

@media (max-width: 768px) {
    body {
        overflow: hidden;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }

    .app-container {
        flex-direction: column-reverse;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        width: 100vw;
        overflow: hidden;
        position: relative;
    }
    
    /* El panel de control se ajusta a su contenido ocupando como máximo el 52% de la pantalla */
    .control-panel {
        width: 100%;
        height: auto;
        max-height: 52vh;
        max-height: calc(var(--vh, 1vh) * 52);
        flex-shrink: 0;
        border-right: none;
        border-top: 1px solid var(--border-color);
        background-color: var(--bg-sidebar);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        z-index: 10;
    }
    
    /* El mapa ocupa dinámicamente todo el espacio restante de la pantalla */
    .map-viewport {
        flex: 1;
        height: auto;
        padding-top: 48px; /* Espacio para la cabecera flotante */
        position: relative;
        background-color: #F3F4F6;
        width: 100%;
        overflow: hidden;
    }
    
    /* Cabecera flotante en la parte superior sobre el mapa */
    .panel-header {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 48px;
        background-color: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        border-bottom: 1px solid var(--border-color);
        border-top: none;
        z-index: 100;
        display: flex !important;
        align-items: center;
        padding: 0 16px;
    }
    
    .header-main-row {
        width: 100%;
        margin-bottom: 0 !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    
    .header-title-box {
        flex: 1;
    }
    
    .panel-header h1 {
        font-size: 13.5px !important;
        font-weight: 700;
        letter-spacing: -0.2px;
        color: var(--text-primary);
    }
    
    .brand-logo-wrapper {
        display: flex;
        align-items: center;
    }
    
    .brand-logo {
        height: 28px !important;
        max-width: 80px;
        object-fit: contain;
    }
    
    .panel-header p {
        display: none !important;
    }
    
    /* Ocultamos listado de pasos lateral en móviles */
    .steps-nav {
        display: none !important;
    }
    
    /* Tarjeta de instrucciones: toma su tamaño natural sin espacio extra, y se reduce con scroll si es necesario */
    .instruction-card {
        margin: 4px 12px; /* Reducido de 6px a 4px */
        padding: 6px 12px; /* Reducido de 8px a 6px */
        border-radius: 8px;
        background-color: var(--bg-light);
        border: 1px solid var(--border-color);
        flex: 0 1 auto; /* No forzar crecimiento, solo tomar altura natural, encogiendo si choca con max-height */
        min-height: 0; /* Permite al flex encoger el contenedor */
        overflow-y: auto; /* Scroll vertical interno si el texto es muy largo */
    }
    
    .card-header {
        margin-bottom: 3px;
    }
    
    .step-badge {
        font-size: 8px;
        padding: 2px 6px;
    }
    
    .step-meta {
        gap: 6px;
        margin-bottom: 3px;
    }
    
    .direction-badge {
        width: 20px;
        height: 20px;
        font-size: 9px;
        border-radius: 4px;
    }
    
    .step-title {
        font-size: 13px;
    }
    
    .step-desc {
        font-size: 11px;
        line-height: 1.3;
    }
    
    .landmark-box {
        margin-top: 3px;
        padding-top: 3px;
        font-size: 9.5px;
        gap: 4px;
    }
    
    .landmark-icon {
        font-size: 10px;
        margin-top: 0px;
    }
    
    .landmark-content strong {
        margin-bottom: 0px;
    }
    
    .navigation-controls {
        padding: 2px 12px 4px 12px; /* Reducido de 4px a 2px */
        gap: 6px;
        flex-shrink: 0;
    }
    
    .btn {
        padding: 5px 8px;
        font-size: 10.5px;
        border-radius: 5px;
    }
    
    .progress-wrapper {
        margin: 0 12px 4px 12px; /* Reducido de 6px a 4px */
        flex-shrink: 0;
    }
    
    .svg-map-wrapper {
        width: 98%;
        height: 98%;
    }
    
    /* Alineación de 3 utilidades en una sola fila horizontal al pie de la pantalla */
    .institutional-utilities {
        padding: 4px 12px 4px 12px; /* Reducido de 6px a 4px */
        flex-direction: row;
        gap: 6px;
        border-top: 1px solid var(--border-color);
        background-color: var(--bg-light);
        flex-shrink: 0; /* Evita que se encoja */
    }
    
    .utility-row, .utility-row-bottom {
        display: contents !important;
    }
    
    .utility-link, .utility-link-full {
        flex: 1;
        padding: 6px 2px;
        font-size: 9.5px;
        border-radius: 5px;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        justify-content: center;
        height: 28px;
    }
    
    .hide-mobile {
        display: none !important;
    }
    
    /* Controles flotantes en el mapa más discretos en móviles */
    .map-overlay-controls {
        top: 54px; /* Un poco más abajo de la cabecera flotante */
        right: 10px;
        gap: 4px;
    }
    
    .map-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    /* Restringimos altura máxima de la imagen del modal en móviles */
    .modal-image {
        max-height: 180px;
        object-fit: cover;
    }
    
    .modal-card {
        width: 92%;
        max-width: 380px;
    }
    
    .modal-body {
        padding: 12px;
        gap: 6px;
    }
    
    .modal-caption {
        font-size: 9.5px;
    }
    
    .modal-footer-btn {
        padding: 6px 12px;
    }
}

/* =============================================================
   MODAL POPUP: REFERENCIA VISUAL PARADERO 38
   ============================================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 580px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i {
    color: #3B82F6;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--brand-fuchsia);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    object-fit: cover;
}

.modal-caption {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.4;
    font-style: italic;
}

.modal-footer-btn {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-light);
    display: flex;
    justify-content: flex-end;
}

.modal-footer-btn .btn {
    flex: none;
    padding: 8px 16px;
    background-color: #3B82F6;
    border-color: #3B82F6;
}

.modal-footer-btn .btn:hover {
    background-color: #2563EB;
    border-color: #2563EB;
}
