/* ============================================================
   AttendanceIQ — Global Styles
   Aesthetic: Industrial precision meets modern clarity
   Font: DM Sans (body) + Syne (display)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── Design tokens ────────────────────────────────────────── */
:root {
  --blue:        #2563EB;
  --blue-dark:   #1D4ED8;
  --blue-light:  #EFF6FF;
  --green:       #16A34A;
  --green-light: #F0FDF4;
  --red:         #DC2626;
  --red-light:   #FEF2F2;
  --amber:       #D97706;
  --amber-light: #FFFBEB;

  --bg:          #F1F5F9;
  --surface:     #FFFFFF;
  --surface-2:   #F8FAFC;
  --border:      #E2E8F0;
  --border-2:    #CBD5E1;

  --text:        #0F172A;
  --text-2:      #475569;
  --text-3:      #94A3B8;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:      0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);

  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   16px;

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: inherit; }

/* ── Navbar ──────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.navbar-logo span { color: var(--blue); }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-user {
  font-size: 0.875rem;
  color: var(--text-2);
  font-weight: 500;
}

/* ── Layout ──────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 12px;
  flex-shrink: 0;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

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

.nav-item.active {
  background: var(--blue-light);
  color: var(--blue);
}

.nav-item svg { flex-shrink: 0; opacity: 0.8; }

/* ── Main content ────────────────────────────────────────── */
.main {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.page-header p {
  font-size: 0.9rem;
  color: var(--text-2);
  margin-top: 4px;
}

/* ── Tab content ─────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Stat cards ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.stat-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 8px;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-card.blue .stat-card-value  { color: var(--blue); }
.stat-card.green .stat-card-value { color: var(--green); }
.stat-card.red .stat-card-value   { color: var(--red); }
.stat-card.amber .stat-card-value { color: var(--amber); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-body { padding: 0; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  white-space: nowrap;
}

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

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

tbody td {
  padding: 13px 20px;
  color: var(--text);
  vertical-align: middle;
  display: table-cell;
  align-items: center;
  gap: 10px;
}

/* ── Employee badge ──────────────────────────────────────── */
.employee-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 10px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* ── Status pills ────────────────────────────────────────── */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-in    { background: var(--green-light); color: var(--green); }
.status-out   { background: var(--bg);          color: var(--text-3); }
.status-late  { background: #fef3c7;            color: #d97706; }
.status-absent{ background: #fee2e2;            color: #dc2626; }
.status-leave { background: #ede9fe;            color: #7c3aed; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-dark); box-shadow: var(--shadow); }

.btn-outline {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-outline:hover { background: var(--bg); color: var(--text); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger-outline {
  background: transparent;
  color: var(--red);
  border: 1px solid #FECACA;
}
.btn-danger-outline:hover { background: var(--red-light); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  transition: all 0.15s;
}

.btn-icon.btn-danger:hover {
  background: var(--red-light);
  color: var(--red);
  border-color: #FECACA;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Filters row ─────────────────────────────────────────── */
.filters-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: flex-end;
}

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

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group input,
.filter-group select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}

.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 440px;
  max-width: 95vw;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Form elements ───────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 4px;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 40px 20px !important;
  font-size: 0.875rem;
}

.empty-state.loading::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  background: var(--text-3);
  border-radius: 50%;
  margin-left: 4px;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1; }
}

/* ── Toast notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  max-width: 320px;
}

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

.toast-success {
  background: #fff;
  border-left: 3px solid var(--green);
  color: var(--text);
}

.toast-error {
  background: #fff;
  border-left: 3px solid var(--red);
  color: var(--text);
}

.toast-icon {
  font-size: 0.8rem;
  font-weight: 700;
}

.toast-success .toast-icon { color: var(--green); }
.toast-error .toast-icon   { color: var(--red); }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -200px;
  left: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(37,99,235,0.07) 0%, transparent 70%);
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -200px;
  right: -200px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(22,163,74,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 8px;
}

.login-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--blue);
  border-radius: 14px;
  margin-bottom: 16px;
}

.login-logo-icon svg { color: #fff; }

.login-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.04em;
  margin-bottom: 4px;
}

.login-title span { color: var(--blue); }

.login-subtitle {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-3);
  margin-bottom: 32px;
}

.login-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-3);
  margin-top: 20px;
}

/* ── Employee page ───────────────────────────────────────── */
.employee-page-body {
  background: var(--bg);
  min-height: 100vh;
}

.employee-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 24px;
}

.clock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.employee-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.employee-name-display {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.live-date {
  font-size: 0.85rem;
  color: var(--text-3);
  margin-bottom: 20px;
}

.live-clock {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 28px;
  font-variant-numeric: tabular-nums;
}

.clock-btn {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: none;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  box-shadow: 0 8px 24px -4px rgba(0,0,0,0.2);
}

.clock-btn:hover { transform: scale(1.04); }
.clock-btn:active { transform: scale(0.97); }
.clock-btn:disabled { opacity: 0.6; transform: none; cursor: not-allowed; }

.clock-in  { background: linear-gradient(135deg, #16A34A, #15803D); box-shadow: 0 8px 24px -4px rgba(22,163,74,0.4); }
.clock-out { background: linear-gradient(135deg, #DC2626, #B91C1C); box-shadow: 0 8px 24px -4px rgba(220,38,38,0.4); }

.clock-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  margin-top: 20px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.2);
  animation: dotPulse 2s infinite;
}

.status-dot.inactive { background: var(--text-3); }

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(22,163,74,0.2); }
  50%       { box-shadow: 0 0 0 6px rgba(22,163,74,0.08); }
}

.clock-in-display {
  font-size: 0.875rem;
  color: var(--green);
  font-weight: 600;
  margin-top: 10px;
}

/* ── Daily status buttons ────────────────────────────────────── */
.status-choice-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.status-choice-btn:hover { background: var(--bg); }
.status-choice-btn.active {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue);
}

/* ── Responsive ──────────────────────────────────────────── */
/* ── Schedule view toggle ────────────────────────────────────── */
.schedule-view-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 0;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.schedule-view-btn:hover { background: var(--bg); }
.schedule-view-btn.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }

/* ── Calendar grid ───────────────────────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-day-header {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 4px 0;
}
.calendar-day {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-height: 56px;
  font-size: 0.78rem;
}
.calendar-day.empty { border-color: transparent; background: transparent; min-height: 0; }
.calendar-day.today { border-color: var(--blue); }
.calendar-day-num { font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.calendar-day.wfh { background: var(--green-light); }
.calendar-day.onsite { background: var(--surface-2); }
.calendar-day.has-override { background: var(--blue-light); }
.calendar-day-badge { font-size: 0.68rem; font-weight: 600; color: var(--text-2); }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 32px 24px; }
  .filters-row { gap: 8px; }
  .filter-group { width: 100%; }
  .filter-group input,
  .filter-group select { width: 100%; }
  .navbar { padding: 0 16px; }
  .clock-btn { width: 160px; height: 160px; font-size: 1.1rem; }
  .live-clock { font-size: 2.5rem; }
}
