/* =========================================================
   MOBILE NAV ENHANCED v1 — Loja da Barba
   Aplica navegação mobile/tablet unificada (≤991px).
   Para reverter: remova ou comente a linha deste arquivo no header.twig
   e o include de mobile_nav.twig no footer.twig.
   ========================================================= */

/* Oculta no desktop */
.mobile-bottom-bar,
#custom-mobile-overlay,
#custom-mobile-drawer {
    display: none !important;
}

/* Screen-reader only label */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 991px) {

    /* Unifica tablet + mobile: esconde hamburger legado */
    header#site-header .mobmenu {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Desativa slide-out Bootstrap antigo */
    #menu .navbar-collapse > ul {
        display: none !important;
    }

    /* ── Bottom bar ── */
    .mobile-bottom-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: #FFFFFF;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
        z-index: 99990;
        justify-content: space-between;
        align-items: center;
        padding: 0 12px calc(6px + env(safe-area-inset-bottom, 0px));
        height: calc(65px + env(safe-area-inset-bottom, 0px));
        min-height: 65px;
        border-top: 1px solid #F4F6F5;
    }

    .m-nav-item,
    .m-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #666666;
        font-size: 10px;
        font-weight: 500;
        flex: 1;
        background: none;
        border: none;
        padding: 4px 0;
        cursor: pointer;
        font-family: "Lexend", sans-serif;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.2s ease;
    }

    .m-nav-item i,
    .m-nav-btn i {
        font-size: 20px;
        margin-bottom: 4px;
        color: #666666;
        transition: color 0.2s ease;
    }

    .m-nav-icon-wrap {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 24px;
        margin-bottom: 4px;
    }

    .m-nav-icon-wrap i {
        margin-bottom: 0;
    }

    .m-nav-item:focus-visible,
    .m-nav-btn:focus-visible {
        outline: 2px solid var(--ldb-gold);
        outline-offset: 2px;
        border-radius: 6px;
    }

    #mobileBottomBar .m-nav-item.active,
    #mobileBottomBar .m-nav-item.active i,
    #mobileBottomBar .m-nav-btn.active,
    #mobileBottomBar .m-nav-btn.active i {
        color: var(--ldb-ink) !important;
        font-weight: 700 !important;
    }

    #mobileBottomBar .m-nav-item.active i,
    #mobileBottomBar .m-nav-btn.active i {
        color: var(--ldb-gold) !important;
    }

    /* Carrinho elevado */
    .m-nav-cart {
        position: relative;
        top: -14px;
        width: 54px;
        height: 54px;
        flex: none;
        background-color: var(--ldb-ink);
        border-radius: 14px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-shadow: 0 6px 15px rgba(30, 57, 42, 0.35);
        border: 3px solid #FFFFFF;
    }

    .m-nav-cart i {
        color: #ffffff !important;
        font-size: 20px;
        margin: 0;
    }

    .m-nav-cart span:not(.m-cart-badge) {
        display: none;
    }

    .m-cart-badge {
        position: absolute;
        top: -5px;
        right: -5px;
        background-color: var(--ldb-gold);
        color: #111111;
        font-size: 11px;
        font-weight: 800;
        min-width: 19px;
        height: 19px;
        border-radius: 50%;
        display: none;
        align-items: center;
        justify-content: center;
        border: 2px solid #FFFFFF;
        padding: 0 4px;
        line-height: 1;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
    }

    .m-nav-wishlist {
        position: relative;
    }

    .m-wishlist-badge {
        position: absolute;
        top: -4px;
        right: -8px;
        background-color: var(--ldb-gold);
        color: #111111;
        font-size: 11px;
        font-weight: 800;
        min-width: 19px;
        height: 19px;
        border-radius: 50%;
        display: none;
        align-items: center;
        justify-content: center;
        border: 2px solid #FFFFFF;
        padding: 0;
        line-height: 1;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
        z-index: 1;
    }

    body.has-mobile-nav {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* ── Overlay (acima do header sticky z-index 999999) ── */
    #custom-mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.55);
        z-index: 1000000;
        display: none !important;
        opacity: 0;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }

    #custom-mobile-overlay.active {
        display: block !important;
        opacity: 1;
    }

    /* ── Drawer (z-index acima do header sticky) ── */
    #custom-mobile-drawer {
        position: fixed;
        top: 0;
        left: -100%;
        width: 88%;
        max-width: 360px;
        height: 100%;
        height: 100dvh;
        background-color: #ffffff;
        z-index: 1000001;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.22);
        transition: left 0.32s cubic-bezier(0.25, 1, 0.5, 1);
        display: flex !important;
        flex-direction: column;
    }

    #custom-mobile-drawer.active {
        left: 0 !important;
    }

    .drawer-header {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 56px;
        min-height: 56px;
        max-height: 56px;
        padding: 0 12px 0 14px;
        background: linear-gradient(135deg, var(--ldb-ink) 0%, #2a5240 100%);
        color: #ffffff;
        flex-shrink: 0;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
        box-sizing: border-box;
    }

    .drawer-header-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        flex: 1;
        min-width: 0;
        text-decoration: none;
        color: inherit;
        overflow: hidden;
    }

    .drawer-logo {
        width: 44px;
        height: 44px;
        max-width: 44px;
        max-height: 44px;
        object-fit: contain;
        flex-shrink: 0;
        filter: brightness(0) invert(1);
    }

    .drawer-title {
        flex: 1;
        min-width: 0;
        font-size: 14.5px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        color: #fff;
        margin: 0;
        font-family: "Lexend", sans-serif;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }

    .drawer-close {
        background-color: var(--ldb-gold);
        color: #111111;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        cursor: pointer;
        border: none;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        flex-shrink: 0;
        margin-left: 2px;
    }

    .drawer-close:focus-visible {
        outline: 2px solid #ffffff;
        outline-offset: 2px;
    }

    .drawer-body {
        overflow-y: auto;
        overflow-x: hidden;
        flex: 1 1 auto;
        min-height: 0;
        display: block;
        background-color: #F7F9F8;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .drawer-categories {
        padding: 6px 10px 2px;
    }

    .acc-icon-wrap {
        width: 38px;
        height: 38px;
        border-radius: 11px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        font-size: 16px;
    }

    .acc-icon-wrap .ldb-mi {
        width: 18px;
        height: 18px;
    }

    .acc-icon-wrap--1 { background: linear-gradient(135deg, var(--ldb-ink) 0%, #2d5a42 100%); color: var(--ldb-gold); }
    .acc-icon-wrap--2 { background: linear-gradient(135deg, #2a4a38 0%, #3d6b52 100%); color: #f0dfa8; }
    .acc-icon-wrap--3 { background: linear-gradient(135deg, #1a3328 0%, #254535 100%); color: #e8c97a; }
    .acc-icon-wrap--4 { background: linear-gradient(135deg, #243d30 0%, var(--ldb-ink) 100%); color: var(--ldb-gold); }

    .acc-item {
        background: #ffffff;
        border-radius: 12px;
        margin-bottom: 6px;
        box-shadow: 0 2px 8px rgba(30, 57, 42, 0.06);
        border: 1px solid #EEF2F0;
        overflow: hidden;
        transition: box-shadow 0.25s ease;
    }

    .acc-item.active {
        box-shadow: 0 4px 16px rgba(30, 57, 42, 0.1);
        border-color: rgba(212, 175, 104, 0.35);
    }

    .acc-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 10px 12px;
        color: #1a1a1a;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.2s;
        background: none;
        border: none;
        text-align: left;
        font-family: "Lexend", sans-serif;
        gap: 8px;
    }

    .acc-header-label {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        flex: 1;
    }

    .acc-name {
        font-size: 13.5px;
        font-weight: 600;
        color: var(--ldb-ink);
        line-height: 1.3;
    }

    .acc-arrow-wrap {
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: #F4F7F5;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .acc-item.active .acc-arrow-wrap {
        background: rgba(212, 175, 104, 0.2);
    }

    .acc-header .acc-arrow {
        color: #aaa;
        font-size: 10px;
        transition: transform 0.3s ease, color 0.3s ease;
    }

    .acc-item.active .acc-arrow {
        transform: rotate(180deg);
        color: var(--ldb-gold);
    }

    .acc-header:focus-visible {
        outline: 2px solid var(--ldb-gold);
        outline-offset: -2px;
    }

    .acc-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.38s cubic-bezier(0.25, 1, 0.5, 1);
    }

    .acc-item.active .acc-content {
        max-height: 900px;
    }

    .acc-content-inner {
        padding: 2px 8px 8px;
        background: linear-gradient(180deg, #FAFBFA 0%, #ffffff 100%);
        border-top: 1px solid #F0F3F1;
    }

    .acc-child-link--text {
        padding-left: 12px;
    }

    .acc-child-link--text .acc-child-name {
        font-weight: 500;
    }

    .acc-name {
        text-transform: none;
        letter-spacing: 0.01em;
    }

    .acc-child-link {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 8px;
        margin-bottom: 2px;
        color: #333;
        text-decoration: none;
        font-size: 13px;
        font-weight: 500;
        border-radius: 10px;
        font-family: "Lexend", sans-serif;
        transition: background 0.2s ease;
    }

    .acc-child-link:active {
        background: #F0F5F2;
        color: var(--ldb-ink);
    }

    .acc-child-icon-wrap {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        background: #EEF4F0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .acc-child-icon-wrap i {
        font-size: 12px;
        color: var(--ldb-ink);
    }

    .acc-child-name {
        flex: 1;
        line-height: 1.35;
    }

    .acc-child-arrow {
        font-size: 10px;
        color: #ccc;
        flex-shrink: 0;
    }

    .acc-see-all {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        margin-top: 4px;
        padding: 9px 12px !important;
        border-radius: 10px !important;
        background: var(--ldb-ink) !important;
        color: #ffffff !important;
        font-size: 12.5px !important;
        font-weight: 600 !important;
        text-decoration: none !important;
        font-family: "Lexend", sans-serif;
    }

    .drawer-link-flat {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        margin-bottom: 6px;
        color: var(--ldb-ink);
        text-decoration: none;
        font-size: 14px;
        font-weight: 600;
        background: #ffffff;
        border-radius: 14px;
        border: 1px solid #EEF2F0;
        box-shadow: 0 2px 8px rgba(30, 57, 42, 0.06);
        font-family: "Lexend", sans-serif;
    }

    .drawer-flat-arrow {
        margin-left: auto;
        font-size: 11px;
        color: #ccc;
    }

    .drawer-link-highlight {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 6px 10px 0;
        padding: 11px 14px;
        color: var(--ldb-ink);
        text-decoration: none;
        font-size: 14px;
        font-weight: 700;
        background: linear-gradient(135deg, rgba(212, 175, 104, 0.18) 0%, rgba(212, 175, 104, 0.08) 100%);
        border: 1px solid rgba(212, 175, 104, 0.35);
        border-radius: 14px;
        font-family: "Lexend", sans-serif;
    }

    .drawer-highlight-icon {
        width: 32px;
        height: 32px;
        border-radius: 10px;
        background: var(--ldb-gold);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .drawer-highlight-icon i {
        color: var(--ldb-ink);
        font-size: 16px;
    }

    .drawer-link-highlight > .fa-chevron-right {
        margin-left: auto;
        font-size: 11px;
        color: var(--ldb-gold);
    }

    .drawer-footer-actions {
        background-color: #F4F7F5;
        padding: 8px 0 10px;
        margin-top: 8px;
        border-top: 1px solid #E5ECE7;
    }

    .action-link {
        display: flex;
        align-items: center;
        padding: 10px 16px;
        color: var(--ldb-ink);
        text-decoration: none;
        font-size: 14px;
        font-weight: 600;
        font-family: "Lexend", sans-serif;
    }

    .action-link i {
        background-color: #ffffff;
        color: var(--ldb-ink);
        width: 30px;
        height: 30px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 12px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
        font-size: 13px;
        flex-shrink: 0;
    }

    /* Telas baixas: compactação extra */
    @media (max-height: 700px) {
        .drawer-header { height: 52px; min-height: 52px; max-height: 52px; padding: 0 10px 0 12px; }
        .drawer-logo { width: 40px; height: 40px; max-width: 40px; max-height: 40px; }
        .drawer-title { font-size: 13.5px; }
        .acc-header { padding: 8px 10px; }
        .acc-icon-wrap { width: 34px; height: 34px; font-size: 14px; }
        .acc-child-link { padding: 8px 6px; }
        .action-link { padding: 8px 14px; font-size: 13px; }
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 991px) {
    body.has-mobile-nav {
        padding-bottom: 75px !important;
    }
}
