/* ==========================================================================
   Car rental portal - public styles (mobile-first, on top of Bootstrap 5)
   ========================================================================== */

:root {
    --brand: #0d6efd;
    --brand-dark: #0f2a44;
    --text: #1f2937;
    --muted: #6b7280;
    --bg: #f5f7fa;
    --card-radius: 14px;
    --shadow: 0 2px 12px rgba(15, 42, 68, .06);
    --cal-available: #e7f6ec;
    --cal-available-border: #34a853;
    --cal-booked: #fde2e1;
    --cal-booked-text: #b42318;
    --cal-unavailable: #eceef1;
    --cal-unavailable-text: #9aa1ab;
    --cal-selected: #0d6efd;
    --cal-range: #cfe2ff;
}

html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    overflow-x: hidden;
}

body.has-mobile-bar { padding-bottom: 84px; }

/* Spanish translation text (always shown in parentheses after English) */
.es { color: var(--muted); font-weight: normal; }
.btn .es, .badge .es, .text-bg-primary .es, .text-bg-success .es,
.text-bg-danger .es, .text-bg-secondary .es { color: inherit; opacity: .85; }

/* Touch targets: at least 44px */
.btn-touch { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-lg.btn-touch { min-height: 52px; }
.form-control, .form-select { min-height: 44px; }
.form-check-input { width: 1.35em; height: 1.35em; margin-top: .1em; }
.form-check-label { padding-left: .25rem; }

/* WhatsApp button */
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn-whatsapp:hover, .btn-whatsapp:focus-visible { background: #1ebe5b; border-color: #1ebe5b; color: #fff; }

/* Header / footer */
/* Header grid: equal side columns keep the WhatsApp button in the middle */
.site-header .navbar > .header-grid {
    /* 1fr never shrinks below its content, so the columns can't overlap */
    display: grid; grid-template-columns: 1fr auto 1fr;
    align-items: center; column-gap: .5rem; flex-wrap: nowrap;
}
.header-grid .navbar-brand { justify-self: start; min-width: 0; margin-right: 0; }
.header-grid .header-center { justify-self: center; }
.header-grid .header-right { justify-self: end; }
.lang-switch { display: inline-flex; border: 1px solid #dee2e6; border-radius: 10px; overflow: hidden; }
.lang-option {
    display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: 0 .6rem;
    color: var(--muted); font-size: .85rem; font-weight: 600; text-decoration: none;
}
.lang-option + .lang-option { border-left: 1px solid #dee2e6; }
.lang-option img { width: 24px; height: 16px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.lang-option:hover { background: #f1f5ff; color: var(--text); }
.lang-option.is-active { background: #e7f0ff; color: var(--brand-dark); }
/* "Check reservation" bar under the header (phones) - collapses while scrolling down */
/* The bar sits just below the sticky header without taking space in the page flow,
   so hiding it (sliding up behind the main bar) never makes the content jump. */
@media (max-width: 991.98px) {
    :root { --check-bar-h: 61px; }
    .check-bar {
        position: absolute; left: 0; right: 0; top: 100%; z-index: -1;
        transition: transform .25s ease, opacity .2s ease;
    }
    .check-bar.is-hidden { transform: translateY(-100%); opacity: 0; pointer-events: none; }
    /* Room for the bar above the page content */
    .site-main { padding-top: calc(var(--check-bar-h) + 1rem) !important; }
}
@media (prefers-reduced-motion: reduce) { .check-bar { transition: none; } }

/* Phones: brand icon + WhatsApp number + flags must fit on one line */
@media (max-width: 575.98px) {
    .site-header .brand-name { display: none; }
    .site-header .navbar-brand { margin-right: .25rem; padding: 0; }
    /* Logo as a bold app-style badge: white car on a blue rounded square */
    .site-header .navbar-brand .bi-car-front-fill {
        width: 44px; height: 44px; border-radius: 12px;
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 1.6rem; color: #fff !important;
        background: linear-gradient(145deg, #2f86ff, #0a58ca);
        box-shadow: none;
    }
    .lang-option span { display: none; }
    .lang-option { padding: 0 .5rem; }
}
@media (max-width: 991.98px) {
    .whatsapp-header { padding-left: .6rem; padding-right: .6rem; font-size: .95rem; }
}
@media (max-width: 339.98px) {
    .whatsapp-header { font-size: .85rem; padding-left: .45rem; padding-right: .45rem; }
}
.site-header .navbar { min-height: 60px; }
.site-header .navbar-brand { font-size: 1.15rem; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer-notice { font-size: .75rem; line-height: 1.4; }

/* Cards */
.card { border: 0; border-radius: var(--card-radius); box-shadow: var(--shadow); }
.card-img-top { border-top-left-radius: var(--card-radius); border-top-right-radius: var(--card-radius); }

.car-card-img, .car-detail-img { width: 100%; object-fit: cover; background: #e9edf2; }
.car-card-img { aspect-ratio: 16 / 10; }
.car-detail-img { aspect-ratio: 16 / 9; max-height: 380px; }

.price-tag .price-amount { font-size: 1.6rem; font-weight: 700; color: var(--brand-dark); }
.car-facts li { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; padding: .2rem 0; }
.car-facts i { color: var(--brand); }

.car-rules dt { font-weight: 600; }
.car-rules dd { margin-bottom: .5rem; }

/* Summary list (used on car, booking and success pages) */
.summary-list { margin: 0; }
.summary-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid #eef0f3; }
.summary-list dt { font-weight: 500; color: var(--muted); }
.summary-list dd { margin: 0; text-align: right; font-weight: 600; }
.summary-list .summary-total { border-bottom: 0; padding-top: .8rem; }
.summary-list .summary-total dt { color: var(--text); font-weight: 700; }
.summary-list .summary-total dd { font-size: 1.35rem; color: var(--brand-dark); }

.summary-card.sticky-lg-top { top: 76px; z-index: 1; }
@media (max-width: 991.98px) { .summary-card.sticky-lg-top { top: 0; } }
.summary-thumb { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; background: #e9edf2; }

.manual-dates summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }

/* Driving licence photo fields (booking form + admin) */
.licence-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.licence-slot {
    position: relative; display: flex; align-items: center; justify-content: center;
    aspect-ratio: 85.6 / 54;   /* ID-1 card format */
    width: 100%; border: 2px dashed #c3cad5; border-radius: 12px; background: #f8fafc;
    cursor: pointer; overflow: hidden; text-align: center; transition: border-color .15s, background-color .15s;
}
.licence-slot:hover, .licence-input:focus-visible + .licence-slot, .licence-input:focus-visible ~ .licence-slot { border-color: var(--brand); background: #f1f6ff; }
.licence-empty { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .5rem; line-height: 1.2; }
.licence-empty .bi { font-size: 1.6rem; color: var(--brand); }
.licence-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.licence-change {
    position: absolute; right: 6px; bottom: 6px; display: none; padding: .2rem .5rem; border-radius: 999px;
    background: rgba(17, 24, 39, .72); color: #fff;
}
.licence-slot.has-photo { border-style: solid; border-color: #198754; }
.licence-slot.is-missing { border-color: #f0ad4e; background: #fffaf0; }
a.licence-slot.has-photo:hover .licence-change { background: var(--brand); }
.licence-replace { cursor: pointer; text-decoration: none; }
.licence-replace:hover { text-decoration: underline; }
.licence-slot.is-missing .licence-empty .bi { color: #b26a00; }
.licence-slot.has-photo .licence-empty { display: none; }
.licence-slot.has-photo .licence-change { display: inline-block; }
.licence-slot.is-loading::after {
    content: ''; position: absolute; width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid rgba(13, 110, 253, .25); border-top-color: var(--brand); animation: licence-spin .8s linear infinite;
}
@keyframes licence-spin { to { transform: rotate(360deg); } }

/* Honeypot */
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Success page */
.success-icon { font-size: 3.2rem; color: #b26a00; line-height: 1; }
.reservation-number-box { background: #f1f5ff; border-radius: 12px; padding: .9rem; }
.reservation-number { font-size: 1.6rem; font-weight: 800; letter-spacing: .04em; color: var(--brand-dark); word-break: break-all; }

/* Mobile sticky summary bar */
.mobile-summary-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: #fff; border-top: 1px solid #e5e7eb; box-shadow: 0 -4px 16px rgba(0,0,0,.06);
    padding: .65rem 0 calc(.65rem + env(safe-area-inset-bottom));
}

/* ==========================================================================
   Availability calendar
   ========================================================================== */
.calendar-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.calendar-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend-dot { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid transparent; }
.legend-dot.is-available { background: var(--cal-available); border-color: var(--cal-available-border); }
.legend-dot.is-booked { background: var(--cal-booked); border-color: var(--cal-booked-text); }
.legend-dot.is-unavailable { background: var(--cal-unavailable); border-color: #d5d9df; }
.legend-dot.is-selected { background: var(--cal-selected); }

.booking-calendar { min-height: 200px; }
.cal-nav { display: flex; justify-content: space-between; margin-bottom: .5rem; }
.cal-nav .btn { min-width: 48px; }
.cal-months { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
.cal-months-2 { grid-template-columns: 1fr 1fr; }
.cal-month-title { text-align: center; font-weight: 700; margin-bottom: .5rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-weekday { display: flex; flex-direction: column; align-items: center; font-size: .72rem; font-weight: 600; color: var(--muted); padding-bottom: 2px; line-height: 1.15; }
.cal-weekday .es { font-size: .66rem; }

.cal-day {
    aspect-ratio: 1 / 1; min-height: 44px; width: 100%;
    border: 1px solid transparent; border-radius: 10px;
    font-size: 1rem; font-weight: 600; padding: 0;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background-color .12s, color .12s;
    -webkit-tap-highlight-color: transparent;
}
.cal-day.is-available { background: var(--cal-available); border-color: rgba(52, 168, 83, .45); color: #14532d; }
.cal-day.is-available:hover { background: #c9ecd5; }
.cal-day.is-booked { background: var(--cal-booked); color: var(--cal-booked-text); text-decoration: line-through; }
.cal-day.is-unavailable { background: var(--cal-unavailable); color: var(--cal-unavailable-text); }
.cal-day.is-past { background: transparent; color: #c4c9d0; cursor: default; }
.cal-day.is-selected { background: var(--cal-selected); color: #fff; border-color: var(--cal-selected); }
.cal-day.is-in-range { background: var(--cal-range); color: #084298; }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--brand-dark); }
.cal-day:focus-visible { outline: 3px solid #86b7fe; outline-offset: 1px; }

@media (max-width: 380px) {
    .cal-grid { gap: 3px; }
    .cal-day { font-size: .9rem; border-radius: 8px; min-height: 40px; }
}

/* Footer always at the bottom of the window, also on short pages */
.site-body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.site-body > .site-main { flex: 1 0 auto; }
.site-body > .site-footer { flex-shrink: 0; }
