/* ==========================================================================
   ILMCode Storefront -- responsive rules
   Loaded after style.css, so these overrides win at small widths.
   ========================================================================== */

/* Hidden at every width by default; the header-switch block below turns it
   on only where the drawer it belongs to can actually open. */
.mobile-menu-scrim { display: none; }

@media (max-width: 1199px) {
    .main-search { max-width: 420px; }
    .header-list-items { gap: 14px; }
}

@media (max-width: 991px) {
    .header-list-items a span { display: none; }
    .header-list-items i { font-size: 18px; }
    .cat_img img, .side_cat_img img { width: 52px; height: 52px; }
    .service_info { padding: 14px 8px; }
    .service_info > div { margin-bottom: 12px; }
}

/* ==========================================================================
   Header switch: desktop nav <-> phone header + drawer.

   Both halves flip together at the SAME width (Bootstrap's lg breakpoint) so
   there is no gap in between. There used to be one: the desktop header only
   hid below 767px while the compact phone header only showed below 767px
   too -- correct at the boundary, but the numbers matched by coincidence of
   both saying "767", not because anything tied them together, and a tablet
   in the 768-991px band got the FULL desktop header (all-categories flyout,
   the main nav links, the hotline) squeezed into a width that never fit it,
   which is what wrapped/overflowed into an unreadable strip.
   ========================================================================== */
@media (max-width: 991.98px) {
    /* .first-nav / .second-nav / .third-nav are the drawer's own category
       tree and live inside .mobile-menu, which is itself display:none above
       this breakpoint -- hiding them here as well left the phone drawer with
       no categories in it at all. */
    .main-header, .hidetosm,
    .mobile_view_display_none { display: none !important; }

    .mobile-header {
        display: block;
        background: #fff;
        box-shadow: var(--shop-shadow);
        position: sticky; top: 0; z-index: 120;
        padding: 9px 0;
    }
    .mobile-header .container { display: flex; align-items: center; gap: 12px; }
    .mobile-logo { display: block; flex: 1 1 auto; }
    .mobile-logo img { max-height: 38px; }
    .mobile-search { display: block; padding: 8px 0 2px; }
    .mobile-search form { display: flex; }
    .mobile-search input {
        flex: 1 1 auto; height: 38px; padding: 0 13px;
        border: 1.5px solid var(--shop-line); border-right: 0;
        border-radius: var(--shop-radius) 0 0 var(--shop-radius); outline: none;
    }
    /* was .msearch_click, which only ever hit the input by mistake */

    .menu-bar { font-size: 21px; color: var(--shop-ink); }

    /* Slide-in drawer. #siteHeader (.sh, site-chrome.css) is itself sticky at
       z-index: 900 -- tying the drawer at the same number let DOM order
       decide the winner, and .sh (included further down master.blade.php)
       always won, painting over the drawer's own logo row and close button
       exactly where a thumb would reach for them. The drawer has to clear
       .sh by a real margin, not tie it, since it's meant to sit above the
       whole page -- including the header -- while open. */
    .mobile-menu {
        /* Flex column so .mobile-menu-account (margin-top:auto) is pinned to
           the actual bottom of the drawer even when the list above it is
           shorter than the viewport -- sticky positioning alone only takes
           over once there's enough scrollable height to push it there. */
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 280px; max-width: 84vw;
        background: #fff;
        box-shadow: 4px 0 24px rgba(16, 24, 40, .18);
        transform: translateX(-100%);
        transition: transform .28s ease;
        z-index: 920;
        overflow-y: auto;
    }
    .mobile-menu.open { transform: translateX(0); }
    /* Same dark panel as #siteHeader's own bar, so the drawer reads as one
       continuous themed panel with the header above it, not a plain white
       strip glued under a dark one -- see site-chrome.css's --sc-navy / --sc-grad. */
    .mobile-menu-logo {
        display: flex; align-items: center; justify-content: space-between;
        padding: 14px 16px; border-bottom: 1px solid var(--sc-line, rgba(148,163,184,.16));
        position: sticky; top: 0; z-index: 2;
        background: var(--sc-navy, #0b1120);
    }
    .mobile-menu-logo img { max-height: 32px; }
    .mobile-menu-close {
        width: 32px; height: 32px; flex: 0 0 auto;
        display: flex; align-items: center; justify-content: center;
        border-radius: 999px; background: rgba(255, 255, 255, .08);
        border: 1px solid var(--sc-line, rgba(148,163,184,.16));
        font-size: 15px; cursor: pointer; color: #e2e8f0;
        transition: background .15s;
    }
    .mobile-menu-close:hover { background: rgba(255, 255, 255, .16); }

    /* Pinned to the very bottom of the drawer (sticky, same mechanic as the
       logo row's sticky top) -- a login/register CTA that stays reachable
       without scrolling through however long the category list gets. */
    .mobile-menu-account {
        position: sticky; bottom: 0; z-index: 2;
        display: flex; gap: 8px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
        background: var(--sc-navy, #0b1120);
        border-top: 1px solid var(--sc-line, rgba(148,163,184,.16));
        margin-top: auto;
    }
    .mml-account-btn {
        flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 8px;
        height: 42px; border-radius: 11px;
        font: 700 13.5px/1 var(--sc-font, inherit); text-decoration: none;
        background: var(--sc-grad, var(--shop-primary));
        color: #fff; border: 1px solid transparent;
        transition: transform .15s, box-shadow .15s;
    }
    .mml-account-btn:hover { color: #fff; transform: translateY(-1px); }
    .mml-account-btn-outline {
        background: transparent; border-color: var(--sc-line, rgba(148,163,184,.3));
        color: #e2e8f0;
    }
    .mml-account-avatar {
        display: inline-block; width: 24px; height: 24px; flex: 0 0 auto;
        border-radius: 50%; background: rgba(255, 255, 255, .22); object-fit: cover;
    }

    /* Dark scrim behind the open drawer -- tap it to close, same as the
       filter drawer's own backdrop (#filterBackdrop). display:none by
       default is set once, outside this media query, so a desktop visitor
       never has even an empty fixed-position div sitting over the page.
       Above .sh (900) too, so the header dims along with the rest of the
       page instead of staying fully bright above the scrim. */
    .mobile-menu-scrim {
        display: block;
        position: fixed; inset: 0;
        background: rgba(16, 24, 40, .5);
        z-index: 910;
        opacity: 0; visibility: hidden;
        transition: opacity .25s ease, visibility .25s ease;
    }
    .mobile-menu-scrim.show { opacity: 1; visibility: visible; }

    /* Store Management -> Menu -> Main menu -- the ONE list in the drawer now
       (mirrors #siteHeader's .sh-nav; see master.blade.php). */
    .mobile-menu-links li a {
        display: flex; align-items: center; gap: 10px;
        padding: 11px 14px;
        border-bottom: 1px solid #f0f2f4;
        font-size: 13.5px; font-weight: 600; color: var(--shop-ink);
    }
    /* Brand-colour accent on every row, including the mega items' nested
       subcategory/childcategory rows below -- one consistent touch (a left
       border + faint tint in the same indigo #siteHeader uses) rather than a
       different effect per row type. */
    .mobile-menu-links li a,
    .menu-subcategory-name, .menu-childcategory-name {
        border-left: 3px solid transparent;
        transition: background .15s, border-color .15s, color .15s;
    }
    .mobile-menu-links li a:hover,
    .menu-subcategory-name:hover, .menu-childcategory-name:hover {
        background: rgba(79, 70, 229, .07);
        border-left-color: var(--shop-primary);
        color: var(--shop-primary);
    }
    .mobile-menu-links i { width: 16px; text-align: center; color: var(--shop-primary); font-size: 13px; }
    /* A category link's own picture instead of a Font Awesome icon -- see
       frontEnd/layouts/partials/menu-glyph.blade.php. */
    .mobile-menu-links .menu-glyph-img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }

    /* A main-menu item with real children, OR a category item with no menu
       children of its own (it gets its live subcategory tree instead, same
       data the desktop mega menu reads -- see master.blade.php's $mega) --
       either way, a chevron expands its own list right there in the drawer.

       .mml-row (NOT the <li>) is the toggle's position:relative anchor, at
       both nesting levels. The <li> also holds the nested <ul> once it's
       expanded, and that list can grow far taller than the row itself (nine
       childcategories, say) -- anchoring the toggle to the whole <li> with
       top:0;bottom:0 stretched it across that expanded height too, landing
       the chevron at the vertical centre of the WHOLE expanded block instead
       of next to its own row. .mml-row holds only the row (the link + its
       toggle), so the toggle always lands on its own row regardless of
       what's expanded below it. */
    .mobile-menu-links .mml-row { position: relative; }
    .mobile-menu-links li.has-submenu > .mml-row > a,
    .parent-subcategory > .mml-row > a { padding-right: 44px; }
    .mobile-submenu-toggle,
    .menu-subcategory-toggle {
        position: absolute; right: 0; top: 0; bottom: 0;
        width: 44px; display: flex; align-items: center; justify-content: center;
        cursor: pointer; color: var(--shop-muted);
    }
    .mobile-submenu-toggle i, .menu-subcategory-toggle i { transition: transform .2s, color .15s; }
    .mobile-submenu-toggle.open i, .menu-subcategory-toggle.active i { transform: rotate(180deg); }
    .menu-subcategory-toggle.active { color: var(--shop-primary); }
    .mobile-submenu li a { padding-left: 30px; font-size: 13px; font-weight: 500; }

    /* Mega item's own nested level: subcategory rows inside .mobile-submenu,
       and (one level deeper still) childcategory rows inside .third-nav.
       Specificity has to beat ".mobile-submenu li a" above on padding-left,
       or every nested row collapses to the same 30px indent regardless of
       depth -- these are two classes deep (or more), so they win reliably. */
    .mobile-submenu .menu-subcategory-name,
    .mobile-submenu .menu-childcategory-name {
        display: flex; align-items: center; justify-content: flex-start; gap: 8px;
        padding: 10px 14px;
        border-bottom: 1px solid #f0f2f4;
        font-size: 13px; font-weight: 500;
    }
    .mobile-submenu .parent-subcategory > .mml-row > .menu-subcategory-name { padding-left: 30px; }
    .mobile-submenu .third-nav .menu-childcategory-name { padding-left: 46px; font-size: 12.5px; color: var(--shop-muted); }

    .mobile-social-link { padding: 14px; }
}

/* Phone-only tweaks -- font size, card padding, floating buttons. The header
   switch above already covers the header/drawer; everything phone-specific
   that is not about the header stays scoped to an actual phone width. */
@media (max-width: 767px) {
    body { font-size: 13.5px; }

    /* Two products per row on phones. */
    .product_item { padding-left: 6px; padding-right: 6px; }
    /* Bigger than it was: the name is what a shopper scans first. */
    .pro_name { font-size: 13.5px; min-height: 38px; }
    .pro_price { font-size: 14px; }
    .cart_btn, .addcartbutton { padding: 8px 10px; font-size: 12px; }

    .section-title-name, .sec_title h2, .sec_title h3 { font-size: 15.5px; }

    .whatsapp-float { width: 46px; height: 46px; right: 12px; bottom: 68px; }
    .whatsapp-float i { font-size: 23px; }
    .scroll-top-btn { width: 40px; height: 40px; right: 12px; bottom: 12px; }
    .call_now_btn { left: 12px; bottom: 12px; padding: 9px 15px; font-size: 12.5px; }

    .cart-dialog { width: calc(100vw - 24px); right: -8px; }

    footer { margin-top: 22px; }
    .footer-top { padding: 24px 0 16px; }
}

@media (max-width: 480px) {
    .cat_img img, .side_cat_img img { width: 44px; height: 44px; }
    .cat_name { font-size: 11.5px; }
    .timer_inner { min-width: 28px; padding: 3px 6px; font-size: 12px; }
}

/* Backdrop behind the mobile drawer. */
.mobile-menu-backdrop {
    position: fixed; inset: 0;
    background: rgba(16, 24, 40, .45);
    z-index: 490;
    display: none;
}
.mobile-menu-backdrop.show { display: block; }
