/* ==========================================================================
   Wattnvolt Attendance — design system
   Palette matches the existing PO Management System screenshots (navy +
   indigo active-state) so this feels like a continuation, not a reinvention.
   Inter for UI chrome; IBM Plex Mono for anything that's a number or a
   clock time — this is a time-tracking tool, the data should read like a
   ledger, not like prose. Every status gets a left-edge color bar on table
   rows rather than just a pill, reinforcing the "log" feeling of a punch
   record without adding visual noise.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #0b1220;
  --surface: #131b2e;
  --surface-raised: #1a2338;
  --surface-hover: #1f2a42;
  --border: #232d45;
  --border-soft: #1b2438;

  /* Text */
  --text: #e8ecf4;
  --text-secondary: #949fb8;
  --text-muted: #5b6478;

  /* Accent (matches the active-tab indigo in the live PO Management UI) */
  --accent: #6366f1;
  --accent-hover: #7c7ff2;
  --accent-soft: rgba(99, 102, 241, 0.14);

  /* Status */
  --present: #10b981;
  --present-soft: rgba(16, 185, 129, 0.14);
  --absent: #ef4444;
  --absent-soft: rgba(239, 68, 68, 0.14);
  --late: #f59e0b;
  --late-soft: rgba(245, 158, 11, 0.14);
  --leave: #38bdf8;
  --leave-soft: rgba(56, 189, 248, 0.14);
  --leave-availed: #2dd4bf;
  --leave-availed-soft: rgba(45, 212, 191, 0.14);
  --holiday: #94a3b8;
  --holiday-soft: rgba(148, 163, 184, 0.14);
  --review: #fb923c;
  --review-soft: rgba(251, 146, 60, 0.14);

  --radius: 8px;
  --radius-lg: 12px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 24px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.sidebar-brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: #b4b6fb; }

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 16px 12px 6px;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 32px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.stat-card.present .value { color: var(--present); }
.stat-card.absent .value { color: var(--absent); }
.stat-card.late .value { color: var(--late); }
.stat-card.review .value { color: var(--review); }

/* ---------- Table ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  transition: background 0.1s ease;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }

tbody tr.row-status::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--status-color, transparent);
}

td {
  padding: 11px 16px;
  vertical-align: middle;
  white-space: nowrap;
}

td.mono, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

td.wrap { white-space: normal; }

.employee-cell { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-raised);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  object-fit: cover;
  flex-shrink: 0;
}

.emp-name { font-weight: 600; font-size: 13.5px; }
.emp-id { color: var(--text-muted); font-size: 11.5px; font-family: var(--font-mono); }

/* ---------- Status pill ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}

.pill-present { background: var(--present-soft); color: var(--present); }
.pill-absent { background: var(--absent-soft); color: var(--absent); }
.pill-late { background: var(--late-soft); color: var(--late); }
.pill-leave { background: var(--leave-soft); color: var(--leave); }
.pill-leave_availed { background: var(--leave-availed-soft); color: var(--leave-availed); }
.pill-holiday, .pill-sunday { background: var(--holiday-soft); color: var(--holiday); }
.pill-half_day { background: var(--late-soft); color: var(--late); }
.pill-review { background: var(--review-soft); color: var(--review); }

.ot-positive { color: var(--present); }
.ot-negative { color: var(--absent); }
.ot-zero { color: var(--text-muted); }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.12s ease, background 0.12s ease;
}

.btn:hover { filter: brightness(1.08); }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--surface-raised); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--absent-soft); color: var(--absent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ---------- Misc ---------- */

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-secondary);
}

.empty-state .big { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 6px 8px;
}

.date-nav button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 15px;
}

.date-nav button:hover { background: var(--surface-hover); color: var(--text); }

.date-nav .current-date {
  font-family: var(--font-mono);
  font-weight: 600;
  min-width: 108px;
  text-align: center;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--absent); color: var(--absent); }
.toast.success { border-color: var(--present); color: var(--present); }

.skeleton-row td {
  color: transparent;
}
.skeleton-row .bar {
  height: 12px;
  border-radius: 4px;
  background: var(--surface-raised);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 10px; }
  .sidebar-brand { display: none; }
  .nav-section-label { display: none; }
  .sidebar-footer { display: none; }
  .main { padding: 16px; }
}
