* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: Calibri, Candara, 'Segoe UI', Tahoma, sans-serif;
    background-color: #f4f4f5;
    color: #1f2328;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* Menubar */
.menubar {
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}

.menubar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.menubar-title {
    font-size: 1.15em;
    font-weight: 700;
    letter-spacing: .2px;
    white-space: nowrap;
}

.menubar-nav {
    display: flex;
    gap: 8px;
    flex: 1;
}

.menubar-nav a {
    padding: 8px 14px;
    border-radius: 4px;
    font-size: .95em;
    color: #4b5563;
}

.menubar-nav a:hover { background-color: #f4f4f5; color: #1f2328; }
.menubar-nav a.active { background-color: #1f2328; color: #fff; }

.menubar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: .9em;
    color: #4b5563;
    white-space: nowrap;
}

.menubar-user a { border: 1px solid #d0d0d0; padding: 6px 12px; border-radius: 4px; }
.menubar-user a:hover { background-color: #f4f4f5; }

/* Content */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

h1 { font-size: 1.4em; font-weight: 700; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.message {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: .95em;
    border: 1px solid transparent;
}

.message.success { background-color: #eef8f0; color: #1e6b34; border-color: #c9e9d0; }
.message.error { background-color: #fdeeee; color: #a11c1c; border-color: #f3caca; }

.muted { color: #6b7280; font-size: .9em; margin-bottom: 16px; }

/* Ô tìm kiếm */
.search-bar { max-width: 360px; margin-bottom: 16px; }

.section-title { font-size: 1.1em; font-weight: 700; margin: 28px 0 10px; }

/* Thanh lọc phụ trợ cho bảng */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 20px;
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 160px;
}

.filter-bar label {
    font-size: .8em;
}

.filter-bar .button-group {
    margin-top: 0;
}

/* Form */
.form-section {
    background-color: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 24px;
    max-width: 640px;
}

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-row4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }

label { display: block; margin-bottom: 6px; color: #4b5563; font-size: .9em; font-weight: 600; }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: .95em;
    font-family: inherit;
    color: #1f2328;
    background-color: #fff;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: #1f2328; }
textarea { resize: vertical; min-height: 80px; }

input[readonly], input:disabled {
    background-color: #f0f0f1;
    color: #6b7280;
    cursor: not-allowed;
}

.field-hint { display: block; margin-top: 4px; font-size: .78em; color: #a11c1c; min-height: 1.2em; }
input.input-valid { border-color: #1e6b34; }
input.input-invalid { border-color: #a11c1c; }

.button-group { display: flex; gap: 10px; margin-top: 20px; }

.btn {
    display: inline-block;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: .9em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
}

.btn-primary { background-color: #1f2328; color: #fff; }
.btn-primary:hover { background-color: #000; }
.btn-secondary { background-color: #fff; color: #1f2328; border-color: #d0d0d0; }
.btn-secondary:hover { background-color: #f4f4f5; }
.btn-outline { background-color: #fff; color: #1f2328; border-color: #d0d0d0; }
.btn-outline:hover { background-color: #f4f4f5; }
.btn-danger-outline { background-color: #fff; color: #a11c1c; border-color: #eec9c9; }
.btn-danger-outline:hover { background-color: #fdeeee; }
.btn-block { width: 100%; }

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    overflow: hidden;
}

thead { background-color: #fafafa; }
th { padding: 12px 14px; text-align: left; font-weight: 700; font-size: .85em; color: #4b5563; border-bottom: 1px solid #e5e5e5; }
td { padding: 12px 14px; border-bottom: 1px solid #eee; font-size: .92em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: #fafafa; }

.clickable-row { cursor: pointer; }

.expanding-section {
    display: none;
    margin-top: 20px;
}

.expanding-section.open { display: block; }

th a { color: inherit; }
th a:hover { text-decoration: underline; }

.status-active { color: #1e6b34; font-weight: 600; }
.status-inactive { color: #a11c1c; font-weight: 600; }

.action-buttons { display: flex; gap: 8px; }
.action-buttons form { display: inline; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
}
.btn-icon svg { display: block; width: 16px; height: 16px; }

.no-data { text-align: center; color: #9ca3af; padding: 32px; }

tbody tr.empty-row:hover { background-color: transparent; }

/* Phân trang */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background-color: #fff;
    font-size: .9em;
    color: #1f2328;
}

a.page-link:hover { background-color: #f4f4f5; }
.page-link.current { background-color: #1f2328; color: #fff; border-color: #1f2328; }
.page-link.disabled { color: #9ca3af; cursor: default; }
.page-ellipsis { padding: 0 4px; color: #6b7280; }

.detail-truncate {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.detail-truncate:hover { color: #1f2328; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(31, 35, 40, .45);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal-box {
    background: #fff;
    border-radius: 6px;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
}

.modal-box h2 { font-size: 1.2em; font-weight: 700; margin-bottom: 20px; }

.tag-input-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background-color: #fff;
}

.tag-input-box:focus-within { border-color: #1f2328; }

.tag-input-box input[type="text"] {
    flex: 1;
    min-width: 140px;
    border: none;
    padding: 3px 4px;
}

.tag-input-box input[type="text"]:focus { outline: none; }

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 10px;
    background-color: #f4f4f5;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    font-size: .85em;
    color: #1f2328;
    white-space: nowrap;
}

.tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #6b7280;
    font-size: 1em;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.tag-remove:hover { background-color: #e5e5e5; color: #a11c1c; }

/* Toast thông báo */
.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    min-width: 240px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: .9em;
    color: #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .25s ease, transform .25s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

.toast-success { background-color: #1e6b34; }
.toast-error { background-color: #a11c1c; }

/* Login page */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f4f4f5;
    padding: 20px;
}

.login-box {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 36px;
    width: 100%;
    max-width: 360px;
}

.login-box h1 { text-align: center; margin-bottom: 24px; font-size: 1.3em; }

.table-responsive {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin-bottom: 15px;
}

.input-table { 
	width: 100%; 
	min-width: 800px;
	border-collapse: collapse; 
}

/*.input-table th, .input-table td { text-align: center; }
.input-table th { background-color: #f4f4f4; font-weight: bold; }*/
.input-table td { padding: 4px 2px; }

form>fieldset, form>fieldset>fieldset {
  padding: 5px 10px;
  margin-bottom: 10px;
  border-radius: 5px;
}

form>fieldset>legend, form>fieldset>fieldset>legend {
  background-color: gray;
  color: white;
  padding: 5px 10px;
}

/* 1. Điều chỉnh chiều cao tổng thể và căn giữa cho khung Select2 */
.select2-container .select2-selection--single {
    height: 40px !important; /* Thay đổi số này để bằng chiều cao ô input của bạn */
    display: flex;
    align-items: center;
    border: 1px solid #ccc;  /* Màu viền đồng bộ với form */
    border-radius: 4px;      /* Độ bo góc */
    position: relative;
}

/* 2. Căn chỉnh chữ hiển thị bên trong ô Select2 */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 40px !important;
    padding-left: 12px;
    padding-right: 30px; /* Tạo khoảng trống bên phải để không đè vào nút clear/mũi tên */
    color: #333;
    font-size: 14px;
    width: 100%;
}

/* 3. SỬA LỖI NÚT XÓA NHANH (DẤU X CLEAR) CHƯA ĐÚNG VỊ TRÍ */
.select2-container--default .select2-selection--single .select2-selection__clear {
    position: absolute !important;
    right: 26px !important;      /* Nằm sát lề phải, ngay trước mũi tên xổ xuống */
    top: 50% !important;
    transform: translateY(-50%) !important; /* Căn giữa tuyệt đối theo chiều dọc */
    margin-right: 0 !important;
    padding: 0 !important;
    font-size: 18px !important;  /* Tăng nhẹ kích thước dấu x cho dễ bấm */
    color: #999 !important;
    cursor: pointer;
    line-height: 1 !important;
}

/* Hiệu ứng đổi màu khi rê chuột vào nút xóa */
.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #e02424 !important; /* Đổi sang màu đỏ khi hover */
}

/* 4. Căn chỉnh lại vị trí của mũi tên góc phải cho cân đối */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px !important;
    top: 0 !important;
    right: 8px !important;
    display: flex;
    align-items: center;
}

/* 5. Tùy chỉnh ô tìm kiếm bên trong danh sách xổ xuống (Dropdown) */
.select2-search--dropdown .select2-search__field {
    height: 36px !important;
    border-radius: 4px;
    padding: 6px 10px !important;
}

/* 6. Hiệu ứng viền khi bấm chọn (Focus) giống các ô Input thông thường */
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #4f46e5 !important; /* Thay bằng màu chủ đạo form của bạn */
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    outline: none;
}
