/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --sidebar-w: 240px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--gray-100); color: var(--gray-900); display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar { width: var(--sidebar-w); background: var(--primary-dark); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; transition: width .3s; overflow: hidden; }
.sidebar.collapsed { width: 64px; }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 20px 16px; font-size: 1.2rem; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.1); white-space: nowrap; }
.sidebar-header i { font-size: 1.4rem; flex-shrink: 0; }
.sidebar-nav { display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; color: rgba(255,255,255,.75); text-decoration: none; font-size: .93rem; transition: all .2s; position: relative; white-space: nowrap; }
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.nav-item i { width: 20px; text-align: center; flex-shrink: 0; }
.badge { background: var(--danger); color: #fff; font-size: .7rem; padding: 2px 6px; border-radius: 20px; margin-left: auto; }

/* ===== MAIN ===== */
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 16px; padding: 0 24px; box-shadow: var(--shadow); flex-shrink: 0; }
.menu-toggle { background: none; border: none; font-size: 1.2rem; color: var(--gray-700); cursor: pointer; padding: 4px; }
.page-title { font-size: 1.15rem; font-weight: 700; color: var(--gray-900); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.date-display { font-size: .85rem; color: var(--gray-500); }
.user-info { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--gray-700); font-weight: 500; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ===== CARDS ===== */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 1rem; font-weight: 600; color: var(--gray-900); }
.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.blue { background: #dbeafe; color: var(--info); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.yellow { background: #fef3c7; color: var(--warning); }
.stat-icon.purple { background: var(--primary-light); color: var(--primary); }
.stat-info .value { font-size: 1.8rem; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-info .label { font-size: .82rem; color: var(--gray-500); margin-top: 4px; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer; font-size: .88rem; font-weight: 500; transition: all .2s; vertical-align: middle; line-height: 1.2; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-info { background: var(--info); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .8rem; vertical-align: middle; line-height: 1.2; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon { padding: 6px 10px; display: inline-flex; align-items: center; justify-content: center; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th { background: var(--gray-50); color: var(--gray-500); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--gray-200); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ===== FORM ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: .9rem; color: var(--gray-900); transition: border-color .2s; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ===== MODAL ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }
.modal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 1000; width: 90%; max-width: 560px; max-height: 90vh; overflow: hidden; flex-direction: column; }
.modal.active, .modal-overlay.active { display: flex; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-header button { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--gray-500); }
.modal-body { padding: 20px; overflow-y: auto; }

/* ===== STATUS BADGES ===== */
.status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.status-green { background: #d1fae5; color: #065f46; }
.status-red { background: #fee2e2; color: #991b1b; }
.status-yellow { background: #fef3c7; color: #92400e; }
.status-blue { background: #dbeafe; color: #1e40af; }
.status-gray { background: var(--gray-100); color: var(--gray-500); }

/* ===== SEARCH & FILTER BAR ===== */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search-input { padding: 8px 12px 8px 36px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: .9rem; width: 240px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.156a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E") no-repeat 10px center; }
.search-input:focus { outline: none; border-color: var(--primary); }

/* ===== DIEM DANH ===== */
.attendance-grid { display: grid; gap: 10px; }
.attendance-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--gray-50); border-radius: 8px; border: 1px solid var(--gray-200); }
.attendance-name { flex: 1; font-weight: 500; }
.attendance-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.att-btn { padding: 5px 12px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; font-size: .82rem; font-weight: 600; transition: all .2s; }
.att-btn.co-mat { border-color: var(--success); color: var(--success); background: transparent; }
.att-btn.co-mat.active { background: var(--success); color: #fff; }
.att-btn.vang-co-phep { border-color: var(--warning); color: var(--warning); background: transparent; }
.att-btn.vang-co-phep.active { background: var(--warning); color: #fff; }
.att-btn.vang-khong-phep, .att-btn.vang-mat { border-color: var(--danger); color: var(--danger); background: transparent; }
.att-btn.vang-khong-phep.active, .att-btn.vang-mat.active { background: var(--danger); color: #fff; }
.att-btn.tre { border-color: var(--info); color: var(--info); background: transparent; }
.att-btn.tre.active { background: var(--info); color: #fff; }

/* ===== TIEN TRINH ===== */
.progress-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 12px; }
.progress-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.progress-score { font-size: 2rem; font-weight: 700; color: var(--primary); }
.progress-bar-wrap { background: var(--gray-200); border-radius: 100px; height: 8px; margin-top: 6px; }
.progress-bar { height: 8px; border-radius: 100px; transition: width .5s; }

/* ===== THONG BAO ===== */
.notif-item { display: flex; gap: 14px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--gray-200); margin-bottom: 10px; cursor: pointer; transition: all .2s; }
.notif-item:hover { border-color: var(--primary); background: var(--primary-light); }
.notif-item.unread { border-left: 3px solid var(--primary); }
.notif-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.notif-icon.hoc-phi { background: #fef3c7; color: var(--warning); }
.notif-icon.tien-trinh { background: #d1fae5; color: var(--success); }
.notif-icon.chung { background: var(--primary-light); color: var(--primary); }
.notif-title { font-weight: 600; font-size: .92rem; margin-bottom: 3px; }
.notif-content { font-size: .85rem; color: var(--gray-500); }
.notif-time { font-size: .78rem; color: var(--gray-400); margin-left: auto; white-space: nowrap; }

/* ===== TOAST ===== */
#toastContainer { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { background: var(--gray-900); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: .9rem; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg); animation: slideIn .3s; min-width: 240px; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }
.empty-state i { font-size: 3rem; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: .95rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    z-index: 200;
    height: 100vh;
    transition: transform .3s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 199;
  }
  .sidebar-overlay.active {
    display: block;
  }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== MISC ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 1.3rem; font-weight: 700; }
.tabs { display: flex; gap: 4px; background: var(--gray-100); padding: 4px; border-radius: 10px; margin-bottom: 20px; }
.tab { padding: 8px 18px; border-radius: 8px; border: none; background: none; cursor: pointer; font-size: .88rem; font-weight: 500; color: var(--gray-500); transition: all .2s; }
.tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.info-item label { font-size: .78rem; color: var(--gray-500); margin-bottom: 2px; }
.info-item span { font-weight: 500; font-size: .9rem; }
