/**
 * Stylesheet: Mobile Bottom Navigation & Slide-up Drawers
 * Project: aiebike.vn (Flatsome Child Theme)
 * Brand Color: #ff8704 (Aiebike Orange)
 */

/* ==========================================================================
   1. GLOBAL & ANTI-OVERFLOW RULES
   ========================================================================== */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    body.aie-drawer-open {
        overflow: hidden !important;
        touch-action: none;
    }

    /* Đệm khoảng trống ở chân trang để không bị thanh Bottom Nav che mất nội dung */
    body {
        padding-bottom: calc(65px + env(safe-area-inset-bottom)) !important;
    }

    /* Tự động ẩn các nút liên hệ cũ bị trùng lặp / đè lên giao diện */
    #button-contact-vr,
    #gom-all-in-one,
    .phone-vr,
    .zalo-vr,
    .quick-contact-bar,
    .contact-vr,
    #popup-showroom-vr,
    #popup-form-contact-vr,
    .back-to-top.active {
        display: none !important;
    }
}

/* Ẩn hoàn toàn trên màn hình Desktop / Laptop (> 768px) */
@media (min-width: 769px) {
    #aie-mobile-bottom-nav-wrap {
        display: none !important;
    }
}

/* ==========================================================================
   2. BOTTOM NAVIGATION BAR
   ========================================================================== */
@media (max-width: 768px) {
    .aie-mobile-nav-wrapper {
        position: relative;
        z-index: 99990;
    }

    .aie-bottom-nav-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        min-height: 56px;
        padding-top: 6px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.96);
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 99992;
        box-sizing: border-box;
    }

    .aie-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        outline: none;
        padding: 4px 2px;
        margin: 0;
        color: #64748b;
        text-decoration: none;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        -webkit-tap-highlight-color: transparent;
        position: relative;
        user-select: none;
    }

    .aie-nav-btn:hover,
    .aie-nav-btn:active,
    .aie-nav-btn.is-active,
    .aie-nav-btn.is-current {
        color: #ff8704;
        text-decoration: none;
    }

    .aie-nav-btn__icon-wrap {
        position: relative;
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 3px;
        transition: transform 0.2s ease;
    }

    .aie-nav-btn:active .aie-nav-btn__icon-wrap,
    .aie-nav-btn.is-active .aie-nav-btn__icon-wrap {
        transform: scale(1.12);
    }

    /* Khóa kích thước SVG Icon chống phình to */
    .aie-nav-btn__svg {
        width: 20px !important;
        height: 20px !important;
        max-width: 20px !important;
        max-height: 20px !important;
        stroke-width: 2;
        stroke: currentColor;
        fill: none;
        transition: stroke 0.2s ease;
    }

    .aie-nav-btn.is-active .aie-nav-btn__svg,
    .aie-nav-btn.is-current .aie-nav-btn__svg {
        stroke: #ff8704;
    }

    .aie-nav-btn__text {
        font-size: 11px;
        font-weight: 600;
        line-height: 1.2;
        text-align: center;
        white-space: nowrap;
        letter-spacing: -0.2px;
    }

    .aie-nav-btn.is-active .aie-nav-btn__text,
    .aie-nav-btn.is-current .aie-nav-btn__text {
        color: #ff8704;
        font-weight: 700;
    }

    /* ==========================================================================
       3. BACKDROP OVERLAY
       ========================================================================== */
    .aie-nav-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.55);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
        z-index: 99995;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .aie-nav-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* ==========================================================================
       4. SLIDE-UP DRAWERS (POPUPS)
       ========================================================================== */
    .aie-drawer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 78vh;
        max-height: 85vh;
        background: #ffffff;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.2);
        z-index: 99998;
        transform: translate3d(0, 105%, 0);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-sizing: border-box;
    }

    .aie-drawer:not(.is-open) {
        display: none !important;
    }

    .aie-drawer.is-open {
        display: flex !important;
        transform: translate3d(0, 0, 0);
        animation: aieDrawerSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    @keyframes aieDrawerSlideUp {
        from {
            transform: translate3d(0, 100%, 0);
        }
        to {
            transform: translate3d(0, 0, 0);
        }
    }

    .aie-drawer--contact {
        height: auto;
        max-height: 75vh;
    }

    /* Drawer Header */
    .aie-drawer__header {
        position: relative;
        padding: 12px 16px 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #ffffff;
        border-bottom: 1px solid #f1f5f9;
        flex-shrink: 0;
    }

    .aie-drawer__drag-indicator {
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: #cbd5e1;
    }

    .aie-drawer__title-wrap {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-top: 4px;
    }

    .aie-drawer__title-icon {
        width: 20px !important;
        height: 20px !important;
        stroke: #ff8704;
        flex-shrink: 0;
    }

    .aie-drawer__title {
        font-size: 16px !important;
        font-weight: 700 !important;
        color: #0f172a;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.3;
    }

    .aie-drawer__close {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f1f5f9;
        border: none;
        border-radius: 50%;
        color: #475569;
        cursor: pointer;
        padding: 0;
        margin: 0;
        transition: background 0.2s ease, transform 0.2s ease;
    }

    .aie-drawer__close:active {
        background: #e2e8f0;
        transform: scale(0.92);
    }

    .aie-drawer__close svg {
        width: 16px !important;
        height: 16px !important;
    }

    /* Drawer Search Box (đối với Đại lý) */
    .aie-drawer__search-box {
        position: relative;
        padding: 8px 16px;
        background: #f8fafc;
        border-bottom: 1px solid #e2e8f0;
        flex-shrink: 0;
    }

    .aie-drawer__search-icon {
        position: absolute;
        left: 28px;
        top: 50%;
        transform: translateY(-50%);
        width: 16px !important;
        height: 16px !important;
        stroke: #94a3b8;
        pointer-events: none;
    }

    .aie-drawer__search-input {
        width: 100% !important;
        height: 38px !important;
        padding: 0 12px 0 34px !important;
        background: #ffffff !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 20px !important;
        font-size: 13px !important;
        color: #1e293b !important;
        outline: none !important;
        box-sizing: border-box;
        margin: 0 !important;
        box-shadow: none !important;
    }

    .aie-drawer__search-input:focus {
        border-color: #ff8704 !important;
    }

    /* Drawer Body: 2-Column Layout */
    .aie-drawer__body {
        flex: 1;
        overflow: hidden;
        position: relative;
    }

    .aie-drawer__split-layout {
        display: flex;
        height: 100%;
    }

    /* Cột trái (Sidebar Tabs) */
    .aie-drawer__sidebar {
        width: 32%;
        min-width: 105px;
        max-width: 135px;
        background: #f8fafc;
        border-right: 1px solid #e2e8f0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex-shrink: 0;
    }

    .aie-drawer__tabs-list {
        list-style: none !important;
        margin: 0 !important;
        padding: 6px 0 !important;
    }

    .aie-drawer__tab-item {
        margin: 0 !important;
        padding: 0 !important;
    }

    .aie-drawer__tab-btn {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 10px 6px;
        background: transparent;
        border: none;
        border-left: 3px solid transparent;
        color: #475569;
        cursor: pointer;
        transition: all 0.2s ease;
        outline: none;
        box-sizing: border-box;
    }

    .aie-drawer__tab-btn.is-active {
        background: #ffffff;
        color: #ff8704;
        border-left-color: #ff8704;
        font-weight: 700;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.04);
    }

    .aie-drawer__tab-img {
        width: 34px;
        height: 34px;
        object-fit: contain;
        border-radius: 6px;
        margin-bottom: 4px;
    }

    .aie-drawer__tab-icon-fallback {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .aie-drawer__tab-name {
        font-size: 11.5px;
        line-height: 1.25;
        word-break: break-word;
    }

    .aie-drawer__empty-text {
        display: block;
        padding: 12px;
        font-size: 12px;
        color: #94a3b8;
        text-align: center;
    }

    /* Tối ưu danh sách Danh mục, Tỉnh/Thành & Tin tức gọn gàng */
    #aie-drawer-category .aie-drawer__sidebar,
    #aie-drawer-store .aie-drawer__sidebar,
    #aie-drawer-news .aie-drawer__sidebar {
        width: 30%;
        min-width: 95px;
        max-width: 120px;
    }

    #aie-drawer-category .aie-drawer__tabs-list,
    #aie-drawer-store .aie-drawer__tabs-list,
    #aie-drawer-news .aie-drawer__tabs-list {
        padding: 0 !important;
    }

    .aie-drawer__tab-btn--cat,
    .aie-drawer__tab-btn--store,
    .aie-drawer__tab-btn--news {
        flex-direction: column !important;
        padding: 12px 8px !important;
        min-height: 44px;
        border-bottom: 1px solid #f1f5f9;
        justify-content: center;
    }

    .aie-drawer__tab-btn--store,
    .aie-drawer__tab-btn--news {
        flex-direction: row !important;
    }

    .aie-drawer__tab-btn--cat .aie-drawer__tab-name,
    .aie-drawer__tab-btn--store .aie-drawer__tab-name,
    .aie-drawer__tab-btn--news .aie-drawer__tab-name {
        font-size: 12px !important;
        font-weight: 600;
        line-height: 1.35;
        text-align: center;
        width: 100%;
    }

    .aie-drawer__tab-btn--cat.is-active .aie-drawer__tab-name,
    .aie-drawer__tab-btn--store.is-active .aie-drawer__tab-name,
    .aie-drawer__tab-btn--news.is-active .aie-drawer__tab-name {
        font-weight: 700;
        color: #ff8704;
    }

    /* Cột phải (Content Area) */
    .aie-drawer__content-area {
        flex: 1;
        background: #ffffff;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 14px;
        box-sizing: border-box;
    }

    .aie-drawer__pane {
        display: none;
    }

    .aie-drawer__pane.is-active {
        display: block;
        animation: aieFadeIn 0.25s ease;
    }

    @keyframes aieFadeIn {
        from { opacity: 0; transform: translateY(4px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .aie-drawer__pane-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px dashed #e2e8f0;
    }

    .aie-drawer__pane-title {
        font-size: 14px !important;
        font-weight: 700 !important;
        color: #0f172a;
        margin: 0 !important;
        padding: 0 !important;
    }

    .aie-drawer__view-all-link {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        font-size: 12px;
        font-weight: 600;
        color: #ff8704;
        text-decoration: none;
    }

    .aie-drawer__view-all-link svg {
        width: 12px !important;
        height: 12px !important;
    }

    /* Chips danh mục con */
    .aie-drawer__subcat-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 14px;
    }

    .aie-drawer__subcat-chip {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 5px 9px;
        background: #f1f5f9;
        border-radius: 14px;
        font-size: 11.5px;
        font-weight: 500;
        color: #334155;
        text-decoration: none;
        transition: background 0.2s ease, color 0.2s ease;
    }

    .aie-drawer__subcat-chip:active {
        background: #fff5eb;
        color: #ff8704;
    }

    .aie-drawer__subcat-count {
        color: #94a3b8;
        font-size: 10px;
    }

    /* Grid sản phẩm */
    .aie-drawer__products-title {
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        color: #64748b;
        margin-bottom: 8px;
        letter-spacing: 0.3px;
    }

    .aie-drawer__products-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .aie-drawer__product-card {
        display: flex;
        flex-direction: column;
        background: #ffffff;
        border: 1px solid #f1f5f9;
        border-radius: 8px;
        overflow: hidden;
        text-decoration: none;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .aie-drawer__product-card:active {
        transform: scale(0.98);
        border-color: #ffedd5;
    }

    .aie-drawer__product-thumb {
        position: relative;
        width: 100%;
        padding-top: 100%;
        background: #f8fafc;
        overflow: hidden;
    }

    .aie-drawer__product-thumb img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .aie-drawer__badge-sale {
        position: absolute;
        top: 4px;
        left: 4px;
        background: #ff8704;
        color: #ffffff;
        font-size: 9px;
        font-weight: 700;
        text-transform: uppercase;
        padding: 2px 5px;
        border-radius: 4px;
    }

    .aie-drawer__product-info {
        padding: 6px 8px 8px;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    .aie-drawer__product-name {
        font-size: 11.5px !important;
        font-weight: 600 !important;
        color: #1e293b;
        margin: 0 !important;
        line-height: 1.3 !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .aie-drawer__product-price {
        font-size: 11.5px;
        font-weight: 700;
        color: #ff8704;
        line-height: 1.2;
    }

    .aie-drawer__product-price del {
        color: #94a3b8;
        font-size: 10px;
        font-weight: 400;
        margin-right: 3px;
    }

    .aie-drawer__product-price ins {
        text-decoration: none;
    }

    /* List Tin tức */
    .aie-drawer__news-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .aie-drawer__news-card {
        display: flex;
        gap: 10px;
        padding: 8px;
        background: #ffffff;
        border: 1px solid #f1f5f9;
        border-radius: 8px;
        text-decoration: none;
        transition: background 0.2s ease;
    }

    .aie-drawer__news-card:active {
        background: #f8fafc;
    }

    .aie-drawer__news-thumb {
        width: 70px;
        height: 60px;
        border-radius: 6px;
        overflow: hidden;
        background: #f1f5f9;
        flex-shrink: 0;
    }

    .aie-drawer__news-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .aie-drawer__news-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .aie-drawer__news-title {
        font-size: 12px !important;
        font-weight: 600 !important;
        color: #0f172a;
        margin: 0 !important;
        line-height: 1.35 !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .aie-drawer__news-meta {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 10.5px;
        color: #94a3b8;
    }

    .aie-drawer__news-date {
        display: inline-flex;
        align-items: center;
        gap: 3px;
    }

    .aie-drawer__news-date svg {
        width: 11px !important;
        height: 11px !important;
    }

    /* List Đại lý */
    .aie-drawer__stores-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .aie-drawer__store-card {
        padding: 10px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    }

    .aie-drawer__store-card.is-hidden {
        display: none !important;
    }

    .aie-drawer__store-thumb {
        width: 100%;
        height: 110px;
        border-radius: 6px;
        overflow: hidden;
        margin-bottom: 8px;
    }

    .aie-drawer__store-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .aie-drawer__store-name {
        font-size: 13px !important;
        font-weight: 700 !important;
        color: #0f172a;
        margin: 0 0 5px 0 !important;
        line-height: 1.3 !important;
    }

    .aie-drawer__store-addr,
    .aie-drawer__store-phone {
        display: flex;
        align-items: flex-start;
        gap: 6px;
        font-size: 11.5px;
        color: #475569;
        margin: 0 0 4px 0 !important;
        line-height: 1.35;
    }

    .aie-drawer__store-addr svg,
    .aie-drawer__store-phone svg {
        width: 13px !important;
        height: 13px !important;
        stroke: #ff8704;
        flex-shrink: 0;
        margin-top: 2px;
    }

    .aie-drawer__store-phone a {
        color: #ff8704;
        font-weight: 600;
        text-decoration: none;
    }

    .aie-drawer__store-actions {
        display: flex;
        gap: 8px;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px dashed #e2e8f0;
    }

    .aie-drawer__store-btn {
        flex: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 6px 10px;
        border-radius: 6px;
        font-size: 11.5px;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.2s ease;
    }

    .aie-drawer__store-btn svg {
        width: 13px !important;
        height: 13px !important;
    }

    .aie-drawer__store-btn--call {
        background: #fff5eb;
        color: #ea580c;
    }

    .aie-drawer__store-btn--call:active {
        background: #fed7aa;
    }

    .aie-drawer__store-btn--map {
        background: #f1f5f9;
        color: #334155;
    }

    .aie-drawer__store-btn--map:active {
        background: #e2e8f0;
    }

    /* ==========================================================================
       5. CONTACT SHEET (DRAWER LIÊN HỆ)
       ========================================================================== */
    .aie-drawer__contact-body {
        padding: 14px 16px 24px;
        overflow-y: auto;
    }

    .aie-drawer__contact-desc {
        font-size: 13px;
        color: #64748b;
        margin: 0 0 14px 0 !important;
        text-align: center;
    }

    .aie-drawer__contact-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .aie-contact-card {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        text-decoration: none;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
        transition: transform 0.2s ease, border-color 0.2s ease;
    }

    .aie-contact-card:active {
        transform: scale(0.98);
        border-color: #fed7aa;
    }

    .aie-contact-card__icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff5eb;
        color: #ff8704;
        flex-shrink: 0;
    }

    .aie-contact-card__icon svg {
        width: 20px !important;
        height: 20px !important;
        stroke: currentColor;
    }

    .aie-contact-card__icon--zalo,
    .aie-contact-card__icon--messenger {
        background: transparent;
        padding: 0;
    }

    .aie-contact-card__icon--zalo svg,
    .aie-contact-card__icon--messenger svg {
        width: 40px !important;
        height: 40px !important;
        stroke: none;
    }

    .aie-contact-card--email .aie-contact-card__icon {
        background: #e0f2fe;
        color: #0284c7;
    }

    .aie-contact-card__info {
        flex: 1;
    }

    .aie-contact-card__label {
        font-size: 11px;
        color: #64748b;
        font-weight: 500;
        margin-bottom: 2px;
    }

    .aie-contact-card__value {
        font-size: 13.5px;
        font-weight: 700;
        color: #0f172a;
    }

    .aie-contact-card__action {
        font-size: 11.5px;
        font-weight: 700;
        color: #ea580c;
        padding: 6px 12px;
        background: #fff5eb;
        border-radius: 20px;
        white-space: nowrap;
    }

    .aie-contact-card--zalo .aie-contact-card__action {
        color: #0068ff;
        background: #eff6ff;
    }

    .aie-contact-card--messenger .aie-contact-card__action {
        color: #0084ff;
        background: #eff6ff;
    }

    .aie-contact-card--email .aie-contact-card__action {
        color: #0284c7;
        background: #f0f9ff;
    }

    .aie-drawer__contact-footer {
        margin-top: 16px;
        padding-top: 12px;
        border-top: 1px dashed #e2e8f0;
    }

    .aie-drawer__work-time {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-size: 11.5px;
        color: #64748b;
        text-align: center;
    }

    .aie-drawer__work-time svg {
        width: 14px !important;
        height: 14px !important;
        stroke: #94a3b8;
    }

    .aie-drawer__no-data {
        padding: 24px 12px;
        font-size: 12.5px;
        color: #94a3b8;
        text-align: center;
    }

    .aie-drawer__no-img {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        font-size: 11px;
        color: #94a3b8;
        background: #f1f5f9;
    }
}
