/* ==========================================================================
   SEDES - Grael
   Mapa Leaflet con panel de búsqueda y lista de sedes (desktop y móvil).
   ========================================================================== */

.sec-sedes {
    padding: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* --- Contenedor del mapa (altura completa menos header) --- */
.mapa-sedes {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    height: calc(100vh - 72px);
}

.mapa-sedes__mapa {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 300px;
    background: #e8e8e8;
    z-index: 0;
}

/* Envuelve el panel para centrarlo (max 1300px) en pantallas grandes */
.mapa-sedes__panel-wrap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 1300px;
    margin: 0 auto;
    width: 100%;
    pointer-events: none;
    z-index: 5;
}

.mapa-sedes__panel-wrap > * {
    pointer-events: auto;
}

/* Panel flotante: búsqueda + lista de sedes */
.mapa-sedes__panel {
    position: absolute;
    top: 2rem;
    left: 2rem;
    bottom: 2rem;
    z-index: 10;
    width: 340px;
    max-width: calc(100% - 4rem);
    max-height: calc(100% - 4rem);
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
}

@media (min-width: 900px) {
    .mapa-sedes__panel {
        width: 380px;
        left: 2rem;
        top: 2rem;
        bottom: 2rem;
        max-height: calc(100% - 4rem);
        max-width: none;
    }
}

/* --- Vista móvil: buscador fijo arriba, lista tipo bottom sheet abajo --- */
@media (max-width: 899px) {
    .mapa-sedes__panel {
        position: static;
        width: 100%;
        max-width: none;
        max-height: none;
        flex-direction: column;
        gap: 0;
        padding: 0;
    }

    /* Buscador fijo bajo el header (72px) */
    .mapa-sedes__bloque-busqueda {
        position: fixed;
        top: calc(72px + env(safe-area-inset-top, 0));
        left: 0;
        right: 0;
        z-index: 20;
        margin: 1rem 1rem 0;
        border-radius: 0 0 1rem 1rem;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    }

    .mapa-sedes__bloque-busqueda .sede-search {
        padding: 0.8rem 1rem;
    }

    /* Mapa a pantalla completa */
    .mapa-sedes__mapa {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    .mapa-sedes__panel-wrap {
        display: flex;
        flex-direction: column;
        pointer-events: none;
    }

    .mapa-sedes__panel-wrap > * {
        pointer-events: auto;
    }

    /* Lista de sedes fija abajo (bottom sheet, max 50vh) */
    .mapa-sedes__bloque-resultados {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 20;
        max-height: 50vh;
        min-height: 200px;
        border-radius: 1rem 1rem 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
        flex: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mapa-sedes__bloque-resultados .sede-panel__titulo {
        padding: 1rem 1rem;
        flex-shrink: 0;
    }

    .mapa-sedes__bloque-resultados .sede-lista {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 1rem 1rem;
    }
}

/* --- Bloque búsqueda: caja blanca con sombra --- */
.mapa-sedes__bloque-busqueda {
    flex-shrink: 0;
    background: var(--color-blanco);
    border-radius: 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.sede-search {
    position: relative;
    padding: 1rem 1.2rem;
}

.sede-search__icono {
    position: absolute;
    left: 1.6rem;
    top: 50%;
    transform: translateY(-50%);
    color: #035d96;
    opacity: 0.7;
    pointer-events: none;
}

.sede-search__input {
    width: 100%;
    padding: 1rem 1.2rem 1rem 3.6rem;
    font-family: "Poppins", sans-serif;
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--color-negro);
    border: 1px solid #e8e8e8;
    border-radius: 0.8rem;
    outline: none;
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.sede-search__input::placeholder {
    color: #546f8b;
}

.sede-search__input:focus {
    border-color: var(--color-celeste);
    box-shadow: 0 0 0 3px rgba(69, 166, 209, 0.12);
    background: var(--color-blanco);
}

/* --- Bloque resultados: título "Sedes" + lista scrolleable --- */
.mapa-sedes__bloque-resultados {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-blanco);
    border-radius: 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.sede-panel__titulo {
    margin: 0;
    padding: 2rem 1.2rem 1.2rem 2rem;
    font-size: 2.07rem; /* 1.8rem + 15% */
    font-weight: 700;
    line-height: 1;
    color: #035d96;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sede-panel__titulo-icono {
    flex-shrink: 0;
    display: block;
    object-fit: contain;
    vertical-align: middle;
}

/* Lista de tarjetas de sedes (scroll) */
.sede-lista {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem 1.2rem;
    min-height: 0;
}

/* Tarjeta de cada sede (estilo tipo card-servicios) */
.sede-tarjeta {
    padding: 1.4rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: -2px 2px 12px 0 rgba(0, 0, 0, 0.08);
}

.sede-tarjeta:last-child {
    margin-bottom: 0;
}

.sede-tarjeta:hover {
    background: var(--color-blanco);
    border-color: var(--color-celeste);
    box-shadow: -2px 4px 15px 0 rgba(3, 93, 150, 0.12);
}

.sede-tarjeta--activo {
    background: var(--color-blanco);
    border-color: var(--color-celeste);
    box-shadow: -2px 4px 15px 0 rgba(3, 93, 150, 0.2);
}

.sede-tarjeta__titulo-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.sede-tarjeta__titulo-wrap .sede-tarjeta__titulo {
    margin: 0;
}

.sede-tarjeta__titulo {
    margin: 0 0 0.8rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #035d96;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}


/* Fila de dato: icono + texto (dirección, horario, teléfono) */
.sede-tarjeta__fila {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.sede-tarjeta__fila:last-of-type {
    margin-bottom: 0;
}

.sede-tarjeta__icono-wrap {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #035d96;
}

.sede-tarjeta__icono-campo {
    width: 2rem;
    height: 2rem;
    stroke-width: 2.5;
}

.sede-tarjeta__texto {
    font-size: 1.5rem;
    color: var(--color-parrafo);
    line-height: 1.4;
    flex: 1;
    min-width: 0;
}

.sede-tarjeta__campo {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    color: var(--color-parrafo);
    line-height: 1.4;
}

.sede-tarjeta__etiqueta {
    font-weight: 600;
    color: #035d96;
    margin-right: 0.25rem;
}

.sede-tarjeta__link {
    font-size: 1.5rem;
    color: var(--color-parrafo);
    line-height: 1.4;
    text-decoration: none;
    font-weight: 400;
    flex: 1;
    min-width: 0;
}

.sede-tarjeta__link:hover {
    color: var(--color-parrafo);
}

/* Contenedor del botón "Cómo llegar" y distancia */
.sede-tarjeta__llegar-wrap {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.sede-tarjeta__distancia {
    font-size: 1.4rem;
    color: var(--color-parrafo);
    font-weight: 500;
    flex-shrink: 0;
}

/* Botón "Cómo llegar" (estilo Grael: celeste/principal) */
.sede-tarjeta__btn-llegar {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0.8rem 1.4rem;
    font-family: "Poppins", sans-serif;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--color-blanco);
    background-color: var(--color-celeste);
    border-radius: 2rem;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
}

.sede-tarjeta__btn-llegar:hover {
    background-color: #15467A;
}

.sede-tarjeta__btn-llegar svg {
    flex-shrink: 0;
    transform: scale(1.2);
}

/* Popup del marcador en el mapa (línea gráfica Grael) */
.sede-marker-popup .leaflet-popup-content-wrapper {
    border-radius: 1rem;
    font-family: "Poppins", sans-serif;
    box-shadow: -2px 4px 20px rgba(3, 93, 150, 0.2);
    border: 1px solid rgba(69, 166, 209, 0.25);
}

.sede-marker-popup .leaflet-popup-content {
    margin: 1rem 1.2rem;
    font-size: 1.3rem;
    color: var(--color-parrafo);
}

.sede-marker-popup .leaflet-popup-tip {
    background: var(--color-blanco);
}

.sede-marker-popup strong {
    color: #035d96;
    font-size: 1.4rem;
}
