/* THEME XANH TRẮNG CÔNG NGHỆ HIỆN ĐẠI */
:root { 
    --primary: #00529c; --primary-hover: #003d73; /* Màu xanh áo Đoàn Thanh Niên */
    --success: #059669; --danger: #ef4444; --light: #f8fafc; 
    --warning: #f59e0b; --info: #0ea5e9; --dark: #0f172a; 
    --bg-color: #f1f5f9; --surface: #ffffff; --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 10px;
}

/* CẬP NHẬT: Giao diện Dashboard cố định màn hình, không cuộn */
body { font-family: 'Inter', sans-serif; background-color: var(--bg-color); color: #334155; margin: 0; padding: 0; display: flex; justify-content: center; height: 100vh; overflow: hidden; }

/* HIỆU ỨNG ANIMATION MƯỢT MÀ */
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* --- GIAO DIỆN ĐĂNG NHẬP CHUYÊN NGHIỆP MỚI --- */
.login-wrapper {
    width: 100%; height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; 
    background-color: #f1f5f9; background-image: radial-gradient(#cbd5e1 1px, transparent 1px); background-size: 24px 24px; animation: fadeIn 0.5s; 
}
.login-container { 
    background: #ffffff; border-radius: 24px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15), 0 10px 15px -3px rgba(0, 0, 0, 0.05); 
    width: 100%; max-width: 960px; height: fit-content; display: flex; flex-direction: row; overflow: hidden; 
    border: 1px solid rgba(255, 255, 255, 0.6); animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1); 
}
.login-half { padding: 40px; flex: 1; display: flex; flex-direction: column; }

.login-left { background: linear-gradient(145deg, #f8fafc 0%, #f1f8ff 100%); border-right: 1px solid #e2e8f0; gap: 20px; }
.login-right { background: #ffffff; justify-content: center; }

.brand-header { display: flex; align-items: center; gap: 15px; margin-bottom: 5px; }
.brand-header .union-logo { width: 60px; height: 60px; object-fit: contain; }
.brand-header .phuong-name { color: var(--info); font-size: 15px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: 1.5px; }
.brand-header .system-name { color: var(--primary); font-size: 22px; font-weight: 800; margin: 4px 0 0 0; letter-spacing: -0.5px; }

.public-card { background: #ffffff; border-radius: 16px; padding: 20px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05); border: 1px solid #e0f2fe; transition: transform 0.2s, box-shadow 0.2s; }
.public-card:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: #bae6fd; }
.public-card h4 { margin: 0 0 8px 0; color: var(--dark); font-size: 15px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.public-card p { font-size: 13px; color: #64748b; margin: 0 0 15px 0; line-height: 1.5; }
.public-card ul { margin: 0; padding-left: 22px; font-size: 13px; color: #64748b; line-height: 1.7; }
.public-card ul li b { color: #475569; }

.admin-header { text-align: center; margin-bottom: 25px; }
.admin-header h3 { margin: 0; font-size: 20px; color: var(--dark); font-weight: 800; letter-spacing: -0.5px; }
.admin-header p { margin: 5px 0 0 0; font-size: 14px; color: #64748b; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 8px; }
.form-group input { width: 100%; padding: 12px 15px; border-radius: 10px; }

.form-options { display: flex; justify-content: flex-start; align-items: center; margin-bottom: 18px; }
.remember-me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #475569; cursor: pointer; user-select: none; font-weight: 500; }
.remember-me input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); margin: 0; }

.captcha-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 15px; margin-bottom: 18px; }
.captcha-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.captcha-header label { font-size: 13px; font-weight: 600; color: #475569; margin: 0; }
.captcha-code { background: #e2e8f0; color: var(--danger); padding: 4px 10px; border-radius: 6px; font-size: 16px; letter-spacing: 3px; user-select: none; font-weight: 700; }
.refresh-captcha { color: var(--primary); cursor: pointer; margin-left: 10px; font-size: 15px; transition: transform 0.3s ease; padding: 5px; }
.refresh-captcha:hover { transform: rotate(180deg); }
.captcha-box input { width: 100%; padding: 10px 15px; text-transform: uppercase; }

.btn-login { padding: 14px; font-size: 15px; border-radius: 10px; font-weight: 600; letter-spacing: 0.5px; box-shadow: 0 4px 6px rgba(0, 82, 156, 0.25); transition: all 0.3s; }
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 15px rgba(0, 82, 156, 0.3); }
.btn-login:active { transform: translateY(0); box-shadow: 0 4px 6px rgba(0, 82, 156, 0.25); }

/* FORM & INPUTS */
input, select, textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; font-family: inherit; transition: all 0.2s ease; outline: none; background: #f8fafc; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(0, 82, 156, 0.15); }

/* CẬP NHẬT: Container chính chiếm full màn hình và sử dụng flexbox để chia bố cục */
.main-container { display: none; background: var(--bg-color); width: 100%; height: 100vh; flex-direction: column; padding: 20px; box-sizing: border-box; animation: fadeIn 0.4s ease-out; }

.header-container { text-align: center; margin-bottom: 10px; flex-shrink: 0; }
.header-container h2 { color: var(--dark); font-weight: 700; padding-bottom: 5px; display: inline-block; margin: 0; font-size: 24px; letter-spacing: -0.5px; }
.header-container h2 i { color: var(--primary); }

.toolbar-container { display: none; flex-direction: column; gap: 12px; margin-bottom: 15px; background: var(--surface); padding: 15px 16px; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); flex-shrink: 0; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.toolbar-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; flex: 1; }
.toolbar-filters input, .toolbar-filters select { padding: 8px 10px; border-radius: 6px; font-size: 13px; width: 100%; border: 1px solid var(--border); background: var(--bg-color); outline: none;}
.toolbar-filters input:focus, .toolbar-filters select:focus { border-color: var(--primary); background: #fff;}
.toolbar-filters input[type="text"] { min-width: 160px; }

/* --- NÂNG CẤP CARD THỐNG KÊ HIỆN ĐẠI --- */
.stats-cards { display: none; gap: 15px; margin-bottom: 15px; flex-shrink: 0; }
.stat-card { flex: 1; display: flex; align-items: center; padding: 15px 20px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); border: 1px solid var(--border); gap: 15px; transition: transform 0.2s, box-shadow 0.2s; position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.stat-card.primary::before { background: var(--info); }
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.warning::before { background: var(--warning); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; justify-content: center; align-items: center; font-size: 20px; flex-shrink: 0; }
.stat-card.primary .stat-icon { background: #e0f2fe; color: var(--info); }
.stat-card.success .stat-icon { background: #d1fae5; color: var(--success); }
.stat-card.danger .stat-icon { background: #fee2e2; color: var(--danger); }
.stat-card.warning .stat-icon { background: #fef3c7; color: var(--warning); }
.stat-info { display: flex; flex-direction: column; justify-content: center; }
.stat-info span { font-size: 12px; color: #64748b; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-info h3 { margin: 4px 0 0 0; font-size: 24px; color: var(--dark); font-weight: 800; line-height: 1; }

/* --- NÂNG CẤP NHÃN (BADGES/PILLS) --- */
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill-success { background: #d1fae5; color: #047857; border: 1px solid #a7f3d0; }
.pill-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.pill-primary { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.pill-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.pill-pink { background: #fce7f3; color: #be185d; border: 1px solid #fbcfe8; }
.pill-gray { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

/* HIỆU ỨNG LOADING TOÀN MÀN HÌNH */
.loading-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.7); z-index: 2000; flex-direction: column; justify-content: center; align-items: center; backdrop-filter: blur(4px); animation: fadeIn 0.2s; }
.tech-spinner { width: 60px; height: 60px; border: 5px solid #cce4f7; border-top: 5px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; box-shadow: 0 0 15px rgba(0, 82, 156, 0.4); }
.tech-spinner-text { margin-top: 20px; color: var(--primary); font-weight: bold; font-size: 16px; letter-spacing: 1px; text-transform: uppercase; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* THANH TRẠNG THÁI LOADING TẠI TOP (PROGRESS BAR) */
#topProgressBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background-color: var(--warning);
    z-index: 9999;
    transition: width 0.4s ease, opacity 0.4s ease;
    box-shadow: 0 0 10px var(--warning);
    opacity: 0;
}

/* CẬP NHẬT: Vùng chứa bảng tự động cuộn (dọc và ngang) khi vượt quá kích thước */
.table-responsive { flex-grow: 1; width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; min-width: 1600px; border-collapse: collapse; font-size: 13.5px; }
th, td { border-bottom: 1px solid var(--border); padding: 12px 10px; text-align: left; vertical-align: middle; }

/* CẬP NHẬT: Header bảng cố định (Sticky Header) */
th { background-color: #f1f5f9; color: #334155; text-transform: uppercase; font-size: 12px; font-weight: 800; letter-spacing: 0.5px; text-align: center; white-space: nowrap; position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 2px rgba(0,0,0,0.05); border-bottom: 2px solid #cbd5e1; }
tr { transition: background-color 0.2s ease; }
tr:hover { background-color: #f1f5f9; }

/* BUTTONS */
.btn { border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; color: white; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); font-size: 13px; font-weight: 600; text-align: center; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-full { width: 100%; padding: 12px; }
.btn-primary { background-color: var(--primary); }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-success { background-color: var(--success); }
.btn-success:hover { background-color: #047857; }
.btn-warning { background-color: var(--warning); color: #333; }
.btn-warning:hover { background-color: #d97706; color: white; }
.btn-info { background-color: var(--info); }
.btn-info:hover { background-color: #0284c7; }
.btn-danger { background-color: var(--danger); }
.btn-danger:hover { background-color: #b91c1c; }
.btn-secondary { background-color: #6c757d; }
.btn-secondary:hover { background-color: #5a6268; }
.btn-dark { background-color: var(--dark); }
.btn-dark:hover { background-color: #000; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 6px; }

.action-group { display: flex; gap: 6px; justify-content: center; }

.pagination-container { display: flex; justify-content: space-between; align-items: center; background: var(--surface); padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-top: 15px; flex-shrink: 0;}
.page-info { font-weight: bold; color: var(--dark); font-size: 13px; }
.page-controls { display: flex; gap: 10px; }

#toast { visibility: hidden; min-width: 250px; background-color: #1e293b; color: #fff; text-align: center; border-radius: 8px; padding: 14px 20px; position: fixed; z-index: 1000; bottom: 30px; right: 30px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; justify-content: center; }
#toast.show { visibility: visible; animation: fadein 0.5s, fadeout 0.5s 4.5s; }
#toast.success { background-color: var(--success); }
#toast.error { background-color: var(--danger); }
#toast.warning { background-color: var(--warning); color: #333; }
@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

/* MODALS */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); z-index: 999; justify-content: center; align-items: center; backdrop-filter: blur(4px); animation: fadeIn 0.25s ease-out; }
.modal-content { background: var(--surface); padding: 24px; border-radius: 16px; width: 90%; max-width: 600px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); max-height: 90vh; overflow-y: auto; animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.modal-content h3 { margin-top: 0; color: var(--dark); font-size: 20px; text-align: center; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 15px;}
.modal-content h3 i { color: var(--primary); margin-right: 5px; }

.input-group { margin-bottom: 10px; text-align: left; }
.input-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: #475569; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 15px; border-top: 1px solid #eee; padding-top: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* HEADER MAIN SCREEN */
.main-header { display: flex; justify-content: space-between; align-items: center; background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%); padding: 15px 20px; border-radius: 16px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); border: 1px solid var(--border); border-bottom: 3px solid var(--primary); margin-bottom: 15px; flex-shrink: 0; }
.header-left { display: flex; align-items: center; gap: 15px; }
.header-logo { width: 55px; height: 55px; object-fit: contain; }
.header-titles { display: flex; flex-direction: column; justify-content: center; }
.header-phuong { margin: 0; font-size: 18px; color: var(--info); text-transform: uppercase; font-weight: 800; letter-spacing: 0.5px; }
.header-sysname { margin: 0; font-size: 13px; color: var(--dark); font-weight: 600; opacity: 0.8; text-transform: uppercase; }

.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.header-datetime { font-size: 13px; color: #64748b; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.header-user-info { display: flex; align-items: center; gap: 15px; }
.role-badge { font-size: 10px; padding: 2px 8px; border-radius: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; margin-left: 5px; }
.role-admin { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.role-manager { background: #e0f2fe; color: #0284c7; border: 1px solid #bae6fd; }
.btn-logout { padding: 6px 12px; font-size: 13px; }

.manager-only { display: none; }
/* Khung hiển thị kết quả AI */
.ai-output-box { border: 1px solid var(--border); background: var(--bg-color); padding: 15px; border-radius: 8px; min-height: 150px; max-height: 300px; overflow-y: auto; font-size: 14.5px; line-height: 1.6; margin-top: 15px; }

/* Ẩn khu vực đăng nhập Admin trên điện thoại */
@media (max-width: 768px) {
    .login-wrapper { padding: 15px; background-image: none; height: auto; min-height: 100vh; justify-content: flex-start; }
    .login-container { flex-direction: column; border-radius: 16px; max-height: none; overflow: visible; }
    .login-half { padding: 25px 20px; }
    .login-left { border-right: none; border-bottom: 1px solid #e2e8f0; }
}