/* ─── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --purple-400: #a78bfa;
  --purple-500: #8b5cf6;
  --purple-600: #7c3aed;
  --purple-700: #6d28d9;
  --purple-900: #2e1065;
  --green:  #34d399;
  --red:    #f87171;
  --yellow: #fbbf24;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg:          #0d0d14;
  --bg-elevated: #161622;
  --bg-card:     #1c1c2e;
  --bg-input:    #252538;
  --bg-hover:    #2a2a42;
  --border:      #2e2e4a;
  --text:        #e8e8f5;
  --text-muted:  #7878a0;
  --text-faint:  #4a4a6a;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

[data-theme="light"] {
  --bg:          #f3f2ff;
  --bg-elevated: #eeeeff;
  --bg-card:     #ffffff;
  --bg-input:    #f0eeff;
  --bg-hover:    #e8e6ff;
  --border:      #d8d4f5;
  --text:        #1a1a2e;
  --text-muted:  #6060888;
  --text-faint:  #aaaacc;
  --shadow:      0 4px 24px rgba(139,92,246,0.10);
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
input, select, textarea, button { font-family: inherit; }

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.logo-icon { width: 28px; height: 28px; stroke: var(--purple-500); }
.logo-text { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.3px; color: var(--text); }

.user-select {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 32px 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b5cf6' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 160px;
  transition: border-color var(--transition);
}
.user-select:focus { outline: none; border-color: var(--purple-500); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ─── Nav ────────────────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  gap: 2px;
  padding: 10px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition);
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn.active { background: var(--purple-600); color: #fff; }

/* ─── Content ────────────────────────────────────────────────────────────────── */
.content { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.view-header { margin-bottom: 20px; }
.view-header h2 { font-size: 1.25rem; font-weight: 600; }
.view-header p  { color: var(--text-muted); font-size: 0.875rem; margin-top: 2px; }

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

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--purple-600); color: #fff; }
.btn-primary:hover { background: var(--purple-700); }
.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg-hover); border-color: var(--purple-500); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: none; border: none; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-large { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-small { padding: 5px 12px; font-size: 0.8rem; }
.btn svg { width: 16px; height: 16px; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--purple-500); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ─── TODAY VIEW ─────────────────────────────────────────────────────────────── */
.today-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
}
@media (max-width: 700px) { .today-grid { grid-template-columns: 1fr; } }

.checkin-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 24px;
  text-align: center;
}

.not-checked-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 1rem;
}
.not-checked-in svg { stroke: var(--purple-500); opacity: 0.7; }

.session-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--green);
  background: rgba(52,211,153,0.12);
  padding: 3px 10px;
  border-radius: 20px;
}
.session-since { font-size: 0.9rem; color: var(--text-muted); }
.timer-display {
  font-size: 3.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--purple-400);
  letter-spacing: -1px;
  line-height: 1;
}
.break-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.break-input {
  width: 64px;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.break-input:focus { outline: none; border-color: var(--purple-500); }
.notes-input {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.notes-input:focus { outline: none; border-color: var(--purple-500); }

.completed-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.check-icon { font-size: 2.5rem; }
.completed-label { font-size: 0.9rem; color: var(--text-muted); }
.completed-time { font-size: 1.1rem; font-weight: 600; }
.completed-hours { font-size: 0.85rem; color: var(--text-muted); }

.special-entry-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.special-entry-icon { font-size: 2.5rem; }
.special-entry-label { font-size: 1rem; font-weight: 600; }
.special-entry-hours { font-size: 0.875rem; color: var(--text-muted); }

.special-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* Stats card */
.stats-card { display: flex; flex-direction: column; gap: 4px; }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.stat-label { font-size: 0.875rem; color: var(--text-muted); }
.stat-value { font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--text-muted); }
.divider  { height: 1px; background: var(--border); margin: 4px 0; }

/* ─── WEEK VIEW ──────────────────────────────────────────────────────────────── */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.week-nav h2 { font-size: 1.1rem; font-weight: 600; }
.week-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.week-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.week-summary-card .label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.week-summary-card .value { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.week-table-wrap { overflow-x: auto; }
.week-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.week-table th {
  background: var(--bg-elevated);
  padding: 10px 12px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.week-table th.col-day { text-align: left; width: 90px; }
.week-table td {
  padding: 10px 12px;
  text-align: center;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.week-table td.col-day {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.week-table td.col-day .day-name { display: block; font-size: 0.95rem; color: var(--text); }
.week-table td.col-day .day-date { font-size: 0.75rem; }
.week-table tr:last-child td { border-bottom: none; }
.week-table tr.today-row td { background: rgba(139,92,246,0.06); }
.week-table tr.weekend-row td { background: rgba(0,0,0,0.03); }
[data-theme="dark"] .week-table tr.weekend-row td { background: rgba(255,255,255,0.02); }

.time-chip {
  display: inline-block;
  background: var(--bg-input);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.balance-chip {
  display: inline-block;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.balance-chip.pos { background: rgba(52,211,153,0.12); color: var(--green); }
.balance-chip.neg { background: rgba(248,113,113,0.12); color: var(--red); }
.balance-chip.zero { background: var(--bg-input); color: var(--text-muted); }

.entry-type-tag {
  display: inline-block;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 500;
}
.tag-full_day { background: rgba(139,92,246,0.15); color: var(--purple-400); }
.tag-vacation { background: rgba(251,191,36,0.15); color: var(--yellow); }
.tag-sick     { background: rgba(248,113,113,0.15); color: var(--red); }
.tag-holiday  { background: rgba(52,211,153,0.15); color: var(--green); }
.tag-active   { background: rgba(139,92,246,0.15); color: var(--purple-400); }

.day-action-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-faint);
  border-radius: 5px;
  padding: 2px 10px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: all var(--transition);
}
.day-action-btn:hover { border-color: var(--purple-500); color: var(--purple-400); background: rgba(139,92,246,0.06); }

/* ─── MONTH VIEW ─────────────────────────────────────────────────────────────── */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.month-nav h2 { font-size: 1.1rem; font-weight: 600; }
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.month-weekday {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 2px;
}
.month-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-height: 64px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.month-day:hover { border-color: var(--purple-500); background: var(--bg-hover); }
.month-day.empty { background: none; border-color: transparent; cursor: default; }
.month-day.today { border-color: var(--purple-500); }
.month-day.weekend .day-num { color: var(--text-faint); }
.month-day .day-num { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.month-day.today .day-num { color: var(--purple-400); }
.month-day .day-content { margin-top: 4px; }
.month-day .day-hours { font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.month-day.worked { border-color: rgba(52,211,153,0.4); }
.month-day.partial { border-color: rgba(251,191,36,0.4); }
.month-day.missing { border-color: rgba(248,113,113,0.2); }
.month-dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block; margin-right: 2px;
}
.dot-green  { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red    { background: var(--red); }
.dot-purple { background: var(--purple-500); }

/* ─── STATS VIEW ─────────────────────────────────────────────────────────────── */
.stats-hero {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.hero-card .hero-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.hero-card .hero-value { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .stats-hero { grid-template-columns: 1fr; } .week-summary { grid-template-columns: 1fr; } }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.stats-table th {
  background: var(--bg-elevated);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.stats-table td {
  padding: 9px 14px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.stats-table tr:last-child td { border-bottom: none; }
.stats-table tr:hover td { background: var(--bg-hover); }

/* ─── SETTINGS ───────────────────────────────────────────────────────────────── */
.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.user-item-info { flex: 1; }
.user-item-name { font-weight: 600; font-size: 0.95rem; }
.user-item-hours { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.user-item-actions { display: flex; gap: 6px; }

.add-user-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 0.875rem;
  z-index: 300;
  transition: transform 0.3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }

/* ─── Login Screen ───────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 16px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.login-logo svg {
  width: 32px;
  height: 32px;
  stroke: var(--purple-500);
}
.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: -12px;
}
.btn-login {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 0.95rem;
}
.login-error {
  font-size: 0.85rem;
  color: var(--red);
  min-height: 16px;
  margin-top: -8px;
}
.login-theme-row {
  display: flex;
  justify-content: center;
  margin-top: -8px;
}

/* User badge in header */
.user-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-input);
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.user-badge.admin { border-color: var(--purple-500); color: var(--purple-400); }

/* ─── Misc ───────────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 0.95rem;
}
.loading { text-align: center; color: var(--text-muted); padding: 40px; }
.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
