:root {
    --header-height: 60px;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 60px; /* Tăng lên để chứa icon thay vì 20px */
    --primary-blue: #002aff;
    --secondary-blue: rgb(0, 115, 255); /* Xanh nhạt hơn cho menu con */
    --dark-navy: #2c3e50;
    --hover-bg: #ffab40;     /* Cam nhạt khi hover */
    --bg-light: #f4f7f6;
    --white: #ffffff;
    --border-color: #bbbbbb;
    --modern-orange: #ff9100;    /* Cam hiện đại */
    --success-green: #1cc88a;
}

/* --- 6. LOGIN PAGE --- */
.login-body {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-navy) 100%);
    margin: 0;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 15px;
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
    animation: fadeIn 0.5s ease-in-out;
}

.login-box h2 {
    color: var(--primary-blue);
    margin-bottom: 5px;
    font-size: 24px;
    font-weight: 800;
}

.login-box p {
    color: #777;
    margin-bottom: 30px;
    font-size: 14px;
}

.login-box .input-group {
    position: relative;
    margin-bottom: 20px;
}

.login-box .input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-blue);
}

.login-box input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 15px;
    transition: all 0.3s;
}

.login-box input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 8px rgba(0, 42, 255, 0.2);
    outline: none;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: var(--modern-orange);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

.login-box button:hover {
    background: var(--hover-bg);
    transform: translateY(-2px);
}

.login-box button:active {
    transform: translateY(0);
}

.login-box .error-list {
    background: #fff0f0;
    border-left: 4px solid #e74a3b;
    padding: 10px;
    margin-bottom: 20px;
    text-align: left;
}

.login-box .error {
    color: #e74a3b;
    font-size: 13px;
    margin: 0;
}

.login-footer {
    margin-top: 20px;
    font-size: 13px;
}

.login-footer a {
    color: var(--primary-blue);
    text-decoration: none;
}

/* --- 0. GLOBAL STYLES --- */

body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: var(--bg-light);
}

/* --- 1. HEADERBAR (Cố định trên cùng) --- */
.headerbar {
    height: var(--header-height);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001; /* Luôn nằm trên Sidebar */
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand {
    font-weight: bold;
    font-size: 20px;
    color: var(--primary-blue);
}

.current-table-display {
    font-size: 15px;
    color: #666;
    border-left: 2px solid #ddd;
    padding-left: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logout-btn {
    background: #e74a3b;
    color: white;
    text-decoration: none;
    padding: 6px 15px;
    border-radius: 4px;
    font-size: 13px;
    transition: 0.3s;
}

.logout-btn:hover { 
    background: #c0392b; 
}

/* --- 2. SIDEBAR (Cố định bên trái) --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-blue);
    color: white;
    height: 100vh;
    position: fixed;
    top: 0; /* Bắt đầu từ 0, nội dung sẽ được padding-top bằng chiều cao header */
    left: 0;
    padding-top: var(--header-height);
    transition: width 0.3s ease;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1000;
}

/* Sidebar thu gọn */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Ẩn chữ khi thu gọn */
.sidebar.collapsed .menu-title span, 
.sidebar.collapsed .menu-items, 
.sidebar.collapsed h2,
.sidebar.collapsed .arrow {
    display: none !important;
}

.sidebar a {
    display: block;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    font-size: 15px;
    white-space: nowrap; /* Không cho rớt dòng khi thu gọn */
}

.sidebar a:hover { background: var(--hover-bg); }

/* Accordion menu */
.menu-title {
    cursor: pointer;
    padding: 12px 20px;
    background: var(--primary-blue);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.menu-items {
    display: none;
    background: var(--secondary-blue);
}

.arrow { transition: transform 0.3s ease; font-size: 12px; }
.arrow.open { transform: rotate(180deg); }

/* --- 3. CONTENT AREA (Nội dung bên phải) --- */
.content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 25px;
    transition: margin-left 0.3s ease;
    min-height: calc(100vh - var(--header-height));
}

.content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* --- 4. DATATABLES & CÁC NÚT --- */
table.dataTable {
    border-collapse: collapse !important;
    width: 100% !important;
    background: white;
    /* border-radius: 4px; */
    overflow: hidden;
    border: 1px solid var(--border-color) !important;
}

table.dataTable thead th {
    background: var(--secondary-blue);
    color: white;
    font-weight: 600;
    padding: 2px;
    border: 0.5px solid var(--border-color) !important;
}

table.dataTable td {
    border: 1px solid var(--border-color) !important;
    padding: 10px;
}

/* Ô đang sửa */
.editing-cell {
    background: #fff9e6 !important;
    padding: 0 !important;
}

.editing-input {
    width: 100%;
    height: 35px;
    border: 2px solid #f6c23e;
    padding: 5px;
    box-sizing: border-box;
    outline: none;
}

/* Group nút hành động */
/* Container chứa nút trong bảng */
.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-add {
    background: var(--success-green) !important;
    color: white !important;
    border-radius: 4px !important;
    padding: 8px 16px !important;
    border: none !important;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    height: 30;
    white-space: nowrap;
}

/* Nút Sửa trong bảng */
.btn-edit {
    background: var(--modern-orange) !important; /* Dùng màu cam hiện đại của bạn */
    color: white !important;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
}
/* Nút Xóa trong bảng */
.btn-delete {
    background: #e74a3b !important; /* Màu đỏ đô */
    color: white !important;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
}

.btn-add:hover, .btn-edit:hover, .btn-delete:hover {
    background: var(--hover-bg) !important;
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); 
}

/* --- 5. TIỆN ÍCH --- */
.toggle-btn {
    padding: 15px;
    cursor: pointer;
    font-size: 20px;
    color: white;
    text-align: center;
    background: rgba(0,0,0,0.2);
}

/* --- 6. FILTERS (Bộ lọc) --- */
/* Thu nhỏ dòng chứa filter */
thead tr.filters th {
    padding: 5px !important; /* Giảm padding của ô th */
    background-color: var(--secondary-blue); /* Màu nền nhẹ để phân biệt với header chính */
    border: 1px solid var(--border-color) !important;
}
/* Tùy chỉnh ô input filter */
.filter-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 5px  !important; /* Nhỏ lại đáng kể */
    font-size: 10px !important;   /* Chữ nhỏ lại */
    font-weight: normal;
    height: 15px !important;      /* Chiều cao cố định thấp */
    color: #333;
    outline: none;
}

.filter-input:focus {
    border-color: #417690; /* Đổi màu khi click vào cho giống Django Admin */
    box-shadow: 0 0 3px rgba(65, 118, 144, 0.3);
}

/* Khóa chiều cao cố định để không bị nhảy khi bản sao header xuất hiện */
/* Ẩn bớt viền thừa nếu cần */
table.dataTable thead tr.filters th {
    border-top: none !important;
    will-change: transform, top;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.filters {
    animation: fadeIn 0.5s ease-in-out;
}

.filters th:first-child {
    pointer-events: none; /* Không cho click */
    opacity: 0.5;         /* Làm mờ đi để báo hiệu bị khóa */
}

/* --- 7. MODAL --- */
.modal-custom {
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5); /* Nền mờ phía sau */
}
/* Đổ bóng nhẹ cho Modal Content */
.modal-content-custom {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 50%;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-top: 5px solid var(--modern-orange) !important; /* Tạo điểm nhấn ở viền trên */
    animation: slideDown 0.4s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Nút chính (Lưu, Thêm, Đăng nhập) */
.btn-primary, .btn-save-modal {
    background: var(--primary-blue) !important; /* Dùng màu cam cho sinh động */
    color: var(--white) !important;
    border: none !important;
    padding: 10px 25px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary:hover, .btn-save-modal:hover {
    background: var(--hover-bg) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 145, 0, 0.3);
}

/* Nút chính 2 (Lưu thêm...) */
.btn-success {
    background: var(--success-green);
    color: var(--white) !important;
    border: none !important;
    padding: 10px 25px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-success:hover{
    background: var(--hover-bg) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 145, 0, 0.3);
}

/* Nút phụ (Hủy, Đóng, Quay lại) */
.btn-secondary, .btn-close-modal {
    background: var(--modern-orange) !important;
    color: #333 !important;
    border: 1px solid var(--border-color) !important;
    padding: 10px 25px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-secondary:hover, .btn-close-modal:hover {
    background: #e2e6ea !important;
}

.row { display: flex; gap: 10px; }
.col-6 { flex: 0 0 48%; }
.col-12 { flex: 0 0 100%; }
.mt-2 { margin-top: 10px; }
.form-control { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; }

/* Container bọc Input và Icon */
.input-group-custom {
    position: relative;
    display: flex;
    align-items: center;
}

/* Icon nằm bên trái */
.input-group-custom i {
    position: absolute;
    left: 12px;
    color: var(--primary-blue);
    font-size: 14px;
    transition: 0.3s;
}

/* Đẩy chữ trong input sang phải để không đè lên icon */
.input-group-custom .form-control {
    padding-left: 38px !important;
}

/* Hiệu ứng khi focus: Icon sáng lên */
.input-group-custom .form-control:focus + i,
.input-group-custom:focus-within i {
    color: var(--modern-orange);
}

/* Tiêu đề label cho chuyên nghiệp */
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark-navy);
    margin-bottom: 5px;
    text-transform: uppercase;
}


@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Ép danh sách Select2 nổi lên trên Modal */
.select2-container--open {
    z-index: 999999999 !important;
}

/* Đảm bảo khung Select2 có độ cao và nhìn thấy được */
.select2-container .select2-selection--single {
    height: 38px !important;
    display: flex !important;
    align-items: center;
}

/* Class để căn phải và định dạng font số cho đẹp */
    .text-right {
        text-align: right !important;
        padding-right: 5px !important;
    }

/* FORM */
    /* 1. Khung bao ngoài cùng của Form */
    .form-container-box {
        background: #ffffff;
        border: 1px solid #e0e0e0;
        border-top: 4px solid #417690; /* Thanh màu nhận diện thương hiệu */
        border-radius: 8px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); /* Tạo độ nổi (depth) */
        margin-bottom: 30px;
        overflow: hidden;
        transition: all 0.3s ease-in-out;
    }
    /* Class gốc: Định nghĩa cấu trúc hàng ngang */
    .form-group-inline {
        display: flex;
        align-items: center;
        margin-bottom: 8px;
        padding: 0 10px;
        width: 100%; /* Mặc định chiếm hết 1 hàng */
    }

    .form-group-inline label {
        white-space: nowrap;
        min-width: 100px; /* Độ rộng nhãn cố định */
        font-weight: bold;
        margin-right: 10px;
    }

    .form-group-inline input, 
    .form-group-inline select, 
    .form-group-inline .select2-container {
        flex: 1; /* Ô nhập tự giãn nở chiếm chỗ còn lại */
    }

    /* CÁC CLASS TÙY CHỈNH ĐỘ RỘNG (MODIFIERS) */
    .w-30  { width: 30% !important; }
    .w-50  { width: 50% !important; }
    .w-70  { width: 70% !important; }
    .w-100 { width: 100% !important; }
    
    .form-group-inline label {
        min-width: 90px;
        white-space:nowrap;
        font-weight: bold;
        padding: 10px;
    }

    /* 2. Tiêu đề của khung Form */
    .form-header-box {
        background: #f8f9fa;
        padding: 5px 5px;
        border-bottom: 1px solid #eee;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .form-header-box h3 {
        font-size: 1.1rem;
        font-weight: 700;
        color: #417690;
        margin: 0;
        text-transform: uppercase;
    }

    /* 3. Nội dung bên trong Form */
    .form-body-padding {
        padding: 10px;
    }

    /* 4. Tùy chỉnh các ô Input cho đồng bộ với khung */
    .form-control-custom {
        border: 1px solid #ced4da;
        border-radius: 4px;
        padding: 8px 12px;
        width: 100%;
        transition: border-color 0.2s, box-shadow 0.2s;
    }

    .form-control-custom:focus {
        border-color: #417690;
        outline: none;
        box-shadow: 0 0 0 3px rgba(65, 118, 144, 0.15);
    }

    /* 5. Chân của khung (Nơi để nút bấm) */
    .form-footer-box {
        background: #fcfcfc;
        padding: 10px 10px;
        border-top: 1px dashed #ddd;
        text-align: left;
    }

    /* 6. Phần phân cách giữa Form và Bảng (Subform) */
    .section-divider {
        border-left: 4px solid #417690;
        padding-left: 15px;
        margin: 40px 0 20px 0;
    }

    .section-divider h4 {
        font-size: 1rem;
        font-weight: 600;
        color: #333;
        margin: 0;
    }

    /* Nút đóng Form nhanh */
    .btn-close-box {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: #bbb;
        cursor: pointer;
    }
    .btn-close-box:hover { color: #d9534f; }

/* 1. Cố định dải Header */
.sticky-table-header {
    position: sticky;
    top: 60px; /* Chiều cao Navbar của Danh */
    z-index: 1020;
    background: #ffffff;
    padding: 10px 5px;
    display: flex; /* Dàn hàng ngang */
    align-items: center; 
    justify-content: flex-start; /* Xếp từ trái sang */
    gap: 20px; /* Khoảng cách giữa các phần tử */
    border: 1px solid rgb(224, 224, 224);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 2. Cố định tiêu đề bảng (thead) ngay sát dưới dải Search */
/* DataTable FixedHeader tạo ra lớp .fixedHeader-floating khi cuộn */
/* Ép toàn bộ Header và dòng lọc sử dụng tăng tốc phần cứng để hết giật */
.fixedHeader-floating {
    will-change: transform, top;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* 3. Tùy chỉnh ô search cho gọn */
.dataTables_filter input {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 10px;
    margin-left: 10px;
}
/* 2. Đẩy từ vị trí ô Search (f) và Phân trang (p) sang bên phải */
/* Trong DataTable, ô Search có class .dataTables_filter, .dataTables_paginate */
 /* Lệnh thần thánh để đẩy cụm này về bên phải */
.sticky-table-header .dataTables_length {
    margin-left: auto !important;
}
/* --- 1. TỔNG THỂ CỤM NÚT --- */
.dt-buttons {
    display: flex !important;
    gap: 8px; /* Khoảng cách giữa các nút */
    margin: 0 0px !important;
}

/* Style chung cho tất cả nút trong cụm B */
.dt-button {
    border: 1px solid #ddd !important;
    background: #ffffff !important;
    padding: 5px 10px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
    transition: all 0.3s ease !important; /* Hiệu ứng đổi màu mượt mà */
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* --- 2. MÀU SẮC RIÊNG VÀ HIỆU ỨNG HOVER --- */

/* Nút Sao chép (Copy) - Màu xanh dương */
.btn-export-copy { color: #007bff !important; border-color: #007bff !important; }
.btn-export-copy:hover { 
    background: #007bff !important; 
    color: #ffffff !important; 
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
    transform: translateY(-2px); /* Nhích nhẹ lên trên */
}

/* Nút Excel - Màu xanh lá đặc trưng */
.btn-export-excel { color: #1d6f42 !important; border-color: #1d6f42 !important; }
.btn-export-excel:hover { 
    background: #1d6f42 !important; 
    color: #ffffff !important; 
    box-shadow: 0 4px 8px rgba(29, 111, 66, 0.3);
    transform: translateY(-2px);
}

/* Nút PDF - Màu đỏ gạch */
.btn-export-pdf { color: #d32f2f !important; border-color: #d32f2f !important; }
.btn-export-pdf:hover { 
    background: #d32f2f !important; 
    color: #ffffff !important; 
    box-shadow: 0 4px 8px rgba(211, 47, 47, 0.3);
    transform: translateY(-2px);
}

/* Nút In (Print) - Màu xám đen chuyên nghiệp */
.btn-export-print { color: #343a40 !important; border-color: #343a40 !important; }
.btn-export-print:hover { 
    background: #343a40 !important; 
    color: #ffffff !important; 
    box-shadow: 0 4px 8px rgba(52, 58, 64, 0.3);
    transform: translateY(-2px);
}

/* Nút Hiện cột (Colvis) - Màu tím hoặc xám xanh */
.btn-colvis { color: #6f42c1 !important; border-color: #6f42c1 !important; }
.btn-colvis:hover { 
    background: #6f42c1 !important; 
    color: #ffffff !important; 
    box-shadow: 0 4px 8px rgba(111, 66, 193, 0.3);
    transform: translateY(-2px);
}

/* pppp--------------------------------------------pppppppppp */
/* Container trong ô TH */
.header-inline-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    width: 100%;
}

.header-text {
    font-size: 13px;
    font-weight: bold;
    color: white;
    white-space: nowrap;
}

/* Ô input nằm trong tiêu đề */
.filter-input-inline {
    width: auto !important;
    height: 15px !important;
    font-size: 11px !important;
    padding: 2px 5px !important;
    border: 1px solid rgba(255,255,255,0.4) !important;
    border-radius: 4px;
    background: rgba(255,255,255,0.9);
    color: #333;
    font-weight: normal;
}

/* Tắt icon sort mặc định để không bị đè lên ô lọc */
table.dataTable thead th.sorting:before, 
table.dataTable thead th.sorting:after {
    display: none !important;
}

/* Container chính dùng Flex */
.form-flex-container {
    display: flex;
    gap: 20px; /* Khoảng cách giữa 2 khối */
    align-items: stretch; /* Ép 2 bên cao bằng nhau */
}

/* Khối bên trái: 60% */
.form-left-content {
    flex: 0 0 70%; 
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Khối bên phải: 40% */
.form-right-image {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
}

.form-right-image label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #417690;
}

/* Khung chứa ảnh Preview */
.image-preview-container {
    flex-grow: 1; /* Tự động cao hết phần còn lại */
    border: 2px dashed #ddd;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: #f9f9f9;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px; /* Độ cao tối thiểu khi chưa có nội dung */
    margin-right: 30px;
}

.image-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Giữ nguyên tỷ lệ ảnh, không bị méo */
    transition: transform 0.3s;
}

/* Hiệu ứng khi di chuột vào ảnh */
.upload-overlay {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 10px;
    text-align: center;
    opacity: 0;
    transition: 0.3s;
}

.image-preview-container:hover .upload-overlay {
    opacity: 1;
}

.image-preview-container:hover img {
    transform: scale(1.05);
}

