/* ============================================================
   HRMS — Light Professional Theme
   Font: Inter (body) + JetBrains Mono (numbers/code)
   ============================================================ */

:root {
  --bg:         #f5f6fa;
  --surface:    #ffffff;
  --surface2:   #f0f2f8;
  --border:     #e2e6f0;
  --border2:    #c8d0e8;
  --primary:    #2563eb;
  --primary-lt: #eff4ff;
  --primary-dk: #1d4ed8;
  --accent:     #059669;
  --warn:       #dc2626;
  --orange:     #d97706;
  --purple:     #7c3aed;
  --text:       #111827;
  --text2:      #374151;
  --muted:      #6b7280;
  --radius:     8px;
  --sidebar-w:  230px;
  --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);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.brand-name { font-size: 15px; font-weight: 700; color: var(--text); }
.brand-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }

.sidebar-nav { padding: 10px 0; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-left: 3px solid transparent;
  transition: all .12s;
  text-decoration: none;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-link:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-lt); color: var(--primary); border-left-color: var(--primary); }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary-lt);
  color: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--muted); text-transform: capitalize; }
.logout-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--muted);
  transition: all .12s;
  flex-shrink: 0;
}
.logout-btn:hover { background: #fee2e2; color: var(--warn); text-decoration: none; }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Page header ── */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 17px; font-weight: 700; color: var(--text); }
.page-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Content area ── */
.content { padding: 24px 28px; flex: 1; }

/* ── Flash messages ── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
}
.flash button { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; opacity: .6; }
.flash-success { background: #d1fae5; color: #065f46; border-bottom: 1px solid #a7f3d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border-bottom: 1px solid #fecaca; }
.flash-info    { background: #dbeafe; color: #1e40af; border-bottom: 1px solid #bfdbfe; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text); }
.card-body  { padding: 20px; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--text); }
.stat-value.blue   { color: var(--primary); }
.stat-value.green  { color: var(--accent); }
.stat-value.orange { color: var(--orange); }
.stat-value.red    { color: var(--warn); }
.stat-value.purple { color: var(--purple); }

/* ── Grid layouts ── */
.grid-2    { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
.grid-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3    { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.gap-16    { display: flex; flex-direction: column; gap: 16px; }
.row       { display: flex; gap: 10px; }
.col       { flex: 1; min-width: 0; }

/* ── Forms ── */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field-label .req { color: var(--warn); }
input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
select option { background: var(--surface); }
.check-row { display: flex; gap: 18px; flex-wrap: wrap; }
.check-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; cursor: pointer; color: var(--text2);
  user-select: none;
}
.check-label input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--primary); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); color: #fff; text-decoration: none; }
.btn-ghost    { background: var(--surface); color: var(--text2); border-color: var(--border2); }
.btn-ghost:hover { background: var(--surface2); text-decoration: none; }
.btn-success  { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.btn-success:hover { background: #a7f3d0; text-decoration: none; }
.btn-danger   { background: #fee2e2; color: var(--warn); border-color: #fecaca; }
.btn-danger:hover { background: #fecaca; text-decoration: none; }
.btn-orange   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.btn-orange:hover { background: #fde68a; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; border-radius: 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Tables ── */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--surface2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 3;
  white-space: nowrap;
}
tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--primary-lt); }
.sticky-left { position: sticky; left: 0; background: var(--surface) !important; z-index: 4; }
tbody tr:hover .sticky-left { background: var(--primary-lt) !important; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-primary  { background: #dbeafe; color: #1e40af; }
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-purple   { background: #ede9fe; color: #5b21b6; }
.badge-gray     { background: #f3f4f6; color: #374151; }

/* ── Attendance cells ── */
.att-cell {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  border-right: 1px solid var(--border);
  transition: filter .1s;
  min-width: 36px;
  height: 32px;
  vertical-align: middle;
  user-select: none;
}
.att-cell:hover { filter: brightness(.92); }
.att-P   { background: #d1fae5; color: #065f46; }
.att-A   { background: #fee2e2; color: #991b1b; }
.att-H   { background: #fef3c7; color: #92400e; }
.att-DD  { background: #dbeafe; color: #1e40af; }
.att-L   { background: #ede9fe; color: #5b21b6; }
.att-PL  { background: #d1fae5; color: #047857; }
.att-HOL { background: #e0e7ff; color: #3730a3; }
.day-hdr {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-align: center; border-right: 1px solid var(--border);
  padding: 5px 2px; min-width: 36px; cursor: default;
  white-space: nowrap;
}
.day-hdr.holiday  { color: #3730a3; background: #e8eaff; }
.day-hdr.weekend  { color: #991b1b; background: #fff1f2; }
.note-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--primary); display: inline-block; vertical-align: middle; margin-left: 2px; }

/* Dept row in attendance */
.dept-hdr-row td {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 6px 12px !important; border-bottom: 1px solid var(--border);
}
.subgroup-row td {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 4px 12px 4px 24px !important;
  background: var(--surface2) !important;
  border-bottom: 1px solid var(--border);
}

/* ── Month/year picker bar ── */
.period-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.period-bar label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.period-bar select { width: auto; padding: 6px 10px; }

/* ── Legend ── */
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot  { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* ── Modals ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(17,24,39,.45);
  backdrop-filter: blur(3px);
  z-index: 9999;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-width: 360px;
  max-width: 95vw;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff4ff 0%, #f5f6fa 50%, #eef2ff 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(37,99,235,.08);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 44px; height: 44px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 20px;
}
.login-logo-text { font-size: 20px; font-weight: 700; color: var(--text); }
.login-logo-sub  { font-size: 12px; color: var(--muted); }
.login-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.login-sub   { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.login-error {
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Payslip print ── */
@media print {
  .sidebar, .page-header, .page-actions, .btn, .flash { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .payslip-print { display: block !important; }
  body { background: #fff; }
}

/* ── Utilities ── */
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { display: flex; flex-direction: column; gap: 8px; }
.text-muted  { color: var(--muted); font-size: 12px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-success { color: var(--accent); }
.text-danger  { color: var(--warn); }
.text-primary { color: var(--primary); }
.fw-700 { font-weight: 700; }
.empty-state { padding: 32px; text-align: center; color: var(--muted); font-size: 13px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Responsive ── */
@media (max-width: 960px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .grid-2, .grid-2-eq, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
