/* === Universal Box Sizing === */
.my-mbm-container,
.my-mbm-container * {
    box-sizing: border-box;
}

/* === CSS Variables & Cấu hình Vùng An Toàn (Safe Area) === */
:root {
    --my-mbm-height: 60px;
    --my-mbm-safe-area-bottom: 0px;
}

/* Hỗ trợ Vùng An Toàn */
@supports (padding-bottom: constant(safe-area-inset-bottom)) {
    :root { --my-mbm-safe-area-bottom: constant(safe-area-inset-bottom); }
}
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    :root { --my-mbm-safe-area-bottom: env(safe-area-inset-bottom); }
}


/* ================================================================== */
/* === TỐI ƯU HÓA LAYOUT (Đã sửa lỗi cuộn & Pop-up) === */
/* ================================================================== */

@media (max-width: 767px) {
    
    /* 1. NGĂN TRÀN NGANG MÀN HÌNH (Không khóa chiều cao dọc để giữ nguyên khả năng cuộn) */
    html.my-mbm-html-active,
    html.my-mbm-html-active body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }

    /* 2. Điều chỉnh Body Padding để nhường chỗ cho Menu không che nội dung website */
    body.my-mbm-active {
        padding-bottom: calc(var(--my-mbm-height) + var(--my-mbm-safe-area-bottom));
        transition: padding-bottom 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    }
    
    /* ================================================================== */
    /* 3. GIẢI PHÁP NHƯỜNG CHỖ (Manual Suppression) */
    /* ================================================================== */
    
    /* 3a. Ẩn menu khi có lệnh (Ví dụ: khi Pop-up mở) */
    body.my-mbm-suppressed .my-mbm-container {
        transform: translate3d(0, 100%, 0) !important;
        -webkit-transform: translate3d(0, 100%, 0) !important;
        visibility: hidden;
    }
    
    /* 3b. Loại bỏ padding của body khi menu đã ẩn */
    body.my-mbm-active.my-mbm-suppressed {
        padding-bottom: 0 !important;
    }
    
    /* 3c. VÔ HIỆU HÓA PHONG TỎA KHI MENU BỊ ẨN (Trả lại quyền kiểm soát layout cho Pop-up) */
    html.my-mbm-html-active.my-mbm-suppressed,
    body.my-mbm-active.my-mbm-suppressed {
        overflow-x: initial !important;
    }
}


/* === Main Container: Cố định vị trí tuyệt đối === */
.my-mbm-container {
    /* CƯỠNG CHẾ VỊ TRÍ VÀ KÍCH THƯỚC */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    
    width: 100% !important; 
    max-width: 100vw !important;
    margin: 0 !important;

    /* Giữ Z-index cao nhất để đảm bảo ổn định, vì chúng ta đã có cơ chế ẩn đi khi cần. */
    z-index: 2147483647; 

    /* Kích thước rõ ràng */
    height: calc(var(--my-mbm-height) + var(--my-mbm-safe-area-bottom));
    
    /* Đảm bảo padding chỉ áp dụng cho đáy (Vùng an toàn) */
    padding: 0 0 var(--my-mbm-safe-area-bottom) 0 !important; 

    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
    overflow: hidden;

    /* === KỸ THUẬT ỔN ĐỊNH HÓA NÂNG CAO === */
    /* A. Tăng tốc phần cứng và thiết lập vị trí mặc định */
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    
    /* B. Ngăn các thao tác chạm không mong muốn trên container */
    touch-action: none; 

    /* C. Hiệu ứng chuyển tiếp (Cho việc ẩn/hiện mượt mà) */
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), visibility 0.3s;
}

/* === List Items === */
.my-mbm-list {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
    height: var(--my-mbm-height);
}

.my-mbm-item {
    flex-grow: 1;
}

.my-mbm-item a {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 4px 0;
    text-decoration: none;
    color: #4A4A4A;
    font-size: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s ease;
}

.my-mbm-item a:hover {
    color: #0073aa;
}

.my-mbm-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    object-fit: contain;
}

.my-mbm-text {
    line-height: 1.2;
}

/* === Ẩn menu trên thiết bị không phải di động === */
@media (min-width: 768px) {
    .my-mbm-container {
        display: none !important;
    }
}