/* =============================================================================
   DSI FRANCE — Mobile & Responsive Overrides
   themes/dsifrance/assets/css/responsive.css

   Scope  : mobile header bar, nav drawer, user dropdown, tablet tweaks
   Rule   : desktop styles live in custom.css — this file is mobile-first only
   Breakpoints:
       mobile  : max-width 767px
       tablet  : max-width 991px
   ============================================================================= */


/* ─────────────────────────────────────────────────────────────────────────────
   BACKDROP OVERLAY (shared — injected by JS when drawer opens)
   ───────────────────────────────────────────────────────────────────────────── */

.dsi-mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    /* z-index must stay BELOW #header's stacking context so it never covers the drawer */
    z-index: 998;
    /* No backdrop-filter — it would blur the drawer too since the drawer is inside #header */
}

/* Prevent body scroll when drawer is open */
body.dsi-nav-open {
    overflow: hidden;
}

/* Ensure the drawer (position:fixed, z-index:9999) always paints above the backdrop (z-index:998).
   #header must NOT create its own stacking context — keep position/z-index off it on mobile. */
@media (max-width: 767px) {
    #header {
        position: relative;
        z-index: auto;
        margin-top: 0;
    }
}


/* =============================================================================
   MOBILE NAV DRAWER
   ============================================================================= */

@media (max-width: 767px) {

    /* ── Drawer container ── */
    #mobile_top_menu_wrapper {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: min(82vw, 300px) !important;
        height: 100dvh !important;
        height: 100vh !important;
        /* fallback */
        overflow-y: auto !important;
        overflow-x: hidden;
        background: #fff !important;
        z-index: 9999 !important;
        padding: 0 !important;
        margin: 0 !important;
        border-right: 1px solid var(--color-gray-300);
        box-shadow: 6px 0 32px rgba(0, 0, 0, 0.18);
        /* row class negative-margin reset */
        flex: unset !important;
        max-width: unset !important;
        /* Slide-in animation fires when display:block is set by JS */
        animation: dsiDrawerIn 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    }

    #mobile_top_menu_wrapper.dsi-drawer-closing {
        animation: dsiDrawerOut 0.25s cubic-bezier(0.55, 0.055, 0.675, 0.19) both;
    }

    @keyframes dsiDrawerIn {
        from {
            transform: translateX(-100%);
            opacity: 0.7;
        }

        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    @keyframes dsiDrawerOut {
        from {
            transform: translateX(0);
            opacity: 1;
        }

        to {
            transform: translateX(-100%);
            opacity: 0.7;
        }
    }

    /* ── Drawer header bar (logo + close button) ── */
    .dsi-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 14px;
        background: var(--color-primary);
        position: sticky;
        top: 0;
        z-index: 2;
        flex-shrink: 0;
    }

    .dsi-drawer-logo {
        display: flex;
        align-items: center;
        text-decoration: none;
    }

    /* Force white version of the logo (teal bg in drawer header) */
    .dsi-drawer-logo img {
        height: 30px;
        width: auto;
        max-width: 120px;
        object-fit: contain;
        filter: brightness(0) invert(1);
    }

    .dsi-drawer-logo a {
        display: flex;
        align-items: center;
    }

    .dsi-drawer-logo a img {
        height: 30px;
        width: auto;
        max-width: 120px;
        object-fit: contain;
        filter: brightness(0) invert(1);
    }

    /* Close button */
    .dsi-drawer-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: none;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 50%;
        cursor: pointer;
        color: #fff;
        /* Same transition as cart-sidebar close button */
        transition: background 0.3s ease, transform 0.3s ease;
        flex-shrink: 0;
        padding: 0;
    }

    .dsi-drawer-close:hover,
    .dsi-drawer-close:focus {
        background: rgba(255, 255, 255, 0.28);
        transform: rotate(90deg);
        outline: none;
    }

    .dsi-drawer-close .material-icons {
        font-size: 20px;
        color: #fff;
        line-height: 1;
    }

    /* ── Top-level menu item rows ── */
    #mobile_top_menu_wrapper .top-menu>li {
        border-bottom: 1px solid var(--color-gray-250);
        display: block;
    }

    /* Top-level links */
    #mobile_top_menu_wrapper .top-menu a[data-depth="0"] {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 15px 16px !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        color: var(--color-accent-blue) !important;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        border-bottom: none !important;
        background: transparent;
        transition: background 0.15s ease, color 0.15s ease;
        line-height: 1.3;
    }

    #mobile_top_menu_wrapper .top-menu a[data-depth="0"]:hover {
        background: var(--bg-light-teal);
        color: var(--color-primary-darker) !important;
    }

    #mobile_top_menu_wrapper .top-menu li.current>a[data-depth="0"] {
        color: var(--color-primary) !important;
        background: var(--bg-light-teal);
    }

    /* ── Chevron span: always at the END of the flex row ── */
    /* HTML puts .float-xs-right BEFORE the label text, so order:2 pushes it right */
    #mobile_top_menu_wrapper .top-menu a[data-depth="0"] .float-xs-right {
        order: 2;
    }

    /* ── Expand / Collapse toggle icons ── */
    #mobile_top_menu_wrapper .float-xs-right {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        pointer-events: none;
        /* the parent <a> handles the click */
    }

    #mobile_top_menu_wrapper .collapse-icons {
        display: flex;
        pointer-events: auto;
    }

    #mobile_top_menu_wrapper .collapse-icons {
        transition: background 0.25s ease, transform 0.25s ease;
        border-radius: 50%;
        padding: 2px;
    }

    /* Hover on the row: highlight the chevron button */
    /*#mobile_top_menu_wrapper .top-menu a[data-depth="0"]:hover .collapse-icons,
    #mobile_top_menu_wrapper .top-menu .sub-menu a:hover .collapse-icons {
        background: rgba(19, 168, 189, 0.12);
    }*/

    #mobile_top_menu_wrapper .collapse-icons .material-icons {
        font-size: 18px;
        color: var(--color-gray-700);
        transition: color 0.2s ease, transform 0.25s ease;
        display: inline-block;
    }

    /* Hover: rotate the chevron slightly (same style as sidebar) */
    #mobile_top_menu_wrapper .top-menu a[data-depth="0"]:hover .collapse-icons .material-icons,
    #mobile_top_menu_wrapper .top-menu .sub-menu a:hover .collapse-icons .material-icons {
        color: var(--color-primary);
        transform: rotate(90deg);
    }

    /* Show/hide add / remove chevrons — driven by aria-expanded (set manually by JS) */
    #mobile_top_menu_wrapper .collapse-icons .material-icons.remove {
        display: none;
    }

    #mobile_top_menu_wrapper .collapse-icons[aria-expanded="true"] .material-icons.add {
        display: none;
    }

    #mobile_top_menu_wrapper .collapse-icons[aria-expanded="true"] .material-icons.remove {
        display: inline;
        color: var(--color-primary);
    }

    /* When expanded: rotate the remove icon back to flat (flipped state = already a different icon) */
    #mobile_top_menu_wrapper .collapse-icons[aria-expanded="true"] .material-icons.remove {
        transform: rotate(0deg);
    }

    /* ── Subcategory panel ── */
    #mobile_top_menu_wrapper .top-menu .sub-menu {
        position: static !important;
        background: var(--color-gray-50) !important;
        border-top: 2px solid var(--color-primary);
        box-shadow: none !important;
        width: 100% !important;
        min-width: 100% !important;
        padding: 4px 0 !important;
        /* Disable the desktop opacity/visibility transition — we toggle .in directly */
        transition: none !important;
    }

    /* Collapsed: hidden. Targets all levels (.collapse) not just top sub-menu.
       Includes :not(.collapsing) to allow Bootstrap's own height animation if JS fix is missing,
       but usually we toggle .in/.show directly for instant response. */
    #mobile_top_menu_wrapper .top-menu .collapse:not(.in):not(.show):not(.collapsing) {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    /* Expanded: fully visible, instant — no animation flicker.
       Supports both Bootstrap 3 (.in) and Bootstrap 4/5 (.show) classes. */
    #mobile_top_menu_wrapper .top-menu .collapse.in,
    #mobile_top_menu_wrapper .top-menu .collapse.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Sub-menu list items — always vertical */
    #mobile_top_menu_wrapper .top-menu .sub-menu ul,
    #mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"] {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    #mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"]>li {
        float: none !important;
        display: block !important;
        margin: 0 !important;
        border-bottom: 1px solid var(--color-gray-300);
    }

    #mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"]>li:last-child {
        border-bottom: none;
    }

    /* Sub-menu links */
    #mobile_top_menu_wrapper .top-menu .sub-menu li>a {
        display: flex !important;
        align-items: center;
        gap: 10px;
        padding: 12px 16px 12px 22px !important;
        font-size: 13px !important;
        font-weight: 500 !important;
        color: var(--color-text-primary) !important;
        border-bottom: none !important;
        border-left: 3px solid transparent;
        background: transparent;
        transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    /* No dot bullets — chevron (already blue/teal) is the only right-side indicator */
    #mobile_top_menu_wrapper .top-menu .sub-menu li>a::before,
    #mobile_top_menu_wrapper .top-menu .sub-menu li>a::after {
        content: none;
    }

    /* Chevron for sub-items that have children — pushed to the right end */
    #mobile_top_menu_wrapper .top-menu .sub-menu li>a .float-xs-right {
        order: 2;
        margin-left: auto;
    }

    #mobile_top_menu_wrapper .top-menu .sub-menu li>a:hover {
        background: var(--bg-light-teal) !important;
        border-left-color: var(--color-primary);
        color: var(--color-primary-darker) !important;
    }

    #mobile_top_menu_wrapper .top-menu .sub-menu li>a:hover::after {
        opacity: 1;
    }

    /* ── Bottom extras (currency, language, contact) ── */
    .js-top-menu-bottom {
        padding: 14px 16px;
        border-top: 1px solid var(--color-gray-300);
        background: var(--color-gray-50);
        margin-top: auto;
    }

    #mobile_top_menu_wrapper .js-top-menu-bottom a {
        font-size: 12px !important;
        color: var(--color-gray-800) !important;
        display: block;
        padding: 5px 0;
    }

}


/* =============================================================================
   MOBILE HEADER BAR
   ============================================================================= */

@media (max-width: 767px) {

    .footer-block-title {
        justify-content: center;
        text-align: center;
    }

    #header .header-nav {
        padding: 6px 0;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    }

    #header .header-nav .mobile {
        display: flex !important;
        align-items: center;
        padding: 4px 10px;
        width: 100%;
        box-sizing: border-box;
        float: none !important;
        position: relative;
        /* container for the absolute search block */
    }

    /* Burger button */
    #menu-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.15s ease;
        flex-shrink: 0;
        order: 0;
    }

    #menu-icon:active {
        background: var(--bg-light-teal);
    }

    #menu-icon .material-icons {
        font-size: 45px;
        color: var(--color-primary);
        line-height: 1;
    }

    /* Centered logo */
    #_mobile_logo {
        flex: 1;
        text-align: center;
        order: 1;
        float: none !important;
    }

    #_mobile_logo img {
        height: 34px;
        width: auto;
        max-width: 130px;
    }

    /* Right-side icons */
    #_mobile_search_toggle {
        order: 2;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        cursor: pointer;
        margin-top: 1rem;
    }

    #_mobile_search_toggle .material-icons {
        font-size: 35px;
        color: var(--color-primary);
    }

    #_mobile_user_info {
        order: 3;
        display: flex;
        align-items: center;
        float: none !important;
    }

    #_mobile_cart {
        order: 4;
        display: flex;
        align-items: center;
        float: none !important;
    }

    /* Cart badge */
    #_mobile_cart .cart-products-count {
        font-size: 11px;
        min-width: 18px;
        height: 18px;
    }

    /* ── Mobile Search Block Overlay ── */
    .dsi-mobile-search {
        display: none;
        /* hidden by default, toggled via .dsi-search-active */
        position: absolute;
        inset: 0;
        background: #fff;
        z-index: 100;
        align-items: center;
        padding: 0 12px;
        gap: 10px;
        animation: dsiFadeIn 0.2s ease;
    }

    .mobile.dsi-search-active .dsi-mobile-search {
        display: flex;
    }

    /* Hide normal header children when search is active */
    .mobile.dsi-search-active> :not(.dsi-mobile-search) {
        visibility: hidden !important;
        pointer-events: none !important;
    }

    #_mobile_search_widget {
        flex: 1;
    }

    #_mobile_search_widget #search_widget {
        width: 100% !important;
        margin: 0 !important;
    }

    #_mobile_search_widget form {
        display: flex;
        align-items: center;
        background: var(--color-gray-100);
        border-radius: 20px;
        padding: 4px 14px;
        width: 100%;
    }

    #_mobile_search_widget input[type="text"] {
        flex: 1;
        border: none;
        background: transparent;
        height: 36px;
        padding: 0;
        font-size: 14px;
        outline: none;
    }

    #search_widget input[type="text"]:focus {
        border: none;
        box-shadow: none !important;
    }



    #_mobile_search_widget .material-icons.search {
        order: -1;
        /* move icon to left of input */
        margin-right: 8px;
        font-size: 20px;
        color: var(--color-gray-600);
    }

    #_mobile_search_close {
        border: none;
        background: none;
        color: var(--color-gray-700);
        padding: 4px;
        cursor: pointer;
    }

    #_mobile_search_close .material-icons {
        font-size: 24px;
    }

    @keyframes dsiFadeIn {
        from {
            opacity: 0;
            transform: translateY(-4px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}


/* =============================================================================
   MOBILE USER DROPDOWN
   ============================================================================= */

@media (max-width: 767px) {

    /* Drop as a fixed panel, full-width minus gutters */
    #_mobile_user_info .dsi-user-menu,
    #_desktop_user_info .dsi-user-menu {
        position: fixed !important;
        top: 58px !important;
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        min-width: unset !important;
        max-height: calc(100dvh - 74px);
        max-height: calc(100vh - 74px);
        overflow-y: auto;
        border-radius: 14px !important;
        box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22) !important;
        z-index: 9001 !important;
        transform-origin: top right !important;
    }

    /* Identity: stack name + badge vertically */
    .dsi-menu-identity {
        flex-direction: column !important;
        gap: 4px !important;
        min-width: 0;
    }

    /* Name: allow wrap */
    .dsi-menu-name {
        white-space: normal !important;
        word-break: break-word;
        font-size: 13px !important;
    }

    /* Badge: truncate extra-long company codes */
    .dsi-menu-badge {
        max-width: 190px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 9px !important;
    }

    /* Slightly taller touch targets for links */
    .dsi-menu-link {
        padding: 12px 16px !important;
        min-height: 44px;
    }

    /* User toggle button — touch-area bump */
    .dsi-user-toggle {
        padding: 5px;
        margin-top: 4px !important;
    }

    .dsi-user-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}


/* =============================================================================
   TABLET (768px – 991px)  — light touch-ups only
   ============================================================================= */

@media (min-width: 768px) and (max-width: 991px) {

    /* Slightly smaller primary nav text */
    #_desktop_top_menu .top-menu a[data-depth="0"] {
        font-size: 12px;
        padding: 10px 10px;
    }
}

/* =============================================================================
   MOBILE & TABLET FOOTER
   Consolidated responsive overrides for branding, grid, titles, and links.
   ============================================================================= */
@media (max-width: 991px) {

    .footer-container {
        padding-top: 40px !important;
    }

    .footer-container .row,
    .footer-container .container .row:first-child {
        display: block !important;
    }

    /* ── Grid & Containers ── */
    .footer-container [class*="col-"],
    .footer-container .links,
    .footer-container .block-contact,
    .footer-container .dsi-block,
    .footer-container .wrapper {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        float: none !important;
        margin-bottom: 0 !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        display: block !important;
        position: static !important;
        text-align: center !important;
    }

    /* ── Unified Titles ── */
    .footer-container .h3,
    .footer-container .h4,
    .footer-container .block-contact-title {
        text-align: center !important;
        margin-bottom: 25px !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        color: var(--color-gray-950) !important;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        position: relative;
        padding-bottom: 12px !important;
        display: inline-block !important;
        width: auto !important;
        border-bottom: none !important;
    }

    /* Centered Underline */
    .footer-container .h3::after,
    .footer-container .h4::after,
    .footer-container .block-contact-title::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 45px !important;
        height: 3px !important;
        background: var(--color-primary) !important;
    }

    /* ── Unified Links ── */
    .footer-container ul,
    .footer-container ul li {
        text-align: center !important;
        list-style: none !important;
        padding: 0 !important;
        margin: 0 auto !important;
    }

    .footer-container ul li {
        margin-bottom: 14px !important;
        background: transparent !important;
        border: none !important;
    }

    .footer-container ul li a {
        display: inline-block !important;
        font-size: 14px !important;
        color: var(--color-gray-800) !important;
        font-weight: 500 !important;
        text-decoration: none !important;
        transition: all 0.2s ease !important;
        padding: 5px 10px !important;
    }

    .footer-container ul li a:hover {
        color: var(--color-primary) !important;
        transform: translateY(-2px);
    }

    /* ── Brand & Socials Fine-tuning ── */
    .dsi-footer-logo {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        margin-bottom: 25px !important;
        text-align: center !important;
    }

    .dsi-footer-logo a {
        display: inline-block !important;
        width: 100% !important;
        text-align: center !important;
    }

    .dsi-footer-logo img {
        display: inline-block !important;
        margin: 0 auto !important;
        max-width: 220px !important;
    }

    .dsi-footer-blook-text-content {
        color: var(--color-gray-700) !important;
        line-height: 1.6;
        font-size: 13.5px !important;
        padding: 0 20px !important;
        text-align: center !important;
    }

    .dsi-footer-social-icons {
        display: flex !important;
        justify-content: center !important;
        margin-top: 25px !important;
        gap: 30px !important;
    }

    .dsi-footer-social-icons a {
        color: var(--color-primary) !important;
    }

    /* ── Copyright Correction (Mobile) ── */
    #footer .dsi-copyright-block {
        margin-top: 30px;
        padding: 30px 10px !important;
    }

    #footer .dsi-copyright-block p a {
        font-size: 20px !important;
    }
}