/* HR System — Main Stylesheet
   Visual language matches the EduFlow LMS reference: indigo primary,
   dark-navy sidebar rail, Tabler icons, card/badge/table components. */
:root {
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --primary-dark: #3730A3;
  --secondary: #0EA5E9;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --purple: #8B5CF6;
  --surface: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --transition: all .18s ease;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.6; height: 100%; overflow: hidden; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ─── App Layout ─── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ─── */
.sidebar { width: var(--sidebar-w); background: #1E1B4B; color: #C7D2FE;
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
  transition: var(--transition); z-index: 200; }
.sidebar-logo { padding: 20px 16px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08); }
.logo-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.logo-name { font-size: 16px; font-weight: 700; color: #fff; }
.logo-sub { font-size: 10px; color: #818CF8; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 8px; }
.nav-section { padding: 14px 12px 4px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .8px; color: #6366F1; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: #C7D2FE;
  transition: var(--transition); margin-bottom: 1px; }
.nav-item:hover { background: rgba(99,102,241,.2); color: #fff; }
.nav-item.active { background: rgba(99,102,241,.3); color: #fff; font-weight: 500; }
.nav-item i { font-size: 16px; width: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--primary); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 600; }
.sidebar-footer { padding: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-top: 4px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: #818CF8;
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0; }
.user-name { font-size: 12px; color: #fff; font-weight: 500; }
.user-role { font-size: 11px; color: #6366F1; }

/* ─── Main Area ─── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ─── Header ─── */
.top-header { height: var(--header-h); background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 12px; flex-shrink: 0;
  box-shadow: var(--shadow); z-index: 100; }
.header-title { font-size: 17px; font-weight: 700; color: var(--text); white-space: nowrap; }
.sidebar-toggle { background: none; border: none; font-size: 20px;
  cursor: pointer; color: var(--text-muted); padding: 4px; display: none; }

/* ─── Page Content ─── */
.page-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ─── Page header ─── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header-left h1 { font-size: 20px; font-weight: 700; }
.page-header-left .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-title { font-size: 15px; font-weight: 700; margin: 24px 0 12px; }

/* ─── Cards ─── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); }
.card-sm { padding: 14px 16px; }

/* ─── Grid ─── */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .g4, .g3, .g2 { grid-template-columns: 1fr; } }

/* ─── Stat Cards ─── */
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 12px; }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.1; }

/* ─── Buttons ─── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; transition: var(--transition); white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled)  { background: #0e9e6f; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled)  { background: var(--surface); }
.btn-sm       { padding: 5px 10px; font-size: 12px; }

/* ─── Badges ─── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-blue   { background: #EFF6FF; color: #1D4ED8; }
.badge-green  { background: #F0FDF4; color: #15803D; }
.badge-orange { background: #FFF7ED; color: #C2410C; }
.badge-red    { background: #FEF2F2; color: #B91C1C; }
.badge-purple { background: #F5F3FF; color: #6D28D9; }
.badge-gray   { background: #F1F5F9; color: var(--text-muted); }

/* ─── Tables ─── */
.table, .simple-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .simple-table th { text-align: left; padding: 10px 14px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 600; }
.table td, .simple-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td, .simple-table tr:last-child td { border-bottom: none; }
.table tr:hover td, .simple-table tr:hover td { background: var(--surface); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--border); box-shadow: var(--shadow); }
.empty-row { text-align: center; color: var(--text-muted); padding: 28px !important; font-size: 13px; }

/* ─── Forms ─── */
.panel { margin-bottom: 20px; }
.controls-panel { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.control-group { display: flex; flex-direction: column; gap: 5px; min-width: 160px; }
.control-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.control-stack { display: flex; flex-direction: column; gap: 14px; }
.control-row { display: flex; flex-direction: row; gap: 16px; }
.control-buttons { display: flex; flex-direction: row; gap: 8px; min-width: 0; align-self: flex-end; }
.control-group input[type="file"],
.control-group input[type="date"],
.control-group input[type="time"] {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; outline: none; background: var(--surface);
  color: var(--text); transition: var(--transition); font-family: inherit; }
.control-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.hint { font-size: 11px; color: var(--text-light); }

/* ─── Messages ─── */
.message-box { display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  font-size: 13px; border-left: 4px solid; border-radius: 0 8px 8px 0; margin-bottom: 20px; }
.message-box.success { background: #F0FDF4; border-color: var(--success); color: #15803D; }
.message-box.error   { background: #FEF2F2; border-color: var(--danger);  color: #B91C1C; }
.message-box.info    { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

/* ─── Legend ─── */
.legend { display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; font-size: 12.5px; color: var(--text-muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend-icon { display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.icon-present { background: #F0FDF4; color: var(--success); }
.icon-absent  { background: #FEF2F2; color: var(--danger); }
.icon-na      { background: #F1F5F9; color: var(--text-light); }
.legend-note  { color: var(--text-light); font-size: 11.5px; }

/* ─── Attendance Grid ─── */
.grid-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: auto; max-height: 65vh; position: relative; }
.att-table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; white-space: nowrap; }
.att-table th, .att-table td { padding: 8px 10px; border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border); text-align: center; }
.att-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 3;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); font-weight: 600; }
.att-table .col-id, .att-table .col-name, .att-table .col-tot {
  position: sticky; background: var(--card); z-index: 2; }
.att-table thead .col-id, .att-table thead .col-name, .att-table thead .col-tot {
  background: var(--surface); z-index: 4; }
.att-table .col-id      { left: 0;    min-width: 70px;  text-align: left; }
.att-table .col-name    { left: 70px; min-width: 160px; text-align: left; }
.att-table .col-tot     { font-weight: 600; color: var(--text); background: #FBFCFE; min-width: 66px; }
.att-table thead .col-tot { background: var(--surface); }
.att-table .col-tot-ab   { left: 230px; }
.att-table .col-tot-late { left: 296px; }
.att-table .col-tot-na   { left: 362px; box-shadow: 2px 0 4px rgba(0,0,0,.06); }
.att-table thead .col-tot-na { box-shadow: 2px 0 4px rgba(0,0,0,.06); }
.att-table .day-header { min-width: 46px; }
.att-table .day-header.weekend { background: #EEF2FF; color: var(--primary-dark); font-weight: 700; }
.att-table .day-cell { cursor: pointer; min-width: 46px; font-weight: 600; user-select: none; transition: var(--transition); position: relative; }
.att-table .day-cell:hover { filter: brightness(0.97); }
.att-table .day-cell.present { background: #F0FDF4; color: var(--success); }
.att-table .day-cell.absent  { background: #FEF2F2; color: var(--danger); }
.att-table .day-cell.na      { background: var(--surface); color: var(--text-light); }
/* Weekend (Fri/Sat) columns always get a violet overlay tint on top of their status color,
   in every row, so the weekend columns read as visually distinct at a glance. */
.att-table .day-cell.weekend { box-shadow: inset 0 0 0 999px rgba(79,70,229,.08); }
.att-table .day-cell.weekend:hover { box-shadow: inset 0 0 0 999px rgba(79,70,229,.14); }
.att-table tbody tr:hover td:not(.col-id):not(.col-name):not(.col-tot) { filter: brightness(0.98); }

/* ─── Utilities ─── */
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-10 { gap: 10px; }

/* ─── Mobile sidebar ─── */
@media (max-width: 768px) {
  .sidebar-toggle { display: flex; align-items: center; }
  .sidebar { position: fixed; left: -100%; top: 0; width: var(--sidebar-w); height: 100vh; transition: left .2s; z-index: 300; }
  .sidebar.open { left: 0; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
