/* ============================================================
   Livelli di accesso dei widget
   ============================================================ */

.box.access-auth {
    border-top: 3px solid #1565c0;
}

.box.access-guest {
    border-top: 3px solid #90a4ae;
}

.private-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e3f2fd;
    color: #0d47a1;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}


/* Il meteo avanzato usa tutta la larghezza della dashboard. */
.meteo-avanzato {
    grid-column: 1 / -1;
}


/* ============================================================
   Situazione meteo corrente
   ============================================================ */

.advanced-current {
    display: grid;
    grid-template-columns:
        minmax(220px, 0.8fr)
        minmax(360px, 1.2fr);
    gap: 28px;
    align-items: center;
}

.advanced-main {
    display: flex;
    align-items: center;
    gap: 20px;
}

.advanced-description {
    font-size: 18px;
    font-weight: 600;
}


/* ============================================================
   Metriche correnti
   ============================================================ */

.weather-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 10px;
}

.weather-metric {
    background: #f4f8fb;
    border: 1px solid #e3edf3;
    border-radius: 8px;
    padding: 10px;
}

.weather-metric span,
.weather-metric strong {
    display: block;
}

.weather-metric span {
    margin-bottom: 4px;
    color: #607d8b;
    font-size: 12px;
}

.weather-metric strong {
    color: #263238;
    font-size: 14px;
}


/* ============================================================
   Titoli delle sezioni meteo
   ============================================================ */

.weather-section-title {
    margin-top: 26px !important;
    padding-bottom: 7px;
    border-bottom: 1px solid #eceff1;
}


/* ============================================================
   Previsioni orarie
   ============================================================ */

.hourly-scroll {
    overflow-x: auto;
    padding-bottom: 8px;
}

.hourly-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(105px, 1fr));
    gap: 8px;
    min-width: 1260px;
}

.weather-hour {
    padding: 11px 7px;
    background: #f4f8fb;
    border-radius: 8px;
    text-align: center;
}

.weather-hour-time {
    font-size: 12px;
    font-weight: 600;
}

.weather-hour-icon {
    margin: 5px 0;
    font-size: 28px;
}

.weather-rain {
    margin-top: 5px;
    color: #1565c0;
    font-size: 12px;
}


/* ============================================================
   Previsioni giornaliere
   ============================================================ */

.advanced-days {
    display: grid;
    grid-template-columns: repeat(5, minmax(190px, 1fr));
    gap: 12px;
}

.advanced-day {
    padding: 13px;
    background: #f8fafb;
    border: 1px solid #e3ebef;
    border-radius: 10px;
}

.advanced-day-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e3ebef;
}

.advanced-day-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 84px;
}

.advanced-day-icon {
    font-size: 34px;
}

.temp-max {
    color: #c62828;
    font-size: 18px;
    font-weight: 700;
}

.temp-min {
    margin-left: 6px;
    color: #1565c0;
    font-weight: 600;
}

.advanced-day-details {
    display: grid;
    gap: 5px;
    color: #546e7a;
    font-size: 12px;
}


/* ============================================================
   Tablet
   ============================================================ */

@media (max-width: 1100px) {
    .advanced-days {
        grid-template-columns: repeat(2, minmax(190px, 1fr));
    }
}


/* ============================================================
   Smartphone
   ============================================================ */

@media (max-width: 750px) {
    .meteo-avanzato {
        grid-column: auto;
    }

    .advanced-current {
        grid-template-columns: 1fr;
    }

    .weather-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .advanced-days {
        grid-template-columns: 1fr;
    }

    .private-badge {
        display: table;
        margin: 6px 0 0;
    }
}


@media (max-width: 420px) {
    .weather-metrics {
        grid-template-columns: 1fr;
    }
}


/* ============================================================
   MERCATO AVANZATO
   ============================================================ */

.mercato-avanzato {
    grid-column: 1 / -1;
}


/* ---------- Selettore ---------- */

.market-selector {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 22px;
    padding: 14px;
    background: #f4f8fb;
    border: 1px solid #e3edf3;
    border-radius: 9px;
}

.market-selector label {
    width: 100%;
    color: #607d8b;
    font-size: 12px;
    font-weight: 600;
}

.market-selector select {
    min-width: 300px;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid #b0bec5;
    border-radius: 6px;
    color: #263238;
    font: inherit;
}

.market-selector select:focus {
    outline: 2px solid #64b5f6;
    border-color: #1565c0;
}

.market-selector button {
    padding: 10px 16px;
    background: #1565c0;
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font: inherit;
}

.market-selector button:hover {
    background: #0d47a1;
}

.market-reset {
    padding: 9px 13px;
    border: 1px solid #b0bec5;
    border-radius: 6px;
    color: #455a64;
    text-decoration: none;
}

.market-reset:hover {
    border-color: #1565c0;
    color: #1565c0;
}


/* ---------- Intestazione strumento ---------- */

.advanced-market-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 18px;
}

.advanced-market-name {
    color: #263238;
    font-size: 26px;
    font-weight: 700;
}

.advanced-market-price {
    text-align: right;
    color: #263238;
    font-size: 28px;
    font-weight: 700;
}

.market-change {
    margin-top: 2px;
    font-size: 15px;
    font-weight: 600;
}

.market-change span {
    color: #78909c;
    font-size: 11px;
    font-weight: 400;
}

.positive {
    color: #2e7d32 !important;
}

.negative {
    color: #c62828 !important;
}


/* ---------- Metriche ---------- */

.advanced-market-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 26px;
}

.advanced-market-metric {
    padding: 11px;
    background: #f8fafb;
    border: 1px solid #e3ebef;
    border-radius: 8px;
}

.advanced-market-metric span,
.advanced-market-metric strong {
    display: block;
}

.advanced-market-metric span {
    margin-bottom: 5px;
    color: #607d8b;
    font-size: 11px;
}

.advanced-market-metric strong {
    color: #263238;
    font-size: 14px;
}


/* ---------- Grafico ---------- */

.chart-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
}

.chart-heading h3 {
    margin-bottom: 2px;
}

.chart-legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
}

.legend-up {
    color: #2e7d32;
}

.legend-down {
    color: #c62828;
}

.candlestick-container {
    width: 100%;
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e3ebef;
    border-radius: 10px;
}

.candlestick-chart {
    display: block;
    width: 100%;
    min-width: 760px;
    height: 480px;
}


/* ---------- Legenda descrittiva ---------- */

.market-explanation {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 13px;
}

.market-explanation > div {
    padding: 10px;
    background: #f8fafb;
    border-radius: 7px;
}

.market-explanation strong,
.market-explanation span {
    display: block;
}

.market-explanation strong {
    color: #37474f;
    font-size: 12px;
}

.market-explanation span {
    margin-top: 3px;
    color: #78909c;
    font-size: 11px;
}


/* ---------- Errore ---------- */

.market-error {
    padding: 14px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    color: #5d4037;
}

.market-error p {
    margin-bottom: 0;
}


/* ---------- Tablet ---------- */

@media (max-width: 1050px) {
    .advanced-market-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .market-explanation {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ---------- Smartphone ---------- */

@media (max-width: 750px) {
    .mercato-avanzato {
        grid-column: auto;
    }

    .market-selector {
        align-items: stretch;
    }

    .market-selector select,
    .market-selector button,
    .market-reset {
        width: 100%;
        min-width: 0;
    }

    .market-reset {
        text-align: center;
    }

    .advanced-market-heading {
        display: block;
    }

    .advanced-market-price {
        margin-top: 12px;
        text-align: left;
    }

    .advanced-market-metrics {
        grid-template-columns: 1fr;
    }

    .market-explanation {
        grid-template-columns: 1fr;
    }

    .candlestick-chart {
        height: 390px;
    }
}

/* ============================================================
   LAYOUT OCHALAND - 3 COLONNE
   Meteo | News | Mercato
   ============================================================ */

.dashboard {
    display: grid;
    grid-template-columns:
        minmax(260px, 30%)
        minmax(320px, 40%)
        minmax(260px, 30%);
    gap: 20px;

    width: 94%;
    max-width: 1600px;
    margin: 30px auto;

    align-items: start;
}

/* COLONNA 1 - METEO */
.meteo,
.meteo-avanzato {
    grid-column: 1 !important;
    grid-row: 1;
}

/* COLONNA 2 - NEWS */
.news {
    grid-column: 2 !important;
    grid-row: 1;
}

/* COLONNA 3 - MERCATI */
.mercati,
.mercato-avanzato {
    grid-column: 3 !important;
    grid-row: 1;
}


/* ============================================================
   NEWS NELLA COLONNA CENTRALE
   ============================================================ */

.news-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.news-col {
    min-width: 0;
}


/* ============================================================
   MERCATO AVANZATO NELLA COLONNA DESTRA
   ============================================================ */

/* Annulla l'eventuale full-width definito in precedenza */

.mercato-avanzato {
    min-width: 0;
}

.advanced-market-heading {
    display: block;
}

.advanced-market-price {
    margin-top: 10px;
    text-align: left;
}

.advanced-market-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.market-selector {
    align-items: stretch;
}

.market-selector select {
    width: 100%;
    min-width: 0;
}

.candlestick-container {
    width: 100%;
    overflow-x: auto;
}

/*
 * Il grafico resta leggibile.
 * Se la colonna è troppo stretta compare lo scroll orizzontale.
 */
.candlestick-chart {
    width: 100%;
    min-width: 600px;
    height: 420px;
}

.market-explanation {
    grid-template-columns: repeat(2, 1fr);
}


/* ============================================================
   METEO AVANZATO NELLA COLONNA SINISTRA
   ============================================================ */

.meteo-avanzato {
    min-width: 0;
}

.advanced-current {
    grid-template-columns: 1fr;
}

.weather-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.advanced-days {
    grid-template-columns: 1fr;
}

.hourly-scroll {
    width: 100%;
    overflow-x: auto;
}


/* ============================================================
   AREA RISERVATA
   Se la lasciamo, va sotto tutte e tre le colonne.
   ============================================================ */

.riservata {
    grid-column: 1 / -1 !important;
    grid-row: auto;
}


/* ============================================================
   TABLET
   Sotto 1100px passiamo a 2 colonne
   ============================================================ */

@media (max-width: 1100px) {

    .dashboard {
        grid-template-columns: 1fr 1fr;
    }

    .meteo,
    .meteo-avanzato {
        grid-column: 1 !important;
        grid-row: 1;
    }

    .mercati,
    .mercato-avanzato {
        grid-column: 2 !important;
        grid-row: 1;
    }

    .news {
        grid-column: 1 / -1 !important;
        grid-row: 2;
    }

    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ============================================================
   SMARTPHONE
   Tutto in una sola colonna
   ============================================================ */

@media (max-width: 750px) {

    .dashboard {
        grid-template-columns: 1fr;
        width: 92%;
        gap: 18px;
    }

    .meteo,
    .meteo-avanzato {
        grid-column: 1 !important;
        grid-row: auto;
    }

    .news {
        grid-column: 1 !important;
        grid-row: auto;
    }

    .mercati,
    .mercato-avanzato {
        grid-column: 1 !important;
        grid-row: auto;
    }

    .riservata {
        grid-column: 1 !important;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    .advanced-market-metrics,
    .weather-metrics,
    .market-explanation {
        grid-template-columns: 1fr;
    }
}
