/*
 * Mobile-first app shell on top of Bootstrap.
 * Base styles target phones; wider screens only adjust from there.
 */
/* Bootstrap's display utilities (d-flex...) are !important and would override the hidden attribute. */
[hidden] {
    display: none !important;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Header: with a translucent status bar the page starts under it, so pad by the safe area. */
.app-header {
    background-color: var(--bs-dark);
    padding-top: env(safe-area-inset-top);
}

.app-top-bar {
    min-height: 56px;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.app-top-bar .navbar-brand {
    font-size: 1.25rem;
    margin-right: 0;
}

/* Icon buttons with a 48px touch target (Android guideline). */
.app-icon-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--bs-emphasis-color);
}

.app-icon-btn:hover,
.app-icon-btn.active {
    background-color: rgba(var(--bs-emphasis-color-rgb), 0.12);
    color: var(--bs-emphasis-color);
}

/* Section bar: tabs fill the width on phones and scroll sideways if they don't fit. */
.app-section-bar .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    --bs-nav-underline-gap: 0;
}

.app-section-bar .nav::-webkit-scrollbar {
    display: none;
}

.app-section-bar .nav-link {
    min-height: 56px;
    padding: 0.375rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    font-size: 0.8125rem;
    white-space: nowrap;
    color: var(--bs-secondary-color);
}

.app-section-bar .nav-link .bi {
    font-size: 1.25rem;
    line-height: 1;
}

.app-section-bar .nav-link.active {
    color: var(--bs-primary);
    border-bottom-color: var(--bs-primary);
}

.app-menu {
    max-width: 85vw;
}

.app-menu .list-group-item {
    padding-top: 0.875rem;
    padding-bottom: 0.875rem;
}

@media (min-width: 768px) {
    .app-section-bar .nav-item {
        flex: 0 0 auto;
    }

    .app-section-bar .nav-link {
        min-width: 120px;
    }
}

/* Full-bleed sections (e.g. the map) fill the space under the header, without padding. */
.app-content--flush {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.app-map {
    position: relative;
    flex: 1;
    display: flex;
    min-height: 300px;
}

.app-map__canvas {
    flex: 1;
    z-index: 0; /* keep Leaflet's panes below the sticky header and the side menu */
}

/* Stacked messages over the top of the map (location status, station loading). */
.app-map__messages {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 1.5rem);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
    pointer-events: none;
}

.app-map__legend {
    position: absolute;
    left: 0.75rem;
    top: 0.75rem;
    z-index: 1000;
    font-weight: 500;
}

/* "Centrar en mi ubicación": a floating round button, on the map and on Nearby. */
.app-locate-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.375rem;
}

.app-map__locate {
    position: absolute;
    right: calc(1rem + env(safe-area-inset-right));
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    z-index: 1000;
}

.app-nearby {
    /* Room for the floating locate button below the last station. */
    padding-bottom: 5rem;
}

.app-nearby__locate {
    position: fixed;
    right: calc(1rem + env(safe-area-inset-right));
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    z-index: 1020;
}

.min-w-0 {
    min-width: 0;
}

/* Station markers: a price pill whose tip points at the station. */
.app-fuel-marker {
    background: none;
    border: 0;
}

.app-fuel-marker__pill {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, calc(-100% - 6px));
    padding: 0.125rem 0.375rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    color: #fff;
    background-color: var(--app-pill-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.app-fuel-marker__pill::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom: 0;
    border-top-color: var(--app-pill-color);
}

.app-fuel-marker__pill--cheap { --app-pill-color: #198754; }
.app-fuel-marker__pill--medium { --app-pill-color: #b07800; }
.app-fuel-marker__pill--expensive { --app-pill-color: #dc3545; }
.app-fuel-marker__pill--none { --app-pill-color: #6c757d; }

.app-fuel-popup {
    min-width: 180px;
}

/*
 * Inside the Hotwire Native app (body.app-native): no web header, the app has a native toolbar and tabs.
 */
.app-native-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0.25rem 0.5rem 0;
}

.app-native-actions__settings {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    text-decoration: none;
}

/* When the app implements the "button" bridge component, it shows a native button instead. */
[data-bridge-components~="button"] [data-controller~="bridge--button"] {
    display: none;
}

/* Station popup placed below or beside its station (fuel_stations_controller.js#fitPopup): no tip. */
.app-fuel-popup-wrapper--detached .leaflet-popup-tip-container {
    display: none;
}

/* Prices in a station popup: product on the left, price on the right; the cheapest (the marker's) first. */
.app-fuel-popup__price {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.8125rem;
}

.app-fuel-popup__price dt {
    font-weight: normal;
}

.app-fuel-popup__price dd {
    margin: 0;
    white-space: nowrap;
}

.app-fuel-popup__price--best {
    font-size: 1rem;
    font-weight: 700;
}

.app-fuel-popup__price--best dt {
    font-weight: 700;
}

/* "Cómo llegar" in a station popup. Leaflet colours every link in the map (.leaflet-container a),
   which would win over the button's own colour: blue text on a blue button. */
.leaflet-container a.app-fuel-popup__directions {
    color: var(--bs-btn-color);
}
