/**
 * TaxiBaoLoc — Booking UI Styles
 * Mobile-first, uses dvh for Safari/Chrome toolbar compatibility
 */

/* ---- VARIABLES ---- */
.bk {
    --c-green: #00b14f;
    --c-green-bg: #e8f8ef;
    --c-red: #ff4757;
    --c-orange: #f59e0b;
    --c-blue: #3b82f6;
    --c-purple: #8b5cf6;
    --c-bg: #f5f7fa;
    --c-card: #ffffff;
    --c-border: #eef0f3;
    --c-text: #1a1a2e;
    --c-muted: #8b95a5;
    --c-shadow: rgba(0, 0, 0, 0.06);
    --radius: 16px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ---- BOOKING CONTAINER ---- */
.bk {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    /* Fallback if dvh not supported */
    height: var(--vh, 100vh);
    z-index: 9999;
    overflow: hidden;
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Hide navbar/footer on booking */
.is-booking-page .navbar,
.is-booking-page .footer,
.is-booking-page .sticky-contacts,
.is-booking-page .fab-call,
.is-booking-page #goToTop,
.is-booking-page .mobile-overlay,
.is-booking-page .mobile-menu {
    display: none !important;
}

/* Google Places Autocomplete dropdown — it renders outside .bk, needs high z-index */
.pac-container {
    z-index: 999999 !important;
    border-radius: 12px;
    border: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
}

.pac-item {
    padding: 10px 14px;
    cursor: pointer;
    border-top: 1px solid #f0f2f5;
    line-height: 1.4;
}

.pac-item:first-child {
    border-top: none;
}

.pac-item:hover,
.pac-item-selected {
    background: #f0faf4;
}

.pac-icon {
    display: none;
}

.pac-item-query {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 13px;
}

/* ---- MAP ---- */
.bk-map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    z-index: 1;
}

.bk-map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 13px;
    color: var(--c-muted);
    box-shadow: 0 4px 20px var(--c-shadow);
    z-index: 2;
}

/* ---- FLOATING HEADER ---- */
.bk-float-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

.bk-float-header>* {
    pointer-events: auto;
}

.bk-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--c-card);
    box-shadow: 0 2px 10px var(--c-shadow);
    font-size: 16px;
    color: var(--c-text);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bk-float-route {
    flex: 1;
    background: var(--c-card);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: 0 2px 12px var(--c-shadow);
    cursor: pointer;
}

.bk-fr-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bk-fr-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bk-fr-line {
    width: 2px;
    height: 12px;
    background: var(--c-border);
    margin: 3px 0 3px 5px;
    border-radius: 2px;
}

.bk-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bk-dot-green {
    background: var(--c-green);
}

.bk-dot-red {
    background: var(--c-red);
}

/* ---- BOTTOM PANEL ---- */
.bk-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--c-card);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.08);
    max-height: 80%;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    -webkit-overflow-scrolling: touch;
}

.bk-panel.minimized {
    transform: translateY(calc(100% - 60px));
    overflow: hidden;
}

.bk-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 6px;
    cursor: pointer;
}

.bk-handle-bar {
    width: 36px;
    height: 4px;
    background: #d8dce2;
    border-radius: 4px;
}

/* ---- STEPS ---- */
.bk-step {
    display: none;
}

.bk-step.active {
    display: flex;
    flex-direction: column;
}

.bk-step-inner {
    padding: 0 20px 12px;
    flex: 1;
}

/* ---- INPUT STYLES ---- */
.bk-greeting {
    font-size: 20px;
    font-weight: 800;
    color: var(--c-text);
    margin-bottom: 16px;
    padding-top: 4px;
}

.bk-input-group {
    background: var(--c-bg);
    border-radius: var(--radius);
    padding: 2px 0;
    border: 1px solid var(--c-border);
}

.bk-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 14px;
    position: relative;
}

.bk-input-divider {
    height: 1px;
    background: var(--c-border);
    margin: 0 14px 0 38px;
}

.bk-input-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bk-input-dot.green {
    background: var(--c-green);
}

.bk-input-dot.red {
    background: var(--c-red);
}

.bk-input-dot.orange {
    background: var(--c-orange);
}

.bk-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-text);
    padding: 10px 0;
    outline: none;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    /* iOS: prevent zoom when font-size < 16px — set via media query below */
}

.bk-input::placeholder {
    color: var(--c-muted);
    font-weight: 400;
}

.bk-input-sm {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 10px 14px;
    box-sizing: border-box;
}

.bk-textarea {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 10px 14px;
    resize: none;
    width: 100%;
    box-sizing: border-box;
}

.bk-gps-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--c-green-bg);
    color: var(--c-green);
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bk-add-stop {
    background: none;
    border: none;
    color: var(--c-green);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 0;
    cursor: pointer;
    font-family: inherit;
}

.bk-stop-row {
    margin-top: 8px;
}

.bk-stop-rm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 71, 87, 0.1);
    color: var(--c-red);
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- SCHEDULE ---- */
.bk-schedule {
    margin-top: 16px;
    padding: 14px;
    background: var(--c-bg);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
}

.bk-schedule-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--c-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.bk-schedule-inputs {
    display: flex;
    gap: 10px;
}

.bk-schedule-inputs .bk-input-sm {
    flex: 1;
    font-size: 13px;
}

/* ---- ACTION BAR ---- */
.bk-action {
    padding: 12px 20px calc(12px + var(--safe-b));
    background: var(--c-card);
    border-top: 1px solid var(--c-border);
}

.bk-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.bk-action-row {
    display: flex;
    gap: 10px;
}

.bk-btn-primary {
    width: 100%;
    padding: 14px 24px;
    border-radius: 14px;
    border: none;
    background: var(--c-green);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    transition: background 0.2s, transform 0.1s;
}

.bk-btn-primary:active {
    transform: scale(0.98);
    background: #009a44;
}

.bk-btn-confirm {
    flex: 1;
    padding: 14px 24px;
    border-radius: 14px;
    border: none;
    background: var(--c-green);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    transition: background 0.2s, transform 0.1s;
}

.bk-btn-confirm:active {
    transform: scale(0.98);
    background: #009a44;
}

.bk-btn-back {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: 1px solid var(--c-border);
    background: var(--c-card);
    color: var(--c-text);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bk-btn-sm {
    padding: 8px 18px;
    border-radius: 10px;
    border: none;
    background: var(--c-green);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

/* ---- BAR TOP (Payment + Promo) ---- */
.bk-bar-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.bk-pay-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 24px;
    border: 1px solid var(--c-border);
    background: var(--c-card);
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.bk-pay-trigger i:first-child {
    color: var(--c-green);
}

.bk-promo-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 24px;
    border: 1px solid var(--c-border);
    background: var(--c-card);
    font-size: 13px;
    font-weight: 600;
    color: var(--c-green);
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

/* ---- PROMO BOX ---- */
.bk-promo-box {
    padding: 16px 20px;
    border-top: 1px solid var(--c-border);
}

.bk-promo-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
}

.bk-promo-head button {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--c-muted);
    cursor: pointer;
}

.bk-promo-row {
    display: flex;
    gap: 8px;
}

/* ---- VEHICLE LIST ---- */
.bk-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.bk-section-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--c-text);
}

.bk-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--c-muted);
    cursor: pointer;
}

.bk-toggle-wrap input {
    display: none;
}

.bk-toggle {
    width: 40px;
    height: 22px;
    background: #ddd;
    border-radius: 20px;
    position: relative;
    transition: background 0.2s;
}

.bk-toggle::after {
    content: '';
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.bk-toggle-wrap input:checked+.bk-toggle {
    background: var(--c-green);
}

.bk-toggle-wrap input:checked+.bk-toggle::after {
    transform: translateX(18px);
}

.bk-vehicle-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bk-vt {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: var(--radius);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--c-bg);
}

.bk-vt.active {
    border-color: var(--c-green);
    background: var(--c-green-bg);
}

.bk-vt-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--c-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--c-green);
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.bk-vt-info {
    flex: 1;
    min-width: 0;
}

.bk-vt-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--c-text);
}

.bk-vt-desc {
    font-size: 12px;
    color: var(--c-muted);
    margin-top: 2px;
}

.bk-vt-meta {
    font-size: 11px;
    color: var(--c-muted);
    margin-top: 3px;
}

.bk-vt-price {
    font-size: 15px;
    font-weight: 800;
    color: var(--c-green);
    white-space: nowrap;
}

/* ---- FORM ---- */
.bk-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.bk-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--c-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
}

/* ---- REVIEW ---- */
.bk-review {
    background: var(--c-bg);
    border-radius: var(--radius);
    padding: 16px;
}

.bk-rv-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 8px 0;
}

.bk-rv-row i {
    margin-top: 2px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.bk-rv-row small {
    font-size: 10px;
    font-weight: 700;
    color: var(--c-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

.bk-rv-row div>div {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
}

.bk-rv-divider {
    height: 1px;
    background: var(--c-border);
    margin: 8px 0;
}

.bk-rv-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 6px 0;
}

.bk-rv-grid small {
    font-size: 10px;
    font-weight: 700;
    color: var(--c-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

.bk-rv-grid div>div {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
}

.bk-rv-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--c-text);
}

.bk-rv-fare {
    font-size: 20px;
    font-weight: 900;
    color: var(--c-green);
}

/* ---- PAYMENT MODAL ---- */
.bk-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.bk-modal-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: bkFadeIn 0.2s ease;
}

.bk-modal-sheet {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: var(--c-card);
    border-radius: 24px 24px 0 0;
    padding: 0 20px calc(20px + var(--safe-b));
    animation: bkSlideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.bk-modal-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--c-text);
    text-align: center;
    margin-bottom: 16px;
}

.bk-pay-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bk-pay-opt {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: var(--radius);
    border: 2px solid var(--c-border);
    cursor: pointer;
    transition: all 0.15s;
}

.bk-pay-opt.active {
    border-color: var(--c-green);
    background: var(--c-green-bg);
}

.bk-pay-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.bk-pay-info {
    flex: 1;
    min-width: 0;
}

.bk-pay-info b {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--c-text);
}

.bk-pay-info small {
    display: block;
    font-size: 12px;
    color: var(--c-muted);
    margin-top: 2px;
}

.bk-pay-check {
    font-size: 20px;
    color: transparent;
    transition: color 0.15s;
}

.bk-pay-opt.active .bk-pay-check {
    color: var(--c-green);
}

/* ---- ANIMATIONS ---- */
@keyframes bkFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes bkSlideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* ---- AUTOCOMPLETE DROPDOWN ---- */
.bk-input-row .autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 14px;
    right: 14px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 500;
    max-height: 200px;
    overflow-y: auto;
}

/* ---- DESKTOP ---- */
@media (min-width: 769px) {
    .bk-panel {
        width: 420px;
        right: 24px;
        left: auto;
        bottom: 24px;
        border-radius: 24px;
        max-height: calc(100% - 48px);
    }

    .bk-handle {
        display: none;
    }

    .bk-float-header {
        padding-left: 24px;
        padding-top: 24px;
    }

    .bk-modal-sheet {
        border-radius: 24px;
        margin-bottom: 24px;
    }

    .bk-form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ---- MOBILE ---- */
@media (max-width: 768px) {
    .bk-panel {
        max-height: 70%;
    }

    .bk-greeting {
        font-size: 18px;
    }

    .bk-form-grid {
        grid-template-columns: 1fr;
    }

    /* Prevent iOS Safari auto-zoom on input focus (requires font-size >= 16px) */
    .bk-input,
    .bk-input-sm,
    .bk-textarea {
        font-size: 16px !important;
    }

    /* Step 3 standalone inputs (not inside .bk-input-row flex) must be full width */
    .bk-step-inner .bk-input:not(.bk-input-row .bk-input),
    .bk-step-inner .bk-input-sm,
    .bk-step-inner .bk-textarea {
        width: 100%;
        display: block;
        box-sizing: border-box;
    }
}

/* ---- TOAST (reused from main) ---- */
.bk .toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
    z-index: 999999;
    padding: 12px 24px;
    border-radius: 14px;
    background: var(--c-card);
    color: var(--c-text);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bk .toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.bk .toast-success i {
    color: var(--c-green);
}

.bk .toast-error i {
    color: var(--c-red);
}
