:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #0f172a;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --badge-green-bg: #dcfce7;
    --badge-green-text: #166534;
    --warn-bg: #fef9c3;
    --warn-text: #854d0e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding: 2rem 1rem;
}

.container {
    max-width: 1020px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 1.75rem;
}

header h1 {
    font-size: 1.85rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text);
}

header p {
    color: var(--muted);
    font-size: 1rem;
}

.controls {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Buscador de localidad con autocompletado Photon (Komoot) */
.location-search-row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.search-autocomplete-wrapper {
    position: relative;
    flex: 1 1 300px;
}

.search-input-group {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.15rem 0.4rem 0.15rem 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background: #ffffff;
}

.search-input-group input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.55rem 0.4rem;
    font-size: 0.92rem;
    color: var(--text);
    outline: none;
}

.search-input-group button.btn-search-loc {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.45rem 0.85rem;
    border-radius: 0.38rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
    white-space: nowrap;
}

.search-input-group button.btn-search-loc:hover {
    background: var(--primary-hover);
}

.suggestions-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
    z-index: 50;
    max-height: 260px;
    overflow-y: auto;
    display: none;
}

.suggestions-dropdown.open {
    display: block;
}

.suggestion-item {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    transition: background-color 0.12s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: #eff6ff;
}

.suggestion-main {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.suggestion-sub {
    font-size: 0.78rem;
    color: var(--muted);
}

.controls-row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1.25rem;
}

.slider-group {
    flex: 1 1 280px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.radius-pill {
    background: #dbeafe;
    color: var(--primary-hover);
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.9rem;
}

input[type="range"]#slider-radio {
    width: 100%;
    height: 6px;
    background: #cbd5e1;
    border-radius: 999px;
    outline: none;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0.25rem 0;
}

/* Posicionamiento proporcional exacto de las marcas de distancia (min=1, max=50) */
.slider-ticks {
    position: relative;
    width: 100%;
    height: 1.2rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.slider-ticks span {
    position: absolute;
    top: 0;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.slider-ticks span:hover {
    color: var(--primary);
    font-weight: 600;
}

.slider-ticks .tick-1 {
    left: 0%;
}

.slider-ticks .tick-10 {
    left: calc(8px + (100% - 16px) * (9 / 49));
    transform: translateX(-50%);
}

.slider-ticks .tick-25 {
    left: calc(8px + (100% - 16px) * (24 / 49));
    transform: translateX(-50%);
}

.slider-ticks .tick-50 {
    right: 0%;
}

.fuel-group {
    flex: 0 1 240px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.fuel-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

select#selector-combustible {
    width: 100%;
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    background-color: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

select#selector-combustible:focus {
    border-color: var(--primary);
}

.actions-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.btn {
    border: none;
    padding: 0.75rem 1.15rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, border-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-outline {
    background-color: #f8fafc;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background-color: #f1f5f9;
}

.btn-outline.active {
    background-color: var(--secondary);
    color: #fff;
    border-color: var(--secondary);
}

.btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

.status-box {
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    display: none;
}

.status-box.info {
    display: block;
    background: #e0f2fe;
    color: #075985;
}

.status-box.warn {
    display: block;
    background: var(--warn-bg);
    color: var(--warn-text);
    border: 1px solid #fde047;
}

.status-box.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
}

/* Sección del Mapa OpenStreetMap */
.map-section {
    display: none;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.map-section.visible {
    display: grid;
    grid-template-columns: 1fr 310px;
}

@media (max-width: 780px) {
    .map-section.visible {
        grid-template-columns: 1fr;
    }
}

#mapa-osm {
    width: 100%;
    height: 460px;
    z-index: 1;
}

.map-sidebar {
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: 460px;
    background: #fcfdff;
}

.map-sidebar-header {
    padding: 0.75rem 1rem;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-station-list {
    overflow-y: auto;
}

.map-station-item {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.map-station-item:hover {
    background-color: #eff6ff;
}

.map-station-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
}

.map-rank {
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}

.map-station-brand {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-station-dist {
    font-size: 0.78rem;
    font-weight: 700;
    color: #334155;
}

.map-station-prices {
    font-size: 0.78rem;
    color: var(--muted);
    display: flex;
    gap: 0.65rem;
}

.map-station-prices strong {
    color: var(--text);
}

/* Pines personalizados sobre el mapa con Marca y Precios */
.gas-pin-wrapper {
    background: transparent;
    border: none;
}

.gas-pin {
    background: #ffffff;
    border: 2px solid var(--primary);
    border-radius: 0.5rem;
    padding: 0.25rem 0.45rem;
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.25);
    font-family: system-ui, -apple-system, sans-serif;
    white-space: nowrap;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transform: translate(-50%, -100%);
    margin-top: -6px;
}

.gas-pin.cheapest {
    border-color: #16a34a;
    background: #f0fdf4;
}

.gas-pin::after {
    content: "";
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 7px 6px 0;
    border-style: solid;
    border-color: var(--primary) transparent transparent;
}

.gas-pin.cheapest::after {
    border-color: #16a34a transparent transparent;
}

.gas-pin-brand {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text);
    max-width: 125px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
}

.gas-pin-prices {
    font-size: 0.68rem;
    font-weight: 700;
    color: #334155;
    display: flex;
    gap: 0.35rem;
    line-height: 1.15;
}

.gas-pin-prices .g95 {
    color: var(--primary-hover);
}

.gas-pin-prices .dsl {
    color: #475569;
}

.meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(0,0,0,0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.country-tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    background: #e2e8f0;
    color: #334155;
    margin-left: 0.3rem;
}

.distance-badge {
    background: #f1f5f9;
    color: #334155;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}

.cheapest-badge {
    display: inline-block;
    background: var(--badge-green-bg);
    color: var(--badge-green-text);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 0.35rem;
    margin-bottom: 0.4rem;
}

.address {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.prices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: #f8fafc;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.price-item {
    display: flex;
    flex-direction: column;
}

.price-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    font-weight: 600;
}

.price-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}

.price-value.highlight {
    color: var(--primary);
}

.card-footer {
    margin-top: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--muted);
}

.map-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 0.8rem;
}

.map-link:hover {
    text-decoration: underline;
}
