/* =====================================================
   CHARTS ALQUILERES DE TEMPORADA - elDiario.es
   Estilo de la casa: tokens --ed-*, base .ed-chart y
   estilos propios bajo .chart-alquileres-temporada.
   ===================================================== */

/* Tokens de color y fuente de la casa (sincronizados con shared/colors/paleta.js) */
:root {
    --ed-rojo: #D0021B;
    --ed-negro: #1a1a1a;
    --ed-amarillo: #ECDC19;
    --ed-azul: #4A90E2;
    --ed-gris-500: #939393;   /* ejes, texto suave */
    --ed-gris-300: #c5c5c5;   /* rejilla, bordes */
    --ed-gris-100: #f2f2f2;   /* fondos suaves (hover de paginación) */
    --ed-radio: 4px;          /* radio de bordes en controles */
    --ed-fuente: "Encode Sans", Arial, sans-serif;
}

/* Base universal de la casa: anti-CMS + tipografía. Va en el contenedor del gráfico. */
.ed-chart {
    width: 100%;
    margin: 50px 0px;      /* aire arriba y abajo de toda la pieza respecto al texto del artículo */
    text-align: left;      /* el CMS suele forzar center en el cuerpo del artículo */
    clear: left;
    box-sizing: border-box;
    font-family: var(--ed-fuente);
}
.ed-chart *, .ed-chart *::before, .ed-chart *::after { box-sizing: border-box; }

/* Cabecera de la casa (título estándar en Encode Sans) */
.chart-alquileres-temporada .ed-titulo {
    font-family: var(--ed-fuente);
    text-align: left;
    color: var(--ed-negro);
    font-size: 22px;
    font-weight: 700;
    margin: 30px 0 8px 0;
}

.chart-alquileres-temporada .ed-subtitulo {
    font-family: var(--ed-fuente);
    text-align: left;
    font-size: 14px;
    line-height: 20px;
    color: #181818;
    margin: 0 0 16px 0;
}

.chart-alquileres-temporada .ed-fuente {
    font-family: var(--ed-fuente);
    font-size: 12px;
    color: var(--ed-gris-500);
    margin: 8px 0 0;
    text-align: left;
    padding: 0;
}



/* =====================================================
   GRÁFICO EVOLUCIÓN % TEMPORADA
   ===================================================== */

.chart-alquileres-temporada .grafico-evolucion-temporada text {
    font-size: 13px;
    font-family: var(--ed-fuente);
}

.chart-alquileres-temporada .grafico-evolucion-temporada .eje-horizontal-evolucion path {
    stroke-width: 0;
}

.chart-alquileres-temporada .grafico-evolucion-temporada .eje-horizontal-evolucion text {
    fill: var(--ed-gris-500);
    font-size: 12px;
}

.chart-alquileres-temporada .grafico-evolucion-temporada .eje-horizontal-evolucion line {
    stroke: var(--ed-gris-500);
    stroke-width: 1;
}

.chart-alquileres-temporada .grafico-evolucion-temporada .eje-vertical-evolucion path {
    stroke-width: 0;
}

.chart-alquileres-temporada .grafico-evolucion-temporada .eje-vertical-evolucion line {
    stroke: var(--ed-gris-300);
    stroke-dasharray: 3;
    stroke-width: 0.5;
}

.chart-alquileres-temporada .grafico-evolucion-temporada .eje-vertical-evolucion text {
    fill: var(--ed-gris-500);
    font-size: 12px;
}


/* =====================================================
   GRÁFICO PRECIO EUR/m² TEMPORADA vs LARGA (dumbbell)
   ===================================================== */

.chart-alquileres-temporada .grafico-precio-m2 text {
    font-family: var(--ed-fuente);
}

.chart-alquileres-temporada .grafico-precio-m2 .eje-horizontal-precio path {
    stroke-width: 0;
}

.chart-alquileres-temporada .grafico-precio-m2 .eje-horizontal-precio line {
    stroke: var(--ed-gris-300);
    stroke-width: 1;
    stroke-dasharray: 3;
}

.chart-alquileres-temporada .grafico-precio-m2 .eje-horizontal-precio text {
    fill: var(--ed-gris-500);
    font-size: 12px;
}


/* =====================================================
   GRÁFICO COLUMNAS APILADAS (total de anuncios por mes)
   ===================================================== */

.chart-alquileres-temporada .grafico-columnas-apiladas text {
    font-family: var(--ed-fuente);
}

/* El atenuado del hover entra suave, no de golpe */
.chart-alquileres-temporada .grafico-columnas-apiladas .columna {
    transition: opacity 0.12s;
}

.chart-alquileres-temporada .grafico-columnas-apiladas .eje-horizontal-apiladas path,
.chart-alquileres-temporada .grafico-columnas-apiladas .eje-horizontal-apiladas line {
    stroke-width: 0;
}

.chart-alquileres-temporada .grafico-columnas-apiladas .eje-horizontal-apiladas text {
    fill: var(--ed-gris-500);
    font-size: 12px;
}

.chart-alquileres-temporada .grafico-columnas-apiladas .eje-vertical-apiladas path {
    stroke-width: 0;
}

.chart-alquileres-temporada .grafico-columnas-apiladas .eje-vertical-apiladas line {
    stroke: var(--ed-gris-300);
    stroke-dasharray: 3;
    stroke-width: 0.5;
}

.chart-alquileres-temporada .grafico-columnas-apiladas .eje-vertical-apiladas text {
    fill: var(--ed-gris-500);
    font-size: 12px;
}

/* El contenedor necesita position:relative para anclar el tooltip */
.chart-alquileres-temporada #grafico-columnas-apiladas {
    position: relative;
}

/* Leyenda de color de las dos series */
.chart-alquileres-temporada .leyenda-apiladas {
    display: flex;
    gap: 18px;
    margin: 0 0 6px 0;
    font-family: var(--ed-fuente);
    font-size: 12px;
    color: #444;
}

.chart-alquileres-temporada .leyenda-apiladas .leg-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-alquileres-temporada .leyenda-apiladas .leg-sw {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

/* =====================================================
   GRÁFICO SMALL MULTIPLES (una mini-línea por ciudad)
   ===================================================== */

.chart-alquileres-temporada #grafico-minis {
    position: relative;
}

.chart-alquileres-temporada #grafico-minis .grid-minis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));   /* ~3-4 por fila */
    gap: 14px 16px;
}

@media (max-width: 500px) {
    .chart-alquileres-temporada #grafico-minis .grid-minis {
        grid-template-columns: repeat(auto-fill, minmax(140px, 2fr));
        gap: 3px;
    }
}

.chart-alquileres-temporada #grafico-minis .mini-titulo {
    font-family: var(--ed-fuente);
    font-size: 12px;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1px;
}

.chart-alquileres-temporada #grafico-minis .mini-ult {
    font-family: var(--ed-fuente);
    font-size: 11px;
    font-weight: 700;
    fill: #B8930B;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 2.5px;
}

.chart-alquileres-temporada .btn-vermas {
    display: block;
    margin: 18px auto 4px auto;
    font-family: var(--ed-fuente);
    font-size: 13px;
    font-weight: 600;
    color: #777;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
}

.chart-alquileres-temporada .btn-vermas:hover {
    color: #333;
    text-decoration: underline;
}

/* =====================================================
   GRÁFICO VARIACIÓN en puntos (dot plot con 2 tasas)
   ===================================================== */

.chart-alquileres-temporada .toggle-variacion {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.chart-alquileres-temporada .btn-toggle {
    font-family: var(--ed-fuente);
    font-size: 12px;
    font-weight: 600;
    color: #555;
    background: #fff;
    border: 1px solid #d5d5d5;
    border-radius: 16px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.chart-alquileres-temporada .btn-toggle.activo {
    background: #222;
    color: #fff;
    border-color: #222;
}

.chart-alquileres-temporada .btn-toggle:hover:not(.activo) {
    background: #f2f2f2;
}

.chart-alquileres-temporada .grafico-variacion text {
    font-family: var(--ed-fuente);
}

.chart-alquileres-temporada .grafico-variacion .eje-horizontal-variacion path {
    stroke-width: 0;
}

.chart-alquileres-temporada .grafico-variacion .eje-horizontal-variacion line {
    stroke: var(--ed-gris-300);
    stroke-dasharray: 3;
    stroke-width: 1;
}

.chart-alquileres-temporada .grafico-variacion .eje-horizontal-variacion text {
    fill: var(--ed-gris-500);
    font-size: 12px;
}

.chart-alquileres-temporada .grafico-variacion .linea-cero {
    stroke: #888;
    stroke-width: 1;
}


/* =====================================================
   MAPA NACIONAL (círculos por capital)
   ===================================================== */

.chart-alquileres-temporada #mapa-nacional {
    position: relative;
}

.chart-alquileres-temporada .mapa-scroll {
    overflow-x: auto;
    overflow-y: hidden;
}

.chart-alquileres-temporada .label-mapa {
    font-family: var(--ed-fuente);
    font-size: 11px;
    fill: #333;
    pointer-events: none;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 2.5px;
}

.chart-alquileres-temporada .leyenda-mapa text {
    font-family: var(--ed-fuente);
}


/* =====================================================
   MAPAS DE BARRIOS (Madrid, Barcelona, València)
   ===================================================== */

.chart-alquileres-temporada #mapas-barrios {
    position: relative;
}

.chart-alquileres-temporada .grid-barrios {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    align-items: start;
}

.chart-alquileres-temporada .barrio-titulo {
    font-family: var(--ed-fuente);
    font-weight: 700;
    font-size: 15px;
    color: #222;
    margin-bottom: 6px;
    text-align: center;
}

/* Etiquetas de los barrios (halo blanco para que se lean sobre los círculos) */
.chart-alquileres-temporada .label-barrio {
    font-family: var(--ed-fuente);
    font-size: 11px;
    font-weight: 300;
    fill: #858585;
    pointer-events: none;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 1.5px;
}


/* =====================================================
   ANUNCIOS DE EJEMPLO (tarjetas tipo idealista)
   ===================================================== */

.chart-alquileres-temporada .grid-anuncios {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 260px));
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
}

@media (max-width: 900px) { .chart-alquileres-temporada .grid-anuncios { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .chart-alquileres-temporada .grid-anuncios { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 375px) { .chart-alquileres-temporada .grid-anuncios { grid-template-columns: repeat(1, minmax(0, 230px)); } }

.chart-alquileres-temporada .anuncio {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    font-family: var(--ed-fuente);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.chart-alquileres-temporada .anuncio-ciudad {
    font-size: 17px;
    text-align: center;
    font-weight: 700;
    padding: 8px 0;
    background: var(--ed-azul);
    color: #fff;
}

.chart-alquileres-temporada .anuncio-meta {
    font-size: 12px;
    color: #777;
    padding: 8px 14px 0;
}

.chart-alquileres-temporada .anuncio-texto {
    font-size: 12px;
    line-height: 1.5;
    color: #444;
    padding: 8px 14px 14px;
    /* Nº de líneas antes del "…": súbelo para tarjetas más altas. */
    display: -webkit-box;
    -webkit-line-clamp: 14;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* El trozo resaltado: fondo amarillo temporada */
.chart-alquileres-temporada .anuncio-texto .resalta {
    background: #ECDC1988;
    padding: 0 3px;
    border-radius: 2px;
    font-weight: 600;
    color: #222;
}


/* =====================================================
   TABLA DE CAPITALES (diseño reutilizado de plantillas/d3)
   ===================================================== */

/* Buscador (izquierda) + paginación (derecha) en una fila */
.chart-alquileres-temporada .ed-tabla-controles {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;   /* buscador y paginación SIEMPRE en la misma línea */
    margin: 10px 0 5px 0;
}

.chart-alquileres-temporada .ed-tabla-buscar {
    flex: 0 1 250px; min-width: 90px;   /* se encoge en móvil para no saltar de línea */
    max-width: 100%; height: 35px; padding: 5px 10px;
    border: 1px solid #cecece; border-radius: var(--ed-radio);
    font-family: var(--ed-fuente); font-size: 14px;
    background-color: #fff; color: rgba(0, 0, 0, 0.75);
    text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.chart-alquileres-temporada .ed-tabla-buscar:focus { outline: none; border-color: var(--ed-gris-500); }

.chart-alquileres-temporada .ed-tabla-pag { display: flex; align-items: center; flex: 0 0 auto; }
.chart-alquileres-temporada .ed-tabla-pag .pagination-btn {
    width: 35px; height: 35px; border: 1px solid #cecece; border-radius: var(--ed-radio);
    background-color: #fff; color: rgba(0, 0, 0, 0.75); font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.chart-alquileres-temporada .ed-tabla-pag .pagination-btn:hover:not(:disabled) { background-color: var(--ed-gris-100); }
.chart-alquileres-temporada .ed-tabla-pag .pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chart-alquileres-temporada .ed-tabla-pag .pagination-info {
    font-family: var(--ed-fuente); font-size: 12px; color: rgba(0, 0, 0, 0.75);
    margin: 0 5px; white-space: nowrap;
}

/* Tabla */
.chart-alquileres-temporada .ed-tabla { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.chart-alquileres-temporada .ed-tabla th {
    color: #444; font-weight: 400; font-size: 11px; text-transform: uppercase; vertical-align: bottom;
}
.chart-alquileres-temporada .ed-tabla td,
.chart-alquileres-temporada .ed-tabla th { padding: 6px; border-bottom: 1px solid #ddd; text-align: left; line-height: 14px; }

/* Botón expandir (círculo con + / −) */
.chart-alquileres-temporada .expand-btn {
    display: inline-block; width: 26px; height: 26px; line-height: 24px; font-size: 24px;
    border-radius: 50%; background-color: #fff; border: 1px solid #cecece;
    color: #404040; font-weight: 300; text-align: center; cursor: pointer;
    user-select: none; transition: background 0.2s;
}
.chart-alquileres-temporada .expand-btn:hover { background-color: var(--ed-gris-300); }

/* Fila expandida */
.chart-alquileres-temporada .expanded-row td {
    background-color: #f5f5f5;
    border-top: 2px solid #ddd;
    border-radius: 0 0 5px 5px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Aviso "Desliza para ver el mapa" (solo se crea en móvil desde el JS del mapa nacional) */
.chart-alquileres-temporada .ed-mapa-slide {
    text-align: center;
    font-family: var(--ed-fuente);
    font-size: 12px;
    font-weight: 400;
    color: #555;
    margin: 0 0 8px;
}
