/* === STYLE CŨ CỦA BẠN === */
body {
    font-family: 'Barlow', Arial, sans-serif;
    background-color: #fff9f9;
}

h2 {
    color: #666666;
    font-family: 'Barlow', Arial, sans-serif;
    text-align: center;
    margin-top: 20px;
    font-size: 40px;
    font-weight: bold;
    margin-bottom: 10px;
}

h4 {
    color: #ff9e9f;
    font-family: 'Barlow', Arial, sans-serif;
    text-align: center;
    font-size: 30px;
    font-weight: bold;
    margin-bottom: 15px;
}

/* Sửa lại TD để căn giữa */
th, td {
    height: 1em;
    font-size: 1em;
    text-align: center;
    vertical-align: middle;

    /* SỬA LỖI 3: Giảm chiều cao (padding) của dòng */
    padding-top: 0.4rem !important;
    padding-bottom: 0.4rem !important;
}

th {
    background-color: #ff9e9f;
    color: #fff;
}

td {
    /* SỬA LỖI 3: Bỏ height cố định để padding quyết định */
    /* height: 30px; */
    color: #666666;
}

tr {
    font-family: 'Barlow', Arial, sans-serif;
    background-color: #fff9f9;
    color: #666666;
}

input {
    /* Bỏ margin 5px chung */
}

input::placeholder {
    font-family: 'Barlow', Arial, sans-serif;
    font-weight: light;
    font-size: 0.9em;
    color: #b2b2b2;
    padding-bottom: 0px;
    vertical-align: center;
}

.btn-primary {
    color: #fff;
    background-color: #fba8bc;
    font-family: 'Barlow', Arial, sans-serif;
    border-color: #fba8bc;
    text-align: center;
    margin-bottom: 0px;
    height: 30px;
    width: 70px;
    padding: 0px;
    margin-left: 5px;
}

.btn-primary:hover {
    color: #fff;
    background-color: #f792af;
    margin-bottom: 0px;
    font-family: 'Barlow', Arial, sans-serif;
    font-weight: bold;
    border-color: #f792af
}

.btn-secondary {
    color: #fff;
    background-color: #74c8ed;
    font-family: 'Barlow', Arial, sans-serif;
    border-color: #74c8ed;
    text-align: center;
    height: 30px;
    width: 70px;
    padding: 0px;
    margin-bottom: 0px;
}

.btn-secondary:hover {
    color: #fff;
    background-color: #3da6e0;
    margin-bottom: 0px;
    font-family: 'Barlow', Arial, sans-serif;
    font-weight: bold;
    border-color: #3da6e0
}

.btn-success {
    color: #fff;
    background-color: #75cb8e;
    font-family: 'Barlow', Arial, sans-serif;
    border-color: #75cb8e;
    text-align: center;
    width: 200px;
    height: 40px;

    /* === THÊM 3 DÒNG NÀY ĐỂ CĂN GIỮA === */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    /* === THÊM 2 DÒNG NÀY ĐỂ VÔ HIỆU HÓA PADDING CỦA .btn-lg === */
    padding-top: 0;
    padding-bottom: 0;
}

.btn-danger-custom {
    color: #fff;
    background-color: #ea4335;
    border-color: #ea4335;
    font-family: 'Barlow', Arial, sans-serif;
    text-align: center;
    height: 30px;
    width: 90px;
    padding: 0px;
    margin-bottom: 0px;
    margin-left: 5px;  
}

.btn-danger-custom:hover {
    color: #fff;
    background-color: #c5342d;
    font-family: 'Barlow', Arial, sans-serif;
    font-weight: bold;
    border-color: #c5342d;
}
.form-container {
    font-family: 'Barlow', Arial, sans-serif;
    color: #000;
    width: 200px;
    height: 30px;
    margin-left: 0px;
    margin-bottom: 0px;
    margin-top: 0px;
    padding-left: 5px;
    padding-bottom: 5px;
    margin-right: 5px;
}

.top-controls-group {
    display: flex;
    justify-content: space-between;  
    align-items: center;
    flex-wrap: wrap;  
    gap: 10px;  
    margin-bottom: 20px;
}

#ProductDetails .form-group {
    display: flex;
    align-items: center;
    gap: 5px;  
    margin-bottom: 0;  
}
#search-form .form-group {
    display: flex;
    align-items: center;
    gap: 5px;  
    margin-bottom: 0;  
}

/* Ẩn bộ lọc mặc định của DataTables */
.dataTables_filter {
    display: none;
}

#spinnerModal .modal-body {
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    color: white;
}
#spinnerModal .spinner-border {
    color: #fba8bc !important;
}


/* === CSS MỚI (PHẦN BẠN CUNG CẤP) === */

/* Bọc các nút điều khiển bảng (Xem x mục | Chọn/Xoá) */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}
/* Căn lề cho "Xem x mục" */
.dataTables_length {
    font-family: 'Barlow', Arial, sans-serif;
    color: #666;
    font-weight: normal;

    /* SỬA LỖI 1: Căn giữa (do label) */
    display: flex;
    align-items: center;
}
/* SỬA LỖI 1: Ghi đè margin của Bootstrap */
.dataTables_length label {
    margin-bottom: 0 !important;
}


/* Nhóm nút bên phải (Chọn, Xoá) */
.table-controls .right-buttons {
    display: flex;
    gap: 5px;
}
/* Chỉnh lại info text (Số lượng...) */
.dataTables_info {
    font-family: 'Barlow', Arial, sans-serif;
    color: #333;
    /* Bỏ font-weight: bold; ở đây */
}
/* Thêm 2 class mới để style riêng */
.dataTables_info .info-label {
    font-weight: bold;
}
.dataTables_info .info-value {
    font-weight: normal;
}


/* === SỬA LỖI NÚT XOÁ (Yêu cầu 2) === */
/* Đổi tên class này để CSS của bạn hoạt động */
.btn-info {
    background-color: #74c8ed !important; /* Xanh */
    border-color: #74c8ed !important;
    color: white !important;
}
.btn-info:hover {
    background-color: #3da6e0 !important;
    border-color: #3da6e0 !important;
}
/* Đặt chiều rộng cố định để text không bị co lại */
#main-delete-btn {
    min-width: 210px; /* Chiều rộng cố định */
    text-align: center;
    transition: background-color 0.2s, border-color 0.2s;
}
/* Trạng thái mờ (disabled) */
#main-delete-btn:disabled {
    background-color: #e9ecef; /* Xám */
    border-color: #e9ecef;
    color: #6c757d;
    opacity: 0.65;
}
/* === SỬA LỖI MỤC II (Yêu cầu 1) === */
/* Ghi đè .form-row, ép sang Flexbox không ngắt dòng */
.count-group.form-row {
    display: flex;
    flex-wrap: nowrap; /* Bắt buộc 4 mục trên 1 hàng */
    align-items: flex-end; /* Căn các input theo lề dưới */
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    
    /* Đặt khoảng cách x (ví dụ 15px) */
    gap: 15px;  
}
/* Ghi đè .col-md-3 bên trong .count-group */
.count-group .form-group[class*="col-"] {
    /* Ghi đè padding của Bootstrap (vì gap đã xử lý) */
    padding-left: 0;
    padding-right: 0;
    /* Cho phép 4 ô co giãn BẰNG NHAU */
    flex: 1 1 0;  
    min-width: 0; /* Cho phép co nhỏ */
    /* Ghi đè width/max-width của .col-md-3 */
    width: auto;
    max-width: 100%;
    margin-bottom: 0;
}
/* Gạch dọc (Sửa lỗi layout) */
#total-packages-group {
    /* Tạo gạch dọc bằng border */
    border-left: 1px solid #ccc;
    /* 'x' - khoảng cách bên trong gạch (bằng với 'gap') */
    padding-left: 15px;  
    /* Ghi đè margin-left (không cần nữa vì đã có gap) */
    margin-left: 0;  
}
/* Đảm bảo input chiếm 100% .form-group */
.count-group .form-control {
    width: 100%;
    margin: 0; /* Ghi đè 'input' global */
}
/* Điều chỉnh gạch dọc cho màn hình nhỏ (responsive) */
@media (max-width: 991.98px) {
    .count-group.form-row {
        flex-wrap: wrap; /* Cho phép xuống dòng */
    }
    /* Ghi đè lại width/margin trên mobile */
    .count-group .form-group[class*="col-"] {
        /* Lấy lại padding của .col-6 */
        padding-left: 15px;
        padding-right: 15px;
    }
    /* Tắt gạch dọc trên mobile/tablet */
    #total-packages-group {
        border-left: none;
        padding-left: 15px; /* Giữ padding của col */
        margin-left: 0;
    }
}
/* === KẾT THÚC SỬA LỖI MỤC II === */


/* Mục III, IV: Cột "Chọn" (checkbox) */
.col-select {
    width: 50px !important;
    text-align: center;
}
.col-select input[type="checkbox"] {
    margin: 0;
    cursor: pointer;

    /* SỬA LỖI 2: Checkbox to hơn */
    transform: scale(1.4);
}
/* Căn giữa checkbox "Nhập thủ công" và "Bất thường" */
td input[type="checkbox"] {
    margin: 0;
    cursor: pointer;

    /* SỬA LỖI 2: Checkbox to hơn */
    transform: scale(1.4);
}


/* Mục Hoàn thành: Căn giữa nút */
.complete-section {
    padding-top: 20px;
    padding-bottom: 10px;
    margin: 20px 0 10px 0;
    background-color: #fdfdfd;
    border-top: 1px solid #eee;
}
/* Căn chữ vào giữa nút (Yêu cầu 6) */
.btn-lg {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* CSS CHO CẤU TRÚC MỤC MỚI */
.form-section {
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-top: 20px;
    background-color: #fafafa;
}

.form-section h5 {
    font-weight: bold;
    color: #d9534f;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* Ghi đè .form-row để căn lề dưới */
.form-row {
    align-items: flex-end;
}


/* CSS CHO TAB MENU */
.tab-content {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-top: none;
    padding: 15px;
    border-radius: 0 0 0.25rem 0.25rem;
}

.nav-tabs .nav-link {
    font-family: 'Barlow', Arial, sans-serif;
    font-weight: 600;
    color: #495057;
}

.nav-tabs .nav-link.active {
    color: #d9534f;
    border-color: #dee2e6 #dee2e6 #fff;
}

/* === CSS CHO TAB PHÂN LOẠI === */

.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background-color: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 4px;
    min-height: 50px;
}

.chip {
    display: inline-block;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

/* Trạng thái 1: Chờ xử lý (Xám) */
.chip.chip-gray {
    background-color: #e9ecef;
    color: #495057;
    border-color: #ced4da;
}
.chip.chip-gray:hover {
    background-color: #d1d5db;
}

/* Trạng thái 2: Đang xử lý (Vàng) */
.chip.chip-yellow {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
    font-weight: 700;
}

/* Trạng thái 3: Đã xử lý (Xanh) */
.chip.chip-green {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}
.chip.chip-green:hover {
    background-color: #b1dfbb;
}

/* Vô hiệu hóa Bảng C */
#sorting-area-C.disabled {
    opacity: 0.7;
    pointer-events: none;
}

/* CSS cho Modal Phân Loại */
#sortingModal .modal-lg {
    max-width: 900px;
}
#sortingModal .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}
#sortingModal .delete-row-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    line-height: 1;
}

/* === SỬA LỖI NÚT BỊ CO LẠI (TAB PHÂN LOẠI) === */
/* Ghi đè style chung cho các nút trong modal Phân loại VÀ modal Xác nhận
  để chúng không bị co lại (ghi đè width: 70px)
*/
#sortingModal .modal-footer .btn,
#sortingConfirmModal .modal-footer .btn,
#add-sorting-row-btn {
    width: auto;      /* Ghi đè width: 70px */
    height: auto;     /* Ghi đè height: 30px */
    padding: 0.375rem 0.75rem; /* Padding chuẩn của Bootstrap */
    min-width: 100px; /* Đảm bảo độ rộng tối thiểu */
}

/* Đảm bảo modal xác nhận nổi lên trên modal phân loại */
#sortingConfirmModal {
    z-index: 1060; /* Bootstrap modal mặc định là 1050 */
}

/* === SỬA ĐỔI CHO TAB PHÂN LOẠI === */

/* Căn lề cho ô quét và checkbox hàng giả */
.sorting-scan-container {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Trạng thái 4: Hàng giả (Đỏ) */
.chip.chip-red {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
    font-weight: 700;
}
.chip.chip-red:hover {
    background-color: #f1b0b7;
}

/* === SỬA ĐỔI CHO TAB PHÂN LOẠI === */

/* Bỏ căn lề ở khu vực quét (nếu còn) */
.sorting-scan-container {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Trạng thái 4: Hàng giả (Đỏ) */
.chip.chip-red {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
    font-weight: 700;
}
.chip.chip-red:hover {
    background-color: #f1b0b7;
}

/* === SỬA ĐỔI NÚT HÀNG GIẢ (Trong Modal) === */
#sortingModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Nút Bật/Tắt Hàng Giả */
#sorting-fake-toggle-btn {
    /* Ghi đè style nút chung */
    width: auto; 
    height: auto;
    padding: 0.375rem 0.75rem;
    min-width: 100px; /* Vẫn giữ min-width */
    margin-left: 15px; /* Khoảng cách với tiêu đề */

    /* Style chữ */
    font-weight: 700;
    
    /* Trạng thái Mặc định (Xám) */
    background-color: #d6d6d6; /* btn-secondary */
    border-color: #d6d6d6;
    color: white;
}

/* Trạng thái Kích hoạt (Đỏ) - Thêm class 'btn-danger' */
#sorting-fake-toggle-btn.btn-danger {
    background-color: #d9534f;
    border-color: #d9534f;
    color: white;
}

/* Trạng thái Vô hiệu hóa (Chế độ Xem) */
#sorting-fake-toggle-btn:disabled {
    opacity: 0.65;
}
/* === CSS CHO VALIDATION MODAL PHÂN LOẠI === */

#sorting-modal-alert .alert {
    margin-bottom: 15px; /* Khoảng cách với bảng */
}

/* Style cho các ô input bị lỗi (dùng class chuẩn của Bootstrap) */
#sorting-modal-table input.is-invalid {
    border-color: #d9534f; /* Viền đỏ */
    box-shadow: 0 0 0 0.2rem rgba(220,53,69,.25); /* Hào quang đỏ */
}
@media print {
    body {
        background-color: #fff;
        margin: 0;
        padding: 0;
    }
    .page {
        margin: 0;
        padding: 0;
        box-shadow: none;
        width: 100%;
        min-height: auto;
    }
    #do-print-btn {
        display: none;
    }
    .info-grid div, .info-line {
        border-bottom: 1px dotted #555;
    }

    /* === THÊM QUY TẮC NGẮT TRANG (TỐI ƯU) === */
    
    /* 1. Tránh để tiêu đề (I, II, III...) mồ côi ở cuối trang */
    h5 {
        page-break-after: avoid; 
    }

    /* 2. Tránh ngắt trang BÊN TRONG một dòng của bảng */
    .items-table tr {
        page-break-inside: avoid;
    }
    
    /* 3. Tránh ngắt trang BÊN TRONG 2 ô chữ ký */
    .sig-box {
        page-break-inside: avoid;
    }
    /* === KẾT THÚC THÊM MỚI === */
}
