/* ============================================================
   eVoost Maps — Frontend del mapa (iframe standalone)
   Colores de marca inyectados como variables CSS por el template.
   ============================================================ */

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

:root {
    --evm-primary: #163832;
    --evm-accent: #c5a689;
    --evm-white: #ffffff;
    --evm-light: #f5f3f0;
    --evm-dark: #0d211d;
    --evm-font: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --evm-shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.15);
    --evm-shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.25);
    --evm-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--evm-font);
    background: var(--evm-primary);
}

#evm-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Controles de zoom de MapLibre bajo el panel de categorías */
.maplibregl-ctrl-top-right {
    top: 90px;
}

/* ============================================================
   PANEL SUPERIOR — CATEGORÍAS
   ============================================================ */
.evm-category-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    background: var(--evm-primary);
    z-index: 10;
    box-shadow: var(--evm-shadow-medium);
}

.evm-category-btn {
    flex: 1;
    padding: 1.25rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--evm-primary);
    color: var(--evm-white);
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: var(--evm-transition);
    font-family: var(--evm-font);
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    outline: none;
}

.evm-category-btn:last-child {
    border-right: none;
}

.evm-category-btn:hover {
    background: var(--evm-dark);
}

.evm-category-btn.active {
    background: var(--evm-accent);
    color: var(--evm-primary);
}

.evm-category-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: var(--evm-transition);
}

/* ============================================================
   SIDEBAR — LISTA DE POIS
   ============================================================ */
.evm-sidebar {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 380px;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 16px;
    box-shadow: var(--evm-shadow-medium);
    background: var(--evm-white);
    transition: var(--evm-transition), transform 0.3s ease, opacity 0.3s ease;
}

.evm-sidebar.collapsed-desktop {
    transform: translateY(-50%) translateX(-420px);
    opacity: 0;
    pointer-events: none;
}

.evm-sidebar::-webkit-scrollbar {
    width: 6px;
}

.evm-sidebar::-webkit-scrollbar-track {
    background: var(--evm-light);
    border-radius: 3px;
}

.evm-sidebar::-webkit-scrollbar-thumb {
    background: var(--evm-accent);
    border-radius: 3px;
}

.evm-sidebar-header {
    position: sticky;
    top: 0;
    background: var(--evm-primary);
    color: var(--evm-white);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 5;
}

.evm-sidebar-header svg {
    width: 20px;
    height: 20px;
    fill: var(--evm-accent);
    flex-shrink: 0;
}

.evm-sidebar-header h3 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.evm-sidebar-loading {
    padding: 1.5rem 1.25rem;
    font-size: 0.8rem;
    color: var(--evm-primary);
    opacity: 0.7;
    text-align: center;
}

/* Botón colapsar sidebar (desktop) */
.evm-sidebar-collapse-btn {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9;
    background: var(--evm-white);
    color: var(--evm-primary);
    border: none;
    border-radius: 0 12px 12px 0;
    width: 36px;
    height: 80px;
    cursor: pointer;
    box-shadow: var(--evm-shadow-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--evm-transition);
    opacity: 0;
    pointer-events: none;
}

.evm-sidebar-collapse-btn.visible {
    opacity: 1;
    pointer-events: auto;
    left: 0;
}

.evm-sidebar-collapse-btn:hover {
    background: var(--evm-accent);
    width: 44px;
}

.evm-sidebar-collapse-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

.evm-sidebar-collapse-btn.rotated svg {
    transform: rotate(180deg);
}

/* Cards de POI */
.evm-poi-card {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--evm-white);
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: var(--evm-transition);
    width: 100%;
    text-align: left;
    font-family: var(--evm-font);
    outline: none;
    position: relative;
    animation: evmFadeIn 0.3s ease forwards;
}

.evm-poi-card:nth-child(2) { animation-delay: 0.05s; }
.evm-poi-card:nth-child(3) { animation-delay: 0.1s; }
.evm-poi-card:nth-child(4) { animation-delay: 0.15s; }
.evm-poi-card:nth-child(5) { animation-delay: 0.2s; }
.evm-poi-card:nth-child(6) { animation-delay: 0.25s; }
.evm-poi-card:nth-child(7) { animation-delay: 0.3s; }
.evm-poi-card:nth-child(8) { animation-delay: 0.35s; }

.evm-poi-card:hover {
    background: var(--evm-light);
}

.evm-poi-card.active {
    background: var(--evm-primary);
    color: var(--evm-white);
}

.evm-poi-card.dimmed {
    opacity: 0.5;
}

.evm-poi-badge {
    display: inline-block;
    background: var(--evm-accent);
    color: var(--evm-primary);
    font-size: 0.55rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.evm-poi-info {
    flex: 1;
    min-width: 0;
}

.evm-poi-name-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.evm-poi-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--evm-primary);
    transition: var(--evm-transition);
}

.evm-poi-card.active .evm-poi-name {
    color: var(--evm-white);
}

.evm-poi-mode {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.65rem;
    color: var(--evm-accent);
    background: color-mix(in srgb, var(--evm-accent) 15%, transparent);
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    font-weight: 500;
}

.evm-poi-card.active .evm-poi-mode {
    background: color-mix(in srgb, var(--evm-accent) 20%, transparent);
    color: var(--evm-accent);
}

.evm-poi-mode svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.evm-poi-time-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.evm-poi-time {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--evm-primary);
    line-height: 1;
    transition: var(--evm-transition);
}

.evm-poi-card.active .evm-poi-time {
    color: var(--evm-accent);
}

.evm-poi-time-unit {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: rgba(0, 0, 0, 0.5);
    font-weight: 500;
}

.evm-poi-card.active .evm-poi-time-unit {
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================================
   BOTÓN CERRAR RUTA
   ============================================================ */
.evm-close-route-btn {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    background: var(--evm-primary);
    color: var(--evm-white);
    border: none;
    border-radius: 50px;
    padding: 0.75rem 1.5rem;
    font-family: var(--evm-font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--evm-shadow-medium);
    transition: var(--evm-transition);
}

.evm-close-route-btn:hover {
    background: var(--evm-accent);
    color: var(--evm-primary);
}

.evm-close-route-btn.visible {
    display: flex;
}

.evm-close-route-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ============================================================
   CONTROLES MÓVIL
   ============================================================ */
.evm-mobile-menu-toggle {
    display: none;
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: var(--evm-white);
    color: var(--evm-primary);
    border: none;
    border-radius: 50px;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    font-family: var(--evm-font);
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: var(--evm-shadow-medium);
    align-items: center;
    gap: 0.5rem;
}

.evm-mobile-menu-toggle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.evm-sidebar-toggle {
    display: none;
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 15;
    background: var(--evm-primary);
    color: var(--evm-white);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    box-shadow: var(--evm-shadow-medium);
    align-items: center;
    justify-content: center;
    transition: var(--evm-transition);
}

.evm-sidebar-toggle:hover {
    background: var(--evm-accent);
    color: var(--evm-primary);
}

.evm-sidebar-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

.evm-sidebar-toggle.rotated svg {
    transform: rotate(180deg);
}

.evm-active-route-indicator {
    display: none;
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 14;
    background: var(--evm-white);
    color: var(--evm-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    max-width: 80%;
    box-shadow: var(--evm-shadow-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.evm-active-route-indicator.visible {
    display: block;
}

/* ============================================================
   MARCADORES Y TOOLTIPS
   ============================================================ */
.evm-marker {
    cursor: pointer;
}

.evm-marker svg {
    display: block;
}

.maplibregl-popup-content {
    font-family: var(--evm-font);
    background: var(--evm-white);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    box-shadow: var(--evm-shadow-medium);
    max-width: 200px;
}

.maplibregl-popup-tip {
    display: none;
}

.evm-tooltip-name {
    font-weight: 600;
    color: var(--evm-primary);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.evm-tooltip-time {
    font-size: 0.75rem;
    color: var(--evm-accent);
}

/* Atribución mínima (obligatoria por licencia ODbL) */
.evm-attribution {
    position: absolute;
    bottom: 3px;
    right: 6px;
    z-index: 8;
    font-size: 10px;
    line-height: 1.4;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.55);
    opacity: 0.75;
    transition: opacity 0.2s ease;
    pointer-events: auto;
}

.evm-attribution:hover {
    opacity: 1;
}

.evm-attribution a {
    color: #333;
    text-decoration: none;
}

.evm-attribution a:hover {
    text-decoration: underline;
}

/* ============================================================
   RESPONSIVE — TABLETS
   ============================================================ */
@media screen and (max-width: 1200px) {
    .evm-sidebar {
        width: 340px;
        left: 20px;
    }

    .evm-category-btn {
        font-size: 0.6rem;
        padding: 1rem 0.4rem;
    }

    .evm-category-btn svg {
        width: 20px;
        height: 20px;
    }
}

@media screen and (max-width: 900px) {
    .evm-category-btn span {
        display: none;
    }

    .evm-category-btn {
        padding: 1rem;
    }

    .evm-category-btn svg {
        width: 24px;
        height: 24px;
    }

    .evm-sidebar {
        width: 300px;
    }
}

/* ============================================================
   RESPONSIVE — MÓVILES
   ============================================================ */
@media screen and (max-width: 768px) {
    .evm-mobile-menu-toggle {
        display: flex;
    }

    .evm-sidebar-collapse-btn {
        display: none;
    }

    .maplibregl-ctrl-top-right {
        top: 70px;
    }

    .evm-category-panel {
        display: none;
        position: absolute;
        top: 60px;
        left: 10px;
        right: 10px;
        width: auto;
        flex-direction: column;
        border-radius: 12px;
        overflow: hidden;
        z-index: 25;
    }

    .evm-category-panel.show {
        display: flex;
    }

    .evm-category-btn {
        flex-direction: row;
        justify-content: flex-start;
        gap: 1rem;
        padding: 1rem 1.25rem;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .evm-category-btn span {
        display: block;
        font-size: 0.8rem;
    }

    .evm-category-btn:last-child {
        border-bottom: none;
    }

    .evm-sidebar-toggle {
        display: flex;
    }

    .evm-sidebar {
        width: calc(100% - 20px);
        left: 10px;
        top: auto;
        bottom: 80px;
        transform: none;
        max-height: 45vh;
        border-radius: 12px;
        transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    }

    .evm-sidebar.collapsed {
        opacity: 0;
        visibility: hidden;
        transform: translateY(20px);
        pointer-events: none;
    }

    .evm-close-route-btn {
        bottom: auto;
        top: 70px;
        right: 10px;
        left: auto;
        transform: none;
        padding: 0.6rem 1rem;
        font-size: 0.7rem;
    }
}

@media screen and (max-width: 480px) {
    .evm-sidebar {
        max-height: 40vh;
        bottom: 85px;
    }

    .evm-poi-card {
        padding: 0.85rem 1rem;
    }

    .evm-poi-name {
        font-size: 0.8rem;
    }

    .evm-poi-time {
        font-size: 1.25rem;
    }
}

@keyframes evmFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
