/* ============================================================================
   yai-mobile.css
   Global responsive fixes for YAI on phone (<768px) + tablet (768-991px).
   Loaded as the LAST stylesheet so it can override component-level rules.

   Breakpoint policy:
     - sm  : 576px  (large phones, landscape)
     - md  : 768px  (tablet portrait)         <- nav switches to desktop here
     - lg  : 992px  (tablet landscape)
     - xl  : 1200px (desktop)
============================================================================ */

/* ---------- 1. Prevent horizontal scroll anywhere ---------- */
html, body { overflow-x: hidden; max-width: 100vw; }
img, table, video, iframe { max-width: 100%; height: auto; }

/* Logo images must keep their natural aspect ratio regardless of viewport. */
.yai-logo, .yai-mobile-nav .offcanvas-title { flex-shrink: 0; }
.yai-logo img,
.yai-mobile-nav .offcanvas-title img {
    width: auto !important;
    max-width: none !important;
    height: auto;
    object-fit: contain;
}
.yai-logo img { max-height: 44px; }
@media (max-width: 575.98px) { .yai-logo img { max-height: 36px; } }
.yai-mobile-nav .offcanvas-title img { max-height: 32px; }

/* ---------- 2. Hamburger button (visible <md only) ---------- */
.yai-hamburger {
    background: none;
    border: 0;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.4rem 0.6rem;
    color: inherit;
    cursor: pointer;
}
.yai-hamburger:focus { outline: 2px solid var(--bs-primary, #0d6efd); }
@media (min-width: 768px) { .yai-hamburger { display: none !important; } }

/* ---------- 3. Mobile nav offcanvas ---------- */
.yai-mobile-nav .offcanvas-body ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.yai-mobile-nav .offcanvas-body li a {
    display: block;
    padding: 1rem 1.25rem;
    color: #1a1a1a;
    text-decoration: none;
    font-size: 1.1rem;
    border-bottom: 1px solid #eef0f3;
}
.yai-mobile-nav .offcanvas-body li a:hover,
.yai-mobile-nav .offcanvas-body li a:focus { background: #f6f8fb; color: var(--bs-primary, #0d6efd); }
.yai-mobile-nav .offcanvas-header { border-bottom: 1px solid #eef0f3; }

/* ---------- 4. Impersonation banner: compress on small screens ---------- */
@media (max-width: 767.98px) {
    .yai-impersonate-banner { font-size: 0.85rem; }
    .yai-impersonate-banner .container {
        gap: 0.4rem !important;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    .yai-impersonate-banner strong { display: block; margin-bottom: 0.1rem; }
    .yai-impersonate-banner .btn { font-size: 0.78rem; padding: 0.2rem 0.5rem; }
}

/* ---------- 5. Impersonation modal: full screen on mobile ---------- */
@media (max-width: 767.98px) {
    #impersonateModal .modal-dialog {
        margin: 0;
        max-width: 100vw;
        height: 100vh;
    }
    #impersonateModal .modal-content { height: 100vh; border-radius: 0; }
    #impersonateModal .modal-body { padding: 0.75rem; }
    #impersonateCartChoice .modal-dialog { margin: 0.5rem; }
}

/* ---------- 6. Cart line items: stack tight on mobile ---------- */
@media (max-width: 767.98px) {
    .yai-cart-line { padding: 0.75rem 0.5rem !important; }
    .yai-cart-line .yai-cart-qty-input { width: 3rem !important; font-size: 1rem; }
    .yai-cart-line .yai-cart-img,
    .yai-cart-line img { max-width: 64px !important; }
    .yai-cart-line .yai-cart-controls {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        margin-top: 0.4rem;
    }
}

/* ---------- 7. Sales-summary checkout: single column + sticky total ---------- */
@media (max-width: 991.98px) {
    /* Right column (summary) drops below on tablet/mobile */
    .checkout-sales .col-lg-4 { position: static; }

    /* Sticky "ส่งคำสั่งซื้อ" footer on phones */
    .checkout-sales .card.sticky-lg-top { position: static; box-shadow: none; }
}
@media (max-width: 767.98px) {
    .checkout-sales .card-body { padding: 0.85rem; }
    .checkout-sales h1 { font-size: 1.25rem; }
    .checkout-sales .form-label { font-size: 0.9rem; }
}

/* ---------- 8. Account sidebar: collapse into tabs on mobile ---------- */
@media (max-width: 767.98px) {
    .yai-account-sidebar {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
        white-space: nowrap;
        scrollbar-width: thin;
    }
    .yai-account-sidebar .nav-link {
        flex: 0 0 auto;
        border: 1px solid #e5e7eb;
        border-radius: 999px;
        padding: 0.4rem 0.9rem;
    }
    .yai-account-sidebar .nav-link.active {
        background: var(--bs-primary, #0d6efd);
        color: #fff !important;
    }
}

/* ---------- 9. Product card grid: 2 cols on phone, 3 on tablet ---------- */
@media (max-width: 575.98px) {
    .yai-product-card .yai-product-name { font-size: 0.85rem; }
    .yai-product-card .yai-product-price { font-size: 0.95rem; }
}

/* ---------- 10. Tables overflow → horizontal scroll instead of layout break ---------- */
.table-responsive-mobile { -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
    table:not(.table-fit) { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------- 11. Buttons: bigger touch targets ---------- */
@media (max-width: 767.98px) {
    .btn,
    .yai-icon-btn,
    button:not(.btn-close):not(.navbar-toggler) {
        min-height: 40px;
    }
    .btn-sm { min-height: 32px; }
}

/* ---------- 12. Forms: prevent iOS zoom on focus (font-size>=16px) ---------- */
@media (max-width: 767.98px) {
    .form-control, .form-select, input, textarea, select {
        font-size: 16px !important;
    }
    .form-control-sm, .form-select-sm { font-size: 14px !important; }
}

/* ---------- 13. Footer: stack on mobile ---------- */
@media (max-width: 767.98px) {
    .yai-footer .row > [class^="col-"] { margin-bottom: 1.25rem; }
    .yai-footer h5, .yai-footer h6 { margin-top: 0.5rem; }
}

/* ---------- 14. Stepper on order-status: shrink labels ---------- */
@media (max-width: 575.98px) {
    .yai-stepper .yai-step-dot { width: 24px; height: 24px; }
    .yai-stepper .small { font-size: 0.7rem; }
}

/* ---------- 15. Sticky checkout submit bar on phones ---------- */
@media (max-width: 767.98px) {
    .yai-sticky-submit {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        background: #fff;
        border-top: 1px solid #e5e7eb;
        padding: 0.6rem 0.9rem;
        z-index: 1030;
        box-shadow: 0 -4px 14px rgba(0,0,0,.06);
    }
    .yai-sticky-submit + .yai-sticky-submit-spacer { height: 70px; }
}

/* ---------- 16. Dropdowns: align right on mobile when overflow ---------- */
@media (max-width: 575.98px) {
    .dropdown-menu-end.dropdown-menu {
        right: 0; left: auto;
        max-width: 90vw;
    }
}


/* ---------- Tablet: tighten top nav so links don't wrap to 2 lines ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .yai-navbar .container-fluid { padding-left: 1rem !important; padding-right: 1rem !important; }
    .yai-nav { gap: 0.25rem !important; flex-wrap: nowrap !important; }
    .yai-nav li a {
        white-space: nowrap;
        padding: 0.4rem 0.5rem !important;
        font-size: 0.92rem !important;
    }
    .yai-navbar .ms-auto { gap: 0.5rem !important; }
    .yai-icon-btn { padding: 0.3rem 0.45rem !important; font-size: 0.95rem !important; }
    .yai-navbar .ms-auto a[href*="/stores"] span { display: none !important; }
}
@media (min-width: 768px) and (max-width: 899.98px) {
    .yai-navbar .dropdown-toggle.yai-icon-btn { font-size: 0.85rem !important; }
    .yai-nav li a { font-size: 0.85rem !important; padding: 0.4rem 0.35rem !important; }
}


/* ---------- Tablet: hide noisy text labels so right-side icons fit ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .yai-navbar .ms-auto .dropdown-toggle span.d-none.d-md-inline { display: none !important; }
    .yai-navbar .ms-auto .btn,
    .yai-navbar .ms-auto a[href*="login"],
    .yai-navbar .ms-auto a[href*="register"] {
        padding: 0.3rem 0.55rem !important;
        font-size: 0.82rem !important;
    }
}
@media (min-width: 768px) and (max-width: 899.98px) {
    .yai-navbar .ms-auto a[href*="register"] { display: none !important; }
    .yai-navbar .ms-auto .yai-icon-btn.dropdown-toggle { font-size: 0; }
    .yai-navbar .ms-auto .yai-icon-btn.dropdown-toggle .bi { font-size: 1rem !important; }
}


/* ---------- BicBen Premium Grade badge (CSS-only replacement for image) ---------- */
.yai-premium-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #111;
    color: #fff;
    padding: 0.6rem 1.4rem;
    border-radius: 4px;
    border: 2px solid #c92a2a;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    line-height: 1;
    height: 60px;
}
.yai-premium-badge strong { color: #c92a2a; font-size: 1.55rem; letter-spacing: 0.05em; }
.yai-premium-badge span   { color: #fff;    font-size: 0.65rem; letter-spacing: 0.25em; margin-top: 0.3rem; }
@media (max-width: 575.98px) {
    .yai-premium-badge { padding: 0.5rem 1rem; height: 50px; }
    .yai-premium-badge strong { font-size: 1.25rem; }
    .yai-premium-badge span   { font-size: 0.55rem; }
}

/* ---------- Mobile navbar: keep search visible + tight icon spacing ---------- */
@media (max-width: 767.98px) {
    .yai-navbar { overflow: visible !important; }
    .yai-navbar .ms-auto { flex-wrap: nowrap !important; gap: 0.4rem !important; }
    .yai-navbar .ms-auto > * { flex-shrink: 0 !important; }
    .yai-header-account-btn {
        padding: 0.45rem 0.7rem !important;
        font-size: 0.9rem !important;
        white-space: nowrap !important;
        min-width: auto !important;
    }
    .yai-icon-btn img { display: inline-block !important; }
}
