/* ============================================
   MAPA HISTÓRICO ANDALUCÍA — estilos autocontenidos
   ============================================ */

/* ============================================
   TÍTULOS Y SUBTÍTULOS
   ============================================ */
.chart_title_election {
    font-family: "Encode Sans", sans-serif;
    text-align: left;
    color: black;
    font-size: 22px;
    font-weight: 700;
    max-width: 643px;
    margin-bottom: 10px;
    line-height: 25px;
}

.chart_subtitle_election {
    font-size: 14px;
    text-align: left;
    font-family: "Encode Sans", sans-serif;
    line-height: 20px;
    color: #181818;
    max-width: 643px;
    margin-bottom: 15px;
}

/* ============================================
   TOOLTIP
   ============================================ */
.tooltip-election {
    position: absolute;
    z-index: 2000; /* por encima del slider (10), buscador (20) y su dropdown (1000) */
    visibility: hidden;
    opacity: 0;
    color: black;
    padding: 8px;
    background-color: white;
    border-radius: 0px;
    font-size: 12px;
    pointer-events: none;
    font-family: "Encode Sans", sans-serif;
    box-shadow: 0 2px 2px 0 #ccc;
    border: 1px solid #ccc;
    margin-left: 2px;
    line-height: 1.5;
}

/* ============================================
   CONTENEDORES DEL MAPA
   ============================================ */
#wrapper-mapa-election-ccaa {
    container-type: inline-size;
}

#div-containers-mapa-election-ccaa {
    display: flex;
    flex-direction: row;
}

#container-mapa-election-ccaa {
    width: 100%;
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

#map-svg-wrapper {
    position: relative;
    width: 100%;
}

/* ============================================
   BOTONES DE ZOOM
   ============================================ */
#container-zoom-buttons {
    display: flex;
    flex-direction: column;
    position: absolute;
    gap: 5px;
    bottom: 10px;
    left: calc(100% - 35px);
    z-index: 3;
    height: fit-content;
}

#container-zoom-buttons button {
    width: 35px;
    height: 35px;
    background-color: #ffffff;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "Encode Sans", sans-serif;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
    outline: none;
    border: 0;
    box-sizing: border-box;
    cursor: pointer;
    font-size: 25px;
    color: #555555 !important;
    padding: 0;
}

#container-zoom-buttons button img {
    width: 25px;
}

#container-zoom-buttons button:focus {
    outline: none;
}

#container-zoom-buttons button {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* ============================================
   LABELS DE MUNICIPIO (sobre el mapa)
   ============================================ */
.labels-mapa-election-ccaa {
    font-family: "Encode Sans", sans-serif;
    pointer-events: none;
    fill: #000000;
    stroke: none;
    font-weight: 400;
    font-size: 11px;
}

.shadow-mapa-election-ccaa {
    font-family: "Encode Sans", sans-serif;
    pointer-events: none;
    fill: black;
    stroke: white;
    stroke-width: 3px;
    opacity: 0.8;
    font-size: 11px;
}

/* ============================================
   LEYENDA DE PARTIDOS
   ============================================ */
#legend-grupos-partidos {
    display: flex;
    flex-wrap: wrap;
    font-family: "Encode Sans", sans-serif;
    font-size: 12px;
    justify-content: center;
    margin: 10px 0px 10px 0px;
    gap: 2px;
    max-width: 350px;
}

/* ============================================
   BUSCADOR DE MUNICIPIOS
   ============================================ */
.container-buscador-ciudades-fecha {
    position: absolute;
    right: 5px;
    top: 5px;
    z-index: 20; /* por encima del slider (z-index: 10) para que el dropdown no quede tapado */
}

.search-ciudades-contenedor {
    position: relative;
}

.search-ciudades-contenedor input {
    width: 100%;
    padding-left: 40px;
    border: 1px solid #d9d9d9;
    height: 35px;
    padding: 10px 10px 10px 40px;
    font-family: "Encode Sans", sans-serif;
    font-size: 14px;
    background-color: #ffffff;
    color: rgba(0, 0, 0, 0.75);
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    border-radius: 5px;
}

.input-icon-wrapper {
    position: relative;
    width: 230px;
}

.input-icon-wrapper svg {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    color: rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

#suggestions-search-results-grafico {
    background-color: rgb(255, 255, 255, 1);
    border-radius: 4px;
    list-style: none;
    margin: 0;
    padding: 0px 5px;
    position: absolute;
    right: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 250px;
    font-size: 14px;
    width: 230px;
    font-family: "Encode Sans", sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#suggestions-search-results-grafico li {
    border-bottom: 1px solid #c5c5c5;
    vertical-align: middle;
    align-items: center;
    text-align: left;
    height: 30px;
    line-height: 30px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   SLIDER OVERLAY (top-left)
   ============================================ */
#slider-historico-container {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d9d9d9;
    border-radius: 5px;
    padding: 10px 14px 6px 14px;
    width: 400px;
    max-width: calc(100% - 260px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-family: "Encode Sans", sans-serif;
}

#slider-historico-wrapper {
    position: relative;
    padding: 0 8px;
}

#slider-historico {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    background: #d9d9d9;
    border-radius: 2px;
    outline: none;
    margin: 0 0 2px 0;
    cursor: pointer;
}

#slider-historico::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #181818;
    border: 2px solid white;
    box-shadow: 0 0 0 1px #181818;
    cursor: pointer;
}

#slider-historico::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #181818;
    border: 2px solid white;
    box-shadow: 0 0 0 1px #181818;
    cursor: pointer;
}

#slider-historico::-moz-range-track {
    height: 3px;
    background: #d9d9d9;
    border-radius: 2px;
}

#slider-historico-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0;
    margin-top: 2px;
}

.slider-tick {
    background: none;
    border: none;
    padding: 2px 0;
    cursor: pointer;
    font-family: "Encode Sans", sans-serif;
    font-size: 11px;
    color: #6b6b6b;
    min-width: 26px;
    text-align: center;
    transition: color 0.12s, font-weight 0.12s;
    line-height: 1.2;
}

.slider-tick:hover {
    color: #181818;
}

.slider-tick.active {
    color: #181818;
    font-weight: 700;
}

/* ============================================
   LEYENDA OVERLAY (bottom-left)
   ============================================ */
#legend-overlay-container {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #d9d9d9;
    border-radius: 5px;
    padding: 6px 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    max-width: calc(100% - 60px);
}

#legend-overlay-container #legend-grupos-partidos {
    margin: 0;
    max-width: none;
    justify-content: center;
    gap: 4px;
}

/* ============================================
   MÓVIL: todo apilado en columna
   Orden: Buscador → Slider → Mapa → Leyenda
   ============================================ */
@media (max-width: 700px) {
    #container-mapa-election-ccaa {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 0;
        gap: 10px;
    }

    /* Hacer estáticos los overlays */
    .container-buscador-ciudades-fecha,
    #slider-historico-container,
    #legend-overlay-container {
        position: static;
        width: 100%;
        max-width: none;
    }

    /* Orden vertical */
    .container-buscador-ciudades-fecha { order: 1; }
    #slider-historico-container { order: 2; margin: 0; }
    #map-svg-wrapper { order: 3; }
    #legend-overlay-container { order: 4; }

    /* Buscador a ancho completo */
    .input-icon-wrapper {
        width: 100% !important;
    }

    #suggestions-search-results-grafico {
        width: 100% !important;
    }

    /* Input más grande para evitar zoom automático en iOS */
    .search-ciudades-contenedor input {
        font-size: 16px;
    }

    /* Slider en móvil */
    #slider-historico-container {
        border-radius: 5px;
    }

    .slider-tick {
        font-size: 10px;
        min-width: 20px;
    }

    /* Leyenda limpia al pie del mapa */
    #legend-overlay-container {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
    }

    /* Zoom buttons anclados al SVG (dentro del wrapper) */
    #container-zoom-buttons {
        bottom: 5px;
        right: 5px;
        left: auto;
    }
}
