/* ==========================================================================
   KHÓA CỐ ĐỊNH LAYOUT TOÀN CỤC TRÊN MOBILE (GLOBAL MOBILE LOCK)
   - Chống co giãn ngang, lắc ngang qua lại khi vuốt chạm
   - Chống tự động phóng to thu nhỏ trên điện thoại iOS / Android
   - Ngăn thanh cuộn ngang 100vw, cố định bảng dữ liệu và form nhập liệu
   ========================================================================== */

html, body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    overscroll-behavior-x: none !important;
    touch-action: pan-y pinch-zoom !important;
    -webkit-text-size-adjust: 100% !important;
}

/* Các khối layout chính không được tràn ra ngoài viewport */
.main_header,
main,
footer,
section {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* KHUNG NỘI DUNG CHÍNH (CONTENT-BODY) CHỐNG TRÀN TOÀN DIỆN */
.content-body {
    flex: 1 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Đảm bảo Header & Nav-Header trên Desktop luôn hiển thị chuẩn 100%, không bị che khuất */
@media (min-width: 992px) {
    .nav-header {
        width: 260px !important;
        max-width: 260px !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 70px !important;
        z-index: 1005 !important;
        box-sizing: border-box !important;
    }
    body.sidebar-collapsed .nav-header {
        width: 80px !important;
        max-width: 80px !important;
    }
    .header {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        left: 260px !important;
        width: calc(100% - 260px) !important;
        max-width: calc(100% - 260px) !important;
        height: 70px !important;
        background: #ffffff !important;
        border-bottom: 1px solid #edf2f7 !important;
        z-index: 1000 !important;
        box-sizing: border-box !important;
    }
    body.sidebar-collapsed .header {
        left: 80px !important;
        width: calc(100% - 80px) !important;
        max-width: calc(100% - 80px) !important;
    }
    .content-body {
        margin-left: 260px !important;
        width: calc(100% - 260px) !important;
        max-width: calc(100% - 260px) !important;
    }
    body.sidebar-collapsed .content-body {
        margin-left: 80px !important;
        width: calc(100% - 80px) !important;
        max-width: calc(100% - 80px) !important;
    }
}

@media (max-width: 991px) {
    .nav-header {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        z-index: 1050 !important;
    }
    .content-body {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Khóa độ rộng chuẩn Bootstrap cho Container trên Desktop: Không bao giờ bị dãn bè ra 2 mép màn hình */
.container {
    width: 100% !important;
    max-width: 1320px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    box-sizing: border-box !important;
}

@media (max-width: 1400px) {
    .container { max-width: 1140px !important; }
}
@media (max-width: 1200px) {
    .container { max-width: 960px !important; }
}
@media (max-width: 992px) {
    .container { max-width: 720px !important; }
}
@media (max-width: 768px) {
    .container,
    .container-fluid {
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        box-sizing: border-box !important;
    }
}

/* Các bảng dữ liệu (Table) bắt buộc bọc trong khung cuộn ngang riêng biệt */
.table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain !important;
}

.table-responsive table {
    margin-bottom: 0 !important;
}

/* Đảm bảo khung logo và hiệu ứng SVG không gây tràn chiều ngang */
.logo-led-wrapper,
.logo-led-svg,
.brand-logo,
.nav-logo {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Thiết lập font-size >= 16px trên mobile & tablet (<= 991.98px) để iOS Safari / Android Chrome không auto-zoom khi focus */
@media (max-width: 991.98px) {
    input,
    select,
    textarea,
    .form-control,
    .form-control-sm,
    .form-select,
    .sidebar-search-input,
    #sidebar-quick-filter,
    #input-filter-quick-search,
    .swal2-input,
    .swal2-select,
    .swal2-textarea {
        font-size: 16px !important;
    }
}
