/* ============================================
   AttendX — Design System
   Palette: Alpine Frost + Deep Navy
   Font: Plus Jakarta Sans + Geist Mono
============================================ */

:root {
  --bg-base:       #0A1929;
  --bg-surface:    #0F2540;
  --bg-card:       #132F4C;
  --bg-hover:      #1A3A5C;
  --border:        #1E4976;
  --border-light:  #2E5090;

  --text-primary:  #E3EDF7;
  --text-secondary:#A8C4E0;
  --text-muted:    #5A8AB0;

  --accent:        #2E5090;
  --accent-bright: #4A90D9;
  --accent-glow:   rgba(74, 144, 217, 0.18);

  --present:       #22C55E;
  --present-bg:    rgba(34, 197, 94, 0.12);
  --absent:        #EF4444;
  --absent-bg:     rgba(239, 68, 68, 0.12);
  --leave:         #F59E0B;
  --leave-bg:      rgba(245, 158, 11, 0.12);
  --late:          #A78BFA;
  --late-bg:       rgba(167, 139, 250, 0.12);

  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.5);

  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --sidebar-w:     240px;
  --topbar-h:      72px;

  --font-sans:     'Plus Jakarta Sans', sans-serif;
  --font-mono:     'Geist Mono', monospace;

  --transition:    all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ============================================
   SIDEBAR
============================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  padding: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(74, 144, 217, 0.35);
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-bright);
  border: 1px solid rgba(74, 144, 217, 0.25);
}

.nav-item.active svg { stroke: var(--accent-bright); }

.sidebar-footer {
  padding: 16px 20px 24px;
  border-top: 1px solid var(--border);
}

.live-clock {
  text-align: center;
}

.clock-time {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent-bright);
  letter-spacing: 0.05em;
  line-height: 1;
}

.clock-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}

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

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; flex-direction: column; gap: 2px; }

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================
   BUTTONS
============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  color: white;
  box-shadow: 0 4px 12px rgba(74, 144, 217, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(74, 144, 217, 0.45);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-lg { padding: 13px 28px; font-size: 0.95rem; }

.btn-danger {
  background: var(--absent-bg);
  color: var(--absent);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

/* ============================================
   VIEWS
============================================ */
.view {
  display: none;
  padding: 28px 32px;
  flex: 1;
  animation: fadeIn 0.25s ease;
}
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   STATS GRID
============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.stat-total::before   { background: linear-gradient(90deg, var(--accent-bright), var(--accent)); }
.stat-present::before { background: linear-gradient(90deg, var(--present), #16a34a); }
.stat-absent::before  { background: linear-gradient(90deg, var(--absent), #dc2626); }
.stat-leave::before   { background: linear-gradient(90deg, var(--leave), #d97706); }

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-total   .stat-icon { background: var(--accent-glow); color: var(--accent-bright); }
.stat-present .stat-icon { background: var(--present-bg); color: var(--present); }
.stat-absent  .stat-icon { background: var(--absent-bg);  color: var(--absent); }
.stat-leave   .stat-icon { background: var(--leave-bg);   color: var(--leave); }

.stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- Rate Card ---- */
.rate-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 28px;
}

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

.rate-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rate-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-bright);
}

.rate-bar-bg {
  height: 10px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}

.rate-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-bright), var(--present));
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   SECTION HEADER
============================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ============================================
   TABLE
============================================ */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead tr {
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 13px 18px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(30, 73, 118, 0.4);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover td {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.data-table tbody tr.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-size: 0.85rem;
}

/* Employee name cell */
.emp-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.emp-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

.emp-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.emp-id {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ---- Status Pills ---- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pill-present { background: var(--present-bg); color: var(--present); }
.pill-present::before { background: var(--present); box-shadow: 0 0 6px var(--present); }

.pill-absent  { background: var(--absent-bg);  color: var(--absent); }
.pill-absent::before  { background: var(--absent); }

.pill-leave   { background: var(--leave-bg);   color: var(--leave); }
.pill-leave::before   { background: var(--leave); }

.pill-late    { background: var(--late-bg);    color: var(--late); }
.pill-late::before    { background: var(--late); }

/* ---- Action Buttons in Table ---- */
.action-btns { display: flex; gap: 6px; }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.icon-btn.delete:hover { background: var(--absent-bg); color: var(--absent); border-color: rgba(239,68,68,0.3); }

/* ============================================
   ATTENDANCE VIEW
============================================ */
.attendance-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.date-picker-row { display: flex; flex-direction: column; gap: 6px; }

.bulk-actions { display: flex; gap: 8px; }

.save-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Status selector in attendance table */
.status-select {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.status-select:focus { border-color: var(--accent-bright); }
.status-select option { background: var(--bg-card); }

.note-input {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  padding: 6px 10px;
  width: 180px;
  outline: none;
  transition: var(--transition);
}

.note-input:focus { border-color: var(--accent-bright); }
.note-input::placeholder { color: var(--text-muted); }

/* ============================================
   REPORTS VIEW
============================================ */
.report-filters {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-group { display: flex; flex-direction: column; gap: 6px; }

/* ============================================
   SEARCH BAR
============================================ */
.search-bar-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  flex: 1;
  max-width: 360px;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box svg { color: var(--text-muted); flex-shrink: 0; }

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  width: 100%;
}

.search-box input::placeholder { color: var(--text-muted); }

/* ============================================
   FORM ELEMENTS
============================================ */
.field-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.form-input, .date-input, .filter-select {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 10px 14px;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

.form-input:focus, .date-input:focus, .filter-select:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.filter-select { cursor: pointer; }
.filter-select option { background: var(--bg-card); }

.date-input { cursor: pointer; }
.date-input::-webkit-calendar-picker-indicator { filter: invert(0.6); cursor: pointer; }

/* ============================================
   MODAL
============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 95vw;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 7px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--border);
}

/* ============================================
   TOAST
============================================ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
}

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

.toast.success { border-left: 4px solid var(--present); }
.toast.error   { border-left: 4px solid var(--absent); }
.toast.info    { border-left: 4px solid var(--accent-bright); }

/* ============================================
   DEPT BADGE
============================================ */
.dept-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--accent-glow);
  color: var(--accent-bright);
  border: 1px solid rgba(74, 144, 217, 0.2);
}

/* ============================================
   SCROLLBAR
============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .view { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .form-row { grid-template-columns: 1fr; }
  .report-filters { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-right .btn-ghost { display: none; }
}