/* ==========================================================================
   App-style mobile experience (phones & small tablets, < 992px)
   Loaded after style.css / responsive.css
   ========================================================================== */

/* Never let anything push the page wider than the screen */
html, body { max-width: 100%; overflow-x: clip; }
img, video, iframe { max-width: 100%; }
/* Grid/flex children may shrink below their content width (prevents sideways overflow) */
.fb-banner > *, .pb-banner > *, .bd-grid > *, .ex-cats > *, .row > * { min-width: 0; }

.app-tabbar, .app-sheet, .app-sheet-backdrop { display: none; }

/* Page titles on the blue hero were dark navy on dark blue: make them readable everywhere */
.slider_section h1 { color: #fff; }
.slider_section h1 span { color: #ffd43b; }
.slider_section > .container p, .slider_section .detail-box p { color: rgba(255, 255, 255, .88); }

@media (max-width: 991.98px) {
    :root { --tabbar-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); }

    body {
        padding-bottom: calc(var(--tabbar-h) + var(--safe-b)) !important;
        -webkit-tap-highlight-color: transparent;
        text-size-adjust: 100%;
        -webkit-text-size-adjust: 100%;
    }

    /* ---- Compact sticky top bar (the bottom bar replaces the hamburger menu) ---- */
    .header_section { padding-top: env(safe-area-inset-top, 0px); }
    .header_section .navbar { padding: 8px 0; min-height: 54px; }
    .header_section .navbar-brand { font-size: 1.2rem !important; margin: 0; }
    .header_section .navbar-toggler,
    .header_section .navbar-collapse { display: none !important; }

    /* ---- Bottom tab bar ---- */
    .app-tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
        background: rgba(255, 255, 255, .97); backdrop-filter: saturate(180%) blur(12px);
        border-top: 1px solid #e5e7eb; box-shadow: 0 -4px 18px rgba(15, 23, 42, .06);
    }
    .app-tab {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        color: #64748b; text-decoration: none; font-size: 11px; font-weight: 600; letter-spacing: .01em;
        background: none; border: 0; padding: 6px 2px; position: relative; min-width: 0;
    }
    .app-tab i { font-size: 19px; line-height: 1; }
    .app-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    .app-tab.active { color: #1e3c72; }
    .app-tab.active::before {
        content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
        width: 34px; height: 3px; border-radius: 0 0 3px 3px; background: #1e3c72;
    }
    .app-tab:active { background: #f1f5f9; }

    /* ---- "More" bottom sheet ---- */
    .app-sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 1040; background: rgba(15, 23, 42, .45); opacity: 0; transition: opacity .2s; }
    .app-sheet {
        display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1050;
        background: #fff; border-radius: 20px 20px 0 0; padding: 10px 16px calc(18px + var(--safe-b));
        box-shadow: 0 -10px 30px rgba(15, 23, 42, .18); transform: translateY(100%); transition: transform .22s ease-out;
        max-height: 85vh; overflow-y: auto;
    }
    .app-sheet[hidden], .app-sheet-backdrop[hidden] { display: none; }
    body.app-sheet-open .app-sheet { transform: translateY(0); }
    body.app-sheet-open .app-sheet-backdrop { opacity: 1; }
    body.app-sheet-open { overflow: hidden; }
    .app-sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: #cbd5e1; margin: 2px auto 14px; }
    .app-sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .app-sheet-grid a {
        display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px;
        border-radius: 14px; color: #1f2937; text-decoration: none; font-size: 12.5px; font-weight: 600; text-align: center;
    }
    .app-sheet-grid a i {
        width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
        background: #eef4ff; color: #1e3c72; font-size: 19px;
    }
    .app-sheet-grid a:active { background: #f1f5f9; }
    .app-sheet-account { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid #eef0f3; }
    .app-sheet-account form { margin: 0; }
    .app-sheet-btn {
        display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px;
        border-radius: 12px; border: 1px solid #d1d5db; background: #fff; color: #1f2937; font-weight: 700; font-size: 15px; text-decoration: none;
    }
    .app-sheet-btn.primary { background: #1e3c72; border-color: #1e3c72; color: #fff; }

    /* ---- Page heroes: shorter on phones so content starts sooner ---- */
    .slider_section { padding: 34px 0 30px !important; }
    .slider_section h1 { font-size: 1.6rem !important; line-height: 1.25; margin-bottom: 6px; }
    .slider_section p { font-size: .98rem; margin-bottom: 0; }

    /* ---- Comfortable touch targets & no iOS zoom on focus ---- */
    input, select, textarea, .form-control, .form-select { font-size: 16px !important; }
    .btn, button, .form-control, .form-select { min-height: 44px; }
    .btn-sm { min-height: 36px; }
    .container { padding-left: 16px; padding-right: 16px; }

    /* Tables scroll sideways inside their box instead of stretching the page */
    .table-responsive, .tb-table-wrap, .ex-table-wrap, .db-table-wrap { -webkit-overflow-scrolling: touch; }

    /* Keep floating things above the tab bar */
    #mobileAppPopup { bottom: calc(var(--tabbar-h) + var(--safe-b)) !important; z-index: 1025 !important; padding: 10px 14px !important; }
    #mobileAppPopup .popup-icon img { width: 42px !important; height: 42px !important; }
    #mobileAppPopup .popup-content h3 { font-size: 15px !important; margin: 0 !important; }
    #mobileAppPopup .popup-content p { font-size: 12px !important; line-height: 1.35; }
    #mobileAppPopup .download-btn { padding: 8px 12px !important; font-size: 13px !important; }
    #mobileAppPopup > div > div { gap: 10px !important; }
    #mobileAppPopup .popup-close-btn { top: -2px !important; right: -4px !important; width: 26px !important; height: 26px !important; font-size: 16px !important; }
    body.app-sheet-open #mobileAppPopup { display: none !important; }
    .db-toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px) !important; }
    .bd-price { position: static !important; }
}

@media (max-width: 575.98px) {
    .app-sheet-grid a { font-size: 11.5px; }
    .slider_section h1 { font-size: 1.45rem !important; }
}

/* Installed as an app ("Add to Home Screen"): no browser bar, so give the header the status-bar area */
@media (display-mode: standalone) {
    .header_section { padding-top: env(safe-area-inset-top, 0px); }
}
