/* =========================================================
   METEOLOST — CSS PRINCIPAL
   ========================================================= */

/* =========================================================
   VARIABLES
   ========================================================= */

:root {
    --cold: #38bdf8;
    --hot: #fb7185;
    --alert: #ef4444;
    --green: #198754;
    --dark: #3E3E47;
    --dark-2: #25252d;

    --radius: 14px;

    --glass-light: rgba(255, 255, 255, .9);
    --glass-dark: rgba(17, 25, 40, .84);

    --shadow-soft: 0 8px 24px rgba(0, 0, 0, .13);
    --shadow-strong: 0 18px 45px rgba(0, 0, 0, .22);
}


/* =========================================================
   BASE
   ========================================================= */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    transition:
        background .6s ease,
        color .3s ease;

    line-height: 1.35;
}


/* =========================================================
   CICLO SOLAR
   ========================================================= */

body.dawn {
    background: linear-gradient(160deg, #fffbe8, #ffd27f);

    --text-main: #1f2937;
    --text-soft: #374151;
    --text-strong: #020617;
    --text-shadow: none;
}

body.daytime {
    background: linear-gradient(160deg, #87ceeb, #ffd27f);

    --text-main: #020617;
    --text-soft: #334155;
    --text-strong: #020617;
    --text-shadow: none;
}

body.dusk {
    background: linear-gradient(160deg, #2c3e50, #fd746c);

    --text-main: #1f2937;
    --text-soft: #374151;
    --text-strong: #020617;
    --text-shadow: 0 1px 2px rgba(255, 255, 255, .35);
}

body.nighttime {
    background: linear-gradient(160deg, #0f2027, #203a43, #2c5364);

    --text-main: #e5e7eb;
    --text-soft: #cbd5f5;
    --text-strong: #fff;
    --text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}


/* =========================================================
   CONTENEDORES
   ========================================================= */

.container-fluid {
    max-width: 100%;
}

.radar-seccio,
.astronomia-seccio {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}


/* =========================================================
   CARDS
   ========================================================= */

.card {
    position: relative;
    border: 0;
    border-radius: var(--radius);
    background: var(--glass-light);
    box-shadow: var(--shadow-soft);
    padding: 1.6rem 1rem 1rem;
    min-height: 95%;
    color: var(--text-main);

    transition:
        transform .25s ease,
        box-shadow .25s ease,
        background .35s ease;
}

body.nighttime .card {
    background: var(--glass-dark);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .42);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

.card.alert {
    padding-top: 1.2rem;
}


/* Evita que Bootstrap cambie el fondo de las tarjetas */

.card.bg-info,
.card.bg-primary,
.card.alert-info,
.card.info {
    background: var(--glass-light);
    color: var(--text-main);
}

body.nighttime .card.bg-info,
body.nighttime .card.bg-primary,
body.nighttime .card.alert-info,
body.nighttime .card.info {
    background: var(--glass-dark);
}


/* =========================================================
   CARD HEADER
   ========================================================= */

.card-header {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;

    min-height: 40px;
    padding: 10px 16px;

    border: 0;
    border-radius: 12px 12px 0 0;

    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, .94),
            rgba(240, 240, 240, .9)
        );

    color: #13212f;

    font-size: 1.2rem;
    font-weight: 750;
    line-height: 1.2;
    text-align: center;

    box-shadow:
        inset 0 -2px 5px rgba(0, 0, 0, .04),
        0 2px 5px rgba(0, 0, 0, .07);
}

#dades-realtime .card-header {
    display: block;
    padding: .7rem 1rem;

    background: #3E3E47;
    color: #fff;

    text-align: left;
}

#dades-realtime .card-header span {
    font-size: .8em;
    line-height: 1.2;
}


/* =========================================================
   CARD BODY
   ========================================================= */

.card-body {
    padding: 1rem;
}

.card-body h5.card-title {
    margin: .2rem 0;

    color: var(--text-strong);

    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;

    text-shadow: var(--text-shadow);
}

.card-body h5.alert {
    color: var(--alert);

    transform: scale(1.05);

    text-shadow:
        0 2px 6px rgba(239, 68, 68, .45);
}

.card-body .min,
.card-body .max {
    display: block;

    margin: 3px 0;

    font-size: .8rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;

    text-shadow: var(--text-shadow);
}

.card-body .min {
    color: var(--cold);
}

.card-body .max {
    color: var(--hot);
}

.card p,
.card span,
.card .prev,
.card .prev * {
    color: var(--text-soft);

    font-size: .85rem;
    line-height: 1.35;

    text-shadow: var(--text-shadow);
}

.card .prev strong,
.card .prev h6 {
    color: var(--text-strong);
    font-weight: 700;
}


/* =========================================================
   ICONOS
   ========================================================= */

.card img {
    display: block;

    height: 20px;
    margin: 5px auto;

    filter: brightness(0);

    transition:
        transform .25s ease,
        filter .25s ease;
}

.card:hover img {
    transform: scale(1.08);

    filter:
        drop-shadow(
            0 2px 4px rgba(0, 0, 0, .25)
        );
}


/* =========================================================
   FRIO / CALOR
   ========================================================= */

.card.cold::before,
.card.hot::before {
    position: absolute;

    top: 0;
    bottom: 0;
    left: 0;

    width: 5px;

    border-radius: var(--radius) 0 0 var(--radius);

    content: "";
}

.card.cold::before {
    background: var(--cold);
}

.card.hot::before {
    background: var(--hot);
}


/* =========================================================
   ALERTAS
   ========================================================= */

.card .alert-text {
    display: inline-block;

    max-width: 100%;

    margin-bottom: 5px;
    padding: 3px 9px;

    box-sizing: border-box;

    border-radius: 5px;

    font-size: .7rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
}

.card.alert.danger .alert-text {
    background: rgba(239, 68, 68, .18);
    color: #ef4444;

    box-shadow:
        0 2px 6px rgba(239, 68, 68, .2);
}

.card.alert.warning .alert-text {
    background: rgba(250, 173, 20, .2);
    color: #d48806;

    box-shadow:
        0 2px 6px rgba(250, 173, 20, .2);
}

.card.alert.info .alert-text {
    background: rgba(24, 144, 255, .17);
    color: #096dd9;

    box-shadow:
        0 2px 6px rgba(24, 144, 255, .2);
}

.card.alert.soft .alert-text {
    background: rgba(34, 197, 94, .17);
    color: #16a34a;

    box-shadow:
        0 2px 6px rgba(34, 197, 94, .2);
}


/* =========================================================
   ALERTA GLOBAL
   ========================================================= */

#global-alerts {
    position: relative;

    z-index: 1;

    width: 100%;

    margin: 0;
    padding: 0;
}

#global-alerts .alert {
    margin: 0;

    border-radius: 0;

    font-weight: 600;
    text-align: center;
}

#global-alerts .alert.show {
    opacity: 1;
    transform: translateY(0);
}

#global-alerts .alert.hide {
    opacity: 0;
    transform: translateY(-20px);
}

#global-alerts .alert-danger {
    background: #ff4d4f;
    color: #fff;

    border: 1px solid #d9363e;
}

#global-alerts .alert-warning {
    background: #faad14;
    color: #1f1f1f;

    border: 1px solid #d48806;
}

#global-alerts .alert-info {
    background: #1890ff;
    color: #fff;

    border: 1px solid #096dd9;
}

#global-alerts .alert-soft {
    background: #d9f7be;
    color: #237804;

    border: 1px solid #b7eb8f;
}


/* =========================================================
   NAVBAR
   ========================================================= */

.navbar {
    position: relative;

    background:
        linear-gradient(
            90deg,
            #0f2027,
            #203a43,
            #2c5364
        );

    box-shadow:
        0 4px 10px rgba(0, 0, 0, .25);
}

.navbar-brand {
    color: #fff;

    font-family:
        "Segoe UI",
        Tahoma,
        Geneva,
        Verdana,
        sans-serif;

    font-weight: 700;
    letter-spacing: 1px;

    transition: color .25s ease;
}

.navbar-brand:hover {
    color: #ffd700;
}

.nav-link {
    position: relative;

    margin: 0 .45rem;

    color: #f0f0f0;

    transition: color .25s ease;
}

.nav-link:hover {
    color: #ffd700;
}

.nav-link::after {
    position: absolute;

    bottom: 0;
    left: 0;

    width: 0;
    height: 2px;

    background: #ffd700;

    content: "";

    transition: width .25s ease;
}

.nav-link:hover::after {
    width: 100%;
}

button.btn-primary {
    padding: .5rem 1rem;

    border: 0;
    border-radius: 25px;

    background: #1da1f2;

    font-weight: 700;

    transition:
        transform .2s ease,
        box-shadow .2s ease;
}

button.btn-primary:hover {
    transform: translateY(-2px);

    box-shadow:
        0 4px 12px rgba(29, 161, 242, .35);
}


/* =========================================================
   RADAR
   ========================================================= */

.radar-seccio {
    padding-right: 12px;
    padding-left: 12px;

    margin-bottom: 30px;
}

.radar-seccio > h5 {
    margin-bottom: 15px !important;

    padding: 10px 15px;

    border-radius: 10px;

    background: #3E3E47 !important;
    color: #fff;

    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.2;
}


/* =========================================================
   RADAR TOOLBAR
   ========================================================= */

.radar-toolbar {
    display: flex;

    flex-wrap: wrap;

    justify-content: center;
    align-items: center;

    gap: 7px;

    margin-bottom: 12px !important;
}

.radar-toolbar .btn {
    padding: 7px 14px;

    border: 1px solid #555;
    border-radius: 8px;

    background: #3E3E47;
    color: #ddd;

    font-size: .88rem;
    font-weight: 500;
    line-height: 1.2;

    transition:
        background .2s ease,
        color .2s ease,
        border-color .2s ease,
        transform .2s ease,
        box-shadow .2s ease;
}

.radar-toolbar .btn:hover {
    background: #50505a;
    color: #fff;

    border-color: #666;

    transform: translateY(-1px);
}

.radar-toolbar .btn:focus {
    outline: none;

    box-shadow:
        0 0 0 3px rgba(25, 135, 84, .18);
}

.radar-toolbar .btn.activo {
    background: #198754;
    color: #fff;

    border-color: #198754;

    box-shadow:
        0 3px 10px rgba(25, 135, 84, .25);
}


/* =========================================================
   RADAR CARD
   ========================================================= */

.radar-card {
    width: 100%;

    overflow: hidden;

    border: 1px solid rgba(255, 255, 255, .05);
    border-radius: 12px;

    background: #25252d;

    box-shadow:
        0 5px 20px rgba(0, 0, 0, .25);
}

.radar-header {
    padding: 10px 15px;

    background: #3E3E47;
    color: #fff;

    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
}

#radarEstado {
    font-size: .75rem;
    font-weight: 500;
    opacity: .85;
}

.radar-content {
    position: relative;

    width: 100%;

    overflow: hidden;
}

#radarMapa {
    width: 100%;
    height: 500px;
}


/* =========================================================
   LEAFLET
   ========================================================= */

#radarMapa .leaflet-control-zoom {
    border: 0;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, .25);
}

#radarMapa .leaflet-control-zoom a {
    border: 0;

    background: rgba(255, 255, 255, .95);
    color: #333;
}

#radarMapa .leaflet-control-zoom a:hover {
    background: #fff;
    color: #198754;
}


/* =========================================================
   MARCADOR
   ========================================================= */

.olost-marker {
    font-size: 28px;
    line-height: 30px;
    text-align: center;
}


/* =========================================================
   AEMET POPUP
   ========================================================= */

.aemet-popup {
    min-width: 250px;
    max-width: 380px;

    color: #222;

    line-height: 1.35;
}

.aemet-popup h6 {
    margin: 0 0 8px;

    color: #222;

    font-weight: 700;
}

.aemet-popup hr {
    margin: 8px 0;
}

.aemet-nivel {
    display: inline-block;

    margin-top: 3px;
    padding: 4px 10px;

    border-radius: 5px;

    color: #fff;

    font-weight: 700;
}

.aemet-amarillo {
    background: #f1c40f;
    color: #222;
}

.aemet-naranja {
    background: #f57c00;
    color: #fff;
}

.aemet-rojo {
    background: #d32f2f;
    color: #fff;
}

.aemet-verde {
    background: #2e7d32;
    color: #fff;
}


/* =========================================================
   LEYENDA RADAR
   ========================================================= */

.radar-leyenda {
    position: absolute;

    right: 15px;
    bottom: 15px;

    z-index: 1000;

    padding: 9px 12px;

    border-radius: 8px;

    background: rgba(40, 40, 45, .94);
    color: #fff;

    font-size: 12px;

    box-shadow:
        0 3px 12px rgba(0, 0, 0, .25);
}

.radar-leyenda strong {
    display: block;

    margin-bottom: 5px;

    font-size: 12px;
}

.leyenda-item {
    display: flex;

    align-items: center;

    gap: 7px;

    margin: 3px 0;

    line-height: 1.2;
}

.leyenda-color {
    width: 13px;
    height: 13px;

    flex: 0 0 13px;

    border-radius: 3px;
}

.leyenda-amarillo {
    background: #f1c40f;
}

.leyenda-naranja {
    background: #f57c00;
}

.leyenda-rojo {
    background: #d32f2f;
}


/* =========================================================
   ASTRONOMIA
   ========================================================= */

.astronomia-seccio {
    padding-right: 12px;
    padding-left: 12px;

    margin-bottom: 30px;
}

.astronomia-seccio > h5 {
    margin-bottom: 20px !important;

    padding: 10px 15px;

    border-radius: 10px;

    background: #3E3E47 !important;
    color: #fff;

    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.2;
}

.astronomia-seccio .card {
    min-height: 100%;
}

.moon-row {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 15px;

    padding: 5px 0;

    border-bottom:
        1px solid rgba(127, 127, 127, .12);

    line-height: 1.25;
}

.moon-row:last-child {
    border-bottom: 0;
}

.moon-row .label {
    color: var(--text-soft);
    font-weight: 500;
}

.astro-event {
    padding: 4px 0;
}

.event-title {
    color: var(--text-strong);
    font-weight: 700;
}

.event-value {
    margin-top: 4px;

    color: var(--text-soft);

    line-height: 1.3;
}


/* =========================================================
   RESPONSIVE — TABLET
   ========================================================= */

@media (max-width: 768px) {

    .card-body h5.card-title {
        font-size: 1.7rem;
    }

    .card img {
        height: 18px;
    }

    #global-alerts .alert {
        padding: 10px;
        font-size: .9rem;
    }

    .navbar-nav {
        padding: 1rem;

        border-radius: 10px;

        background: #203a43;
    }

    .nav-item {
        margin-bottom: .4rem;
    }

    .radar-toolbar {
        gap: 6px;
    }

    .radar-toolbar .btn {
        padding: 7px 11px;
        font-size: .84rem;
    }

    #radarMapa {
        height: 430px;
    }

    .radar-header {
        padding: 9px 12px;
    }

    .radar-leyenda {
        right: 10px;
        bottom: 10px;

        font-size: 11px;
    }
}


/* =========================================================
   RESPONSIVE — MÓVIL
   ========================================================= */

@media (max-width: 576px) {

    .card-body h5.card-title {
        font-size: 1.55rem;
    }

    .card img {
        height: 16px;
    }

    .radar-seccio,
    .astronomia-seccio {
        padding-right: 8px;
        padding-left: 8px;
    }

    .radar-toolbar .btn {
        padding: 7px 10px;
        font-size: .8rem;
    }

    #radarMapa {
        height: 380px;
    }

    .radar-card {
        border-radius: 10px;
    }

    .radar-leyenda {
        padding: 7px 9px;
    }

    .moon-row {
        gap: 8px;

        font-size: .82rem;
    }
}

/* =========================================================
   FOOTER — METEOLOST
   ========================================================= */

footer {
    width: 100vw !important;
    margin-left: calc(50% - 50vw) !important;
    margin-right: 0 !important;

    background: linear-gradient(
        90deg,
        #0f2027,
        #203a43,
        #2c5364
    ) !important;

    border: 0 !important;
    color: #fff !important;
    box-sizing: border-box;
}

/* ================================
   ACORDEONS DE LES SECCIONS
   ================================ */

.seccio-acordio {
    margin-bottom: 1rem;
}

.seccio-acordio > .accordion-item {
    border: 0;
    background: transparent;
}

.seccio-acordio > .accordion-item > .accordion-header {
    margin: 0;
}

.seccio-acordio > .accordion-item > .accordion-header .accordion-button {
    background: #3E3E47;
    color: #fff;
    font-weight: 600;
    font-size: 1.05rem;
    border-radius: 10px !important;
    box-shadow: none;
    padding: .85rem 1rem;
}

.seccio-acordio > .accordion-item > .accordion-header .accordion-button:not(.collapsed) {
    background: #3E3E47;
    color: #fff;
    box-shadow: none;
}

.seccio-acordio > .accordion-item > .accordion-header .accordion-button::after {
    filter: brightness(0) invert(1);
}

.seccio-acordio > .accordion-item > .accordion-collapse {
    background: transparent;
}

.seccio-acordio > .accordion-item > .accordion-collapse > .accordion-body {
    padding: 1rem 0 0 0;
}

/* La secció de dades en temps real queda sempre oberta */
.seccio-oberta .accordion-button {
    cursor: default;
}

.seccio-oberta .accordion-button::after {
    display: none;
}

/* Separació entre seccions */
#main-content > .container-fluid {
    margin-bottom: 1rem;
}

/* =========================================================
   SALUT AMBIENTAL
   ========================================================= */

.ambient-card {
    overflow: hidden;
}

.ambient-card .card-header {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.ambient-card .card-header i {
    font-size: 1.15rem;
}

.ambient-main-value {
    font-size: 2.5rem;
    line-height: 1;
    font-weight: 700;
    text-align: center;
    margin: .4rem 0 .65rem;
}

.ambient-icon {
    font-size: 2.2rem;
    text-align: center;
    margin-bottom: .5rem;
}

.ambient-meaning {
    background: #f5f6f7;
    border-radius: 10px;
    padding: .85rem;
    margin-top: .5rem;
}

.ambient-meaning strong {
    display: block;
    margin-bottom: .35rem;
}

.ambient-meaning p {
    margin: 0;
    line-height: 1.45;
}

.ambient-action {
    margin-top: .85rem;
    line-height: 1.45;
}

.ambient-action strong {
    margin-right: .2rem;
}

.ambient-progress {
    height: 8px;
    border-radius: 10px;
}

.ambient-data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .45rem 0;
    border-top: 1px solid #e9ecef;
}

.ambient-data-row span {
    color: #6c757d;
}

.ambient-data-row strong {
    font-weight: 600;
}


/* RESUM GENERAL */

.ambient-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, .92);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .10);
}

.ambient-summary-icon {
    font-size: 2.2rem;
}

.ambient-summary-title {
    font-size: .9rem;
    color: #6c757d;
}

.ambient-summary-level {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: .1rem;
}

.ambient-summary-text {
    margin-top: .15rem;
    line-height: 1.4;
}


/* AIRE */

.ambient-air-data {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .55rem;
}

.ambient-air-data > div {
    background: #f5f6f7;
    border-radius: 8px;
    padding: .55rem;
    text-align: center;
}

.ambient-air-data small {
    display: block;
    color: #6c757d;
}

.ambient-air-data strong {
    display: block;
}


/* POL·LEN */

.ambient-pollen-data {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .55rem;
}

.ambient-pollen-data > div {
    background: #f5f6f7;
    border-radius: 8px;
    padding: .55rem;
    text-align: center;
}

.ambient-pollen-data small {
    display: block;
    color: #6c757d;
}

.ambient-pollen-data strong {
    display: block;
}


/* GASOS */

.ambient-gas-data {
    margin-top: 1rem;
}

.ambient-gas-data > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .55rem 0;
    border-top: 1px solid #e9ecef;
}

.ambient-gas-data small {
    color: #6c757d;
}


/* PLANTES */

.ambient-plant-data {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .55rem;
    margin-top: 1rem;
}

.ambient-plant-data > div {
    background: #f5f6f7;
    border-radius: 8px;
    padding: .55rem;
    text-align: center;
}

.ambient-plant-data small {
    display: block;
    color: #6c757d;
}

.ambient-plant-data strong {
    display: block;
}


/* FONT / EXPLICACIÓ */

.ambient-source {
    text-align: center;
    color: #6c757d;
    font-size: .75rem;
    margin-top: 1rem;
}

.ambient-footer {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .85rem 1rem;
    background: rgba(255, 255, 255, .65);
    border-radius: 10px;
    color: #6c757d;
    font-size: .82rem;
    line-height: 1.4;
}


/* MÒBIL */

@media (max-width: 576px) {

    .ambient-summary {
        align-items: flex-start;
    }

    .ambient-summary-icon {
        font-size: 1.8rem;
    }

    .ambient-main-value {
        font-size: 2.2rem;
    }

    .ambient-air-data,
    .ambient-pollen-data,
    .ambient-plant-data {
        grid-template-columns: repeat(2, 1fr);
    }
}
