/* =======================================================
   01-BASE-LAYOUT.CSS
   Layout Dasar, Header Terkunci Step 2 & 4 (Anti-Lag),
   Scroll Lock, Skeleton 60fps, Shadow Step 1 & Review Step 4
   ======================================================= */

html {
    overflow-x: hidden !important;
}

body {
    overflow-x: clip !important;
    overflow-y: visible !important;
    height: auto !important;
    min-height: 100vh;
    position: relative !important;
    transform: none !important;
}

main {
    overflow: visible !important;
    position: relative !important;
    height: auto !important;
    transform: none !important;
}

[data-hidden-by-step="true"] {
    display: none !important;
}

/* Ruang atas & tinggi minimal Step 2 (102px Mobile, 116px Desktop) */
#step-2 {
    overflow: visible !important;
    position: relative !important;
    height: auto !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding-top: 102px !important;
    transform: none !important;
}

#step-2-content {
    min-height: calc(100vh - 102px) !important;
    min-height: calc(100dvh - 102px) !important;
}

@media (min-width: 768px) {
    #step-2 {
        padding-top: 116px !important;
    }
    #step-2-content {
        min-height: calc(100vh - 116px) !important;
        min-height: calc(100dvh - 116px) !important;
    }
}

/* Kunci kontainer header Step 2 di urutan paling depan tanpa shadow */
#step-2-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 4030 !important;
    width: 100% !important;
    background-color: #0064D2 !important;
    box-shadow: none !important;
}

#step-2-header > div:first-child {
    height: 54px !important;
    display: flex !important;
    align-items: center !important;
    background-color: #0064D2 !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
}

#step-2-header > div:first-child > div {
    width: 100% !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

#step-2-header > div:last-child {
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid #f1f5f9 !important;
    box-shadow: none !important;
}

#step-2-header > div:last-child > div {
    width: 100% !important;
}

@media (min-width: 768px) {
    #step-2-header > div:first-child {
        height: 64px !important;
    }
    #step-2-header > div:last-child {
        height: 52px !important;
    }
}

/* Efek putar halus tombol swap */
.swap-btn-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.swap-btn:active .swap-btn-icon {
    transform: rotate(180deg);
}

/* =========================================
   LOCK SCROLL & SAFE AREA PERANGKAT MOBILE
   ========================================= */
html.lock-scroll,
body.lock-scroll {
    overflow: hidden !important;
    overscroll-behavior: none;
}

.pt-safe {
    padding-top: max(12px, env(safe-area-inset-top));
}

.pb-safe {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* Scrollbar halus */
.custom-scrollbar {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: #f8fafc;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* =========================================
   SKELETON LOADING RINGAN 60FPS
   ========================================= */
@keyframes formShimmerWave {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes cardSmoothReveal {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes badgeShine {
    0% {
        transform: translateX(-150%) skewX(-20deg);
    }
    35%, 100% {
        transform: translateX(250%) skewX(-20deg);
    }
}

.form-skeleton-box {
    position: relative !important;
    overflow: hidden !important;
    background-color: #eef2f6 !important;
    background-image: none !important;
    animation: none !important;
}

.form-skeleton-box::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.45) 40%,
        rgba(255, 255, 255, 0.75) 50%,
        rgba(255, 255, 255, 0.45) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: formShimmerWave 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    pointer-events: none;
}

#loadingOverlay {
    transition: opacity 0.3s ease !important;
}

.smooth-reveal {
    animation: cardSmoothReveal 0.22s ease-out;
}

.modern-badge-shine {
    position: relative;
    overflow: hidden;
}
.modern-badge-shine::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.35) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: badgeShine 4s infinite ease-in-out;
    pointer-events: none;
}

/* Gaya Popover Tutorial Driver.js */
.driver-popover-next-btn,
.driver-popover-done-btn {
    background-color: #0064D2 !important;
    color: white !important;
    border: none !important;
    text-shadow: none !important;
}
.driver-popover-prev-btn {
    color: #6b7280 !important;
}
.driver-popover-title {
    font-size: 14px !important;
    line-height: 1.3 !important;
}

/* Gaya Modal Syarat & Ketentuan (S&K) */
#snk-dynamic-content {
    scroll-behavior: smooth;
}
.snk-card-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    transition: all 0.2s ease;
}
.snk-card-item:hover {
    border-color: #cbd5e1;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

/* Slide horizontal filter layanan Step 2 */
#filter-container {
    display: flex;
    align-items: center;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding: 0 2px !important;
}
#filter-container::-webkit-scrollbar {
    display: none;
}
.filter-btn {
    scroll-snap-align: start;
    flex-shrink: 0;
    transition: all 0.25s ease-in-out;
}

/* Aturan blokir area Step 1 */
.dropdown-option[data-area-blocked="true"][data-block-mode="sembunyikan"] {
    display: none !important;
}
.dropdown-option[data-area-blocked="true"][data-block-mode="nonaktifkan"] {
    opacity: 0.45 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    background-color: #f8fafc !important;
    color: #94a3b8 !important;
}
.city-group[data-city-empty="true"] {
    display: none !important;
}

/* =======================================================
   MODE FOKUS & KUNCI HEADER STEP 4
   ======================================================= */
body.step-focus-mode,
body.step-focus-mode main,
body.step-focus-mode main > section,
body.step-focus-mode #step-3 {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

body.step-focus-mode #hero-section,
body.step-focus-mode #extra-sections,
body.step-focus-mode #rute-section {
    display: none !important;
}

body.step-focus-mode #booking-wrapper,
body.step-focus-mode #booking-wrapper.booking-elevated {
    margin-top: 0 !important;
}

#step-4 {
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding-top: 56px !important;
}

@media (min-width: 768px) {
    #step-4 {
        padding-top: 60px !important;
    }
}

#step-4-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 4500 !important;
    background-color: #0064D2 !important;
    box-shadow: none !important;
    pointer-events: auto !important;
}

#btn-back-step2-pay {
    position: relative !important;
    z-index: 10 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    min-width: 36px !important;
    min-height: 36px !important;
}

/* =======================================================
   HILANGKAN RUANG KOSONG BAWAH KHUSUS RINCIAN SEBELUM BAYAR
   (Tanpa selector :has() agar ringan & anti-lag di HP)
   ======================================================= */
body.step-focus-mode.is-pre-payment-view {
    min-height: 0 !important;
    height: auto !important;
}

body.step-focus-mode.is-pre-payment-view main,
body.step-focus-mode.is-pre-payment-view main > section,
body.step-focus-mode.is-pre-payment-view #booking-wrapper,
body.step-focus-mode.is-pre-payment-view #step-3 {
    min-height: 0 !important;
    height: auto !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    flex: 0 0 auto !important;
}

#step-4.is-pre-payment-view {
    min-height: 0 !important;
    height: auto !important;
    padding-bottom: 14px !important;
}

/* =======================================================
   HEADER MODAL RINGKAS, FOOTER PADAT & TOMBOL BATAL/LANJUT 40PX
   ======================================================= */
body #detail-modal > div:first-child,
body #seat-modal > div:first-child {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    min-height: 0 !important;
}

body #detail-modal > div:first-child button,
body #seat-modal > div:first-child button {
    width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
}

/* Tombol Ubah Alamat Pulang tetap ringkas */
#btn-edit-modal-jemput-pulang,
#btn-edit-modal-antar-pulang,
#btn-edit-seat-jemput-pulang,
#btn-edit-seat-antar-pulang {
    height: auto !important;
    min-height: 30px !important;
    padding: 5px 10px !important;
    font-size: 11.5px !important;
    line-height: 1.2 !important;
}

/* Pembungkus footer tombol dipadatkan */
body #detail-modal > div:last-child,
body #seat-modal > div:last-child {
    height: auto !important;
    padding-top: 8px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
}

body #detail-modal > div:last-child > div,
body #seat-modal > div:last-child > div {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Tombol Batal & Lanjut 40px */
body #detail-modal > div:last-child button,
body #seat-modal > div:last-child button,
body #btn-lanjut-modal,
body #btn-confirm-seats {
    min-height: 40px !important;
    height: 40px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    font-size: 14px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* =======================================================
   PERBESARAN HURUF KHUSUS RINCIAN SEBELUM LANJUT BAYAR
   ======================================================= */
#pay-summary-card.is-pre-payment-review .pay-label-faktur {
    font-size: 13.5px !important;
    line-height: 1.3 !important;
}

#pay-summary-card.is-pre-payment-review #pay-invoice-num {
    font-size: 17px !important;
    line-height: 1.3 !important;
}

#pay-summary-card.is-pre-payment-review .pay-btn-lihat-detail {
    font-size: 15px !important;
}

#pay-summary-card.is-pre-payment-review #pay-order-detail {
    font-size: 15px !important;
    line-height: 1.45 !important;
    padding: 14px !important;
}

#pay-summary-card.is-pre-payment-review #pay-det-tipe-perjalanan {
    font-size: 13.5px !important;
    padding: 3px 11px !important;
}

#pay-summary-card.is-pre-payment-review .pay-label-total {
    font-size: 13.5px !important;
    line-height: 1.3 !important;
}

#pay-summary-card.is-pre-payment-review #pay-total-amount {
    font-size: 22px !important;
    line-height: 1.25 !important;
}

#pay-summary-card.is-pre-payment-review .pay-btn-salin-total {
    font-size: 14.5px !important;
}

@media (min-width: 640px) {
    #pay-summary-card.is-pre-payment-review #pay-invoice-num {
        font-size: 18px !important;
    }
    #pay-summary-card.is-pre-payment-review #pay-order-detail {
        font-size: 16px !important;
    }
    #pay-summary-card.is-pre-payment-review #pay-total-amount {
        font-size: 24px !important;
    }
}

.map-suggestion-item.is-active {
    background-color: #EFF6FF;
}

/* Sembunyikan tombol zoom (+/-) pada Peta Leaflet */
#leaflet-map-container .leaflet-control-zoom {
    display: none !important;
}

/* Pastikan Toast selalu tampil di atas pop-up Peta & Dropdown */
#toast {
    z-index: 99995 !important;
}

/* Shadow halus kartu formulir Step 1 agar terlihat sedikit terangkat */
#step-1,
#form-wrapper {
    box-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
}

#step-1-content {
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
    box-shadow: 0 10px 24px -8px rgba(15, 23, 42, 0.10), 0 2px 6px -1px rgba(15, 23, 42, 0.04) !important;
    filter: none !important;
    -webkit-filter: none !important;
}

#step-1,
#step-2,
#detail-modal,
#seat-modal,
#map-picker-modal {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Lebar form Step 1 seukuran ponsel (400px) & tengah di Tablet/Desktop */
@media (min-width: 768px) {
    #step-1 #form-wrapper,
    #step-1 #step-1-content,
    #booking-wrapper .booking-glass-overlay {
        max-width: 400px !important;
        width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Validasi inline field */
@keyframes fieldShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.field-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px #ef4444 !important;
}

.field-invalid-input {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px #ef4444 !important;
    background-color: #fef2f2 !important;
}

.field-shake {
    animation: fieldShake 0.28s ease-in-out;
}

.field-error-msg {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #dc2626;
}
