:root {
    /* Tema visual general de la aplicacion. */
    color-scheme: light;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #16212f;
}

* {
    box-sizing: border-box;
}

html,
body {
    /* El scroll queda dentro del listado lateral, no en toda la pagina. */
    height: 100%;
    margin: 0;
    overflow: hidden;
}

.app-shell {
    /* La aplicacion ocupa exactamente el alto visible del navegador. */
    height: 100vh;
    padding: 10px;
    overflow: hidden;
}

.map-panel {
    /* Dos columnas: mapa flexible y panel lateral fijo. */
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    height: calc(100vh - 20px);
    min-height: 0;
    border: 1px solid #d7dee7;
    background: #ffffff;
}

#map {
    /* Google Maps necesita dimensiones explicitas para renderizar correctamente. */
    width: 100%;
    height: 100%;
    min-height: 0;
}

.results {
    /* Panel lateral con cabecera fija y lista desplazable. */
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-left: 1px solid #d7dee7;
    background: #fbfcfd;
}

.results header {
    padding: 18px 18px 12px;
    border-bottom: 1px solid #d7dee7;
}

h1 {
    margin: 0 0 6px;
    font-size: 24px;
    line-height: 1.2;
}

.fuel-control {
    display: grid;
    gap: 6px;
    margin: 10px 0 10px;
}

.fuel-control span {
    color: #59697a;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.fuel-control select {
    width: 100%;
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #16212f;
    font: inherit;
}

.fuel-control select:focus {
    border-color: #2f6fed;
    outline: none;
}

.status,
p {
    margin: 0;
    color: #59697a;
    font-size: 14px;
    line-height: 1.4;
}

.price-summary {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    overflow: hidden;
    border-radius: 6px;
}

.price-summary td {
    padding: 8px 6px;
    color: #ffffff;
    text-align: center;
}

.price-summary span,
.price-summary strong {
    display: block;
}

.price-summary span {
    font-size: 11px;
    font-weight: 700;
}

.price-summary strong {
    margin-top: 3px;
    font-size: 14px;
}

.summary-min {
    background: #16834a;
}

.summary-avg {
    background: #e88922;
}

.summary-max {
    background: #b42318;
}

#stationList {
    /* Solo esta lista hace scroll cuando hay varias gasolineras. */
    display: grid;
    gap: 8px;
    align-content: start;
    min-height: 0;
    margin: 0;
    padding: 12px;
    overflow: auto;
    list-style: none;
}

.station button {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 76px;
    padding: 10px;
    border: 1px solid #d7dee7;
    border-radius: 8px;
    background: #ffffff;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.station button:hover,
.station button:focus {
    border-color: #2f6fed;
    outline: none;
}

.position {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1f6f5b;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
}

.details {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.details strong,
.details span,
.details small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.details strong {
    font-size: 14px;
}

.details span {
    color: #334155;
    font-size: 13px;
}

.details small {
    color: #667789;
    font-size: 12px;
}

.price {
    font-size: 16px;
    font-weight: 700;
    color: #9b2c2c;
    white-space: nowrap;
}

.popup {
    display: grid;
    gap: 6px;
    min-width: 250px;
    max-width: 310px;
    padding: 2px 2px 4px;
    color: #16212f;
    font-size: 13px;
    line-height: 1.3;
}

.popup-title {
    color: #111827;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
}

.popup-price {
    display: inline-block;
    width: max-content;
    margin: 2px 0 4px;
    padding: 4px 8px;
    border-radius: 6px;
    background: #f8e8e7;
    color: #9b2c2c;
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}

.popup-address {
    color: #334155;
    font-size: 14px;
}

.popup-place,
.popup-hours {
    color: #667789;
    font-size: 12px;
}

.gm-style .gm-style-iw-c {
    border-radius: 8px;
}

.gm-style .gm-style-iw-d {
    overflow: auto !important;
}

/* Fecha de actualizacion */
.popup-updated {
    color: #9ca3af;
    font-size: 11px;
    font-style: italic;
    margin-top: 2px;
}

small.updated {
    color: #9ca3af;
    font-size: 10px;
    font-style: italic;
}

/* Tablet: entre 620px y 1024px */
@media (max-width: 1024px) and (min-width: 621px) {
    .map-panel {
        grid-template-columns: minmax(0, 1fr) 320px;
    }

    .station button {
        min-height: 68px;
        padding: 8px;
    }

    .details strong {
        font-size: 13px;
    }
}

/* Movil: menos de 620px */
@media (max-width: 620px) {
    .app-shell {
        height: 100vh;
        padding: 0;
    }

    .map-panel {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 55vh) minmax(0, 45vh);
        height: 100vh;
        min-height: 0;
        border: 0;
    }

    #map {
        height: 100%;
        min-height: 0;
    }

    .results {
        max-height: none;
        border-top: 1px solid #d7dee7;
        border-left: 0;
    }

    .results header {
        padding: 10px 12px 8px;
    }

    h1 {
        font-size: 18px;
        margin: 0 0 4px;
    }

    .fuel-control {
        margin: 6px 0 6px;
        gap: 4px;
    }

    .fuel-control select {
        min-height: 36px;
        font-size: 14px;
    }

    .status,
    p {
        font-size: 12px;
    }

    .price-summary strong {
        font-size: 12px;
    }

    #stationList {
        gap: 6px;
        padding: 8px;
    }

    .station button {
        grid-template-columns: 28px minmax(0, 1fr) auto;
        gap: 8px;
        min-height: 64px;
        padding: 8px;
    }

    .position {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .details strong {
        font-size: 13px;
    }

    .details span {
        font-size: 12px;
    }

    .details small {
        font-size: 11px;
    }

    .price {
        font-size: 14px;
    }

    .popup {
        min-width: 200px;
        max-width: 260px;
    }

    .popup-title {
        font-size: 15px;
    }

    .popup-price {
        font-size: 20px;
    }
}
