/* =================== VARIABLES =================== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

/* =================== RESET & BASE =================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* =================== LAYOUT =================== */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =================== HEADER =================== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.header-right {
  text-align: right;
}

.live-clock {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.live-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* =================== LOGO =================== */
.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}
.logo-icon.large {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  font-size: 1.75rem;
  margin: 0 auto 1rem;
}

.header-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  display: block;
}

.login-logo {
  height: 80px;
  width: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.5rem;
}

.sidebar-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* =================== MAIN CONTENT =================== */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* =================== PANELS =================== */
.panel { display: none; }
.panel.active { display: block; }

.panel-title {
  text-align: center;
  margin-bottom: 2rem;
}
.panel-title h2 { font-size: 1.5rem; margin-bottom: 0.25rem; }

/* =================== EMPLOYEE GRID =================== */
.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.employee-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}
.employee-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.employee-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.employee-card-dept {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* =================== PIN PANEL =================== */
.pin-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  max-width: 340px;
  margin: 0 auto;
  text-align: center;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: all var(--transition);
}
.dot.filled {
  background: var(--primary);
  border-color: var(--primary);
}
.dot.error {
  background: var(--danger);
  border-color: var(--danger);
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.num-btn {
  aspect-ratio: 1;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  transition: all var(--transition);
  padding: 0.75rem;
}
.num-btn:hover { background: var(--primary-light); color: var(--primary); }
.num-btn:active { transform: scale(0.93); }

.num-clear { background: #fef2f2; color: var(--danger); }
.num-clear:hover { background: var(--danger-light); }

.num-ok { background: var(--primary); color: white; }
.num-ok:hover { background: var(--primary-dark); }

/* =================== STATUS PANEL =================== */
.employee-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.employee-avatar-lg {
  width: 64px;
  height: 64px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  flex-shrink: 0;
}

.status-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.time-row:last-child { border-bottom: none; }
.time-row .label { color: var(--text-muted); font-size: 0.9rem; }
.time-row .value { font-weight: 600; font-size: 1rem; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.badge-absent { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-in { background: var(--success-light); color: var(--success); }
.badge-done { background: var(--primary-light); color: var(--primary); }

.punch-area { text-align: center; }

.btn-punch {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  border: none;
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}
.btn-punch:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-punch:active { transform: translateY(0); }
.btn-punch.punch-out { background: var(--danger); }
.btn-punch.punch-out:hover { background: #b91c1c; }
.btn-punch.punch-done { background: var(--text-muted); cursor: default; }
.btn-punch.punch-done:hover { transform: none; }

.punch-icon { font-size: 1.25rem; }

.message-box {
  margin-top: 1.5rem;
  background: var(--success-light);
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideIn 0.3s ease;
}
.message-box.msg-error { background: var(--danger-light); border-color: #fca5a5; }
.message-box.msg-info { background: var(--primary-light); border-color: #93c5fd; }
.message-icon { font-size: 1.25rem; flex-shrink: 0; }

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

/* =================== FOOTER =================== */
.app-footer {
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* =================== SHARED COMPONENTS =================== */
.subtitle { color: var(--text-muted); font-size: 0.9rem; }

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary.full-width { width: 100%; padding: 0.75rem; font-size: 1rem; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { background: var(--border); }
.btn-secondary.sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  transition: color var(--transition);
}
.btn-link:hover { color: var(--primary-dark); text-decoration: underline; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  transition: background var(--transition);
  font-size: 1rem;
}
.btn-icon:hover { background: var(--bg); }
.btn-icon.danger:hover { background: var(--danger-light); color: var(--danger); }

.error-msg { color: var(--danger); font-size: 0.875rem; margin: 0.5rem 0; min-height: 1.2rem; }
.success-msg { color: var(--success); font-size: 0.875rem; margin: 0.5rem 0; }

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
  outline: none;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

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

/* Loading */
.loading-spinner {
  grid-column: 1/-1;
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =================== ADMIN LAYOUT =================== */
.admin-body { background: var(--bg); }

.admin-layout { display: block; }

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }

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

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

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition);
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 1.25rem; text-align: center; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.sidebar-link { display: block; padding: 0.4rem 0; text-align: left; }

/* =================== ADMIN MAIN =================== */
.admin-main {
  margin-left: 220px;
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; }
.date-label { font-size: 0.9rem; color: var(--text-muted); }

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

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
}
.stat-card.stat-green { border-left-color: var(--success); }
.stat-card.stat-blue { border-left-color: var(--primary); }
.stat-card.stat-orange { border-left-color: var(--warning); }

.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 0.35rem; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* =================== CARD =================== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1rem; }

/* =================== TABLE =================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }

.empty-row { text-align: center; color: var(--text-muted); padding: 2rem !important; }
.empty-state { text-align: center; color: var(--text-muted); padding: 3rem; }

/* =================== BADGES =================== */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* =================== FILTER BAR =================== */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 120px; }
.filter-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.filter-group select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.filter-group select:focus { border-color: var(--primary); }

/* =================== REPORT =================== */
.report-employee {
  margin-bottom: 1.5rem;
}

.report-emp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid var(--primary);
  box-shadow: var(--shadow);
}

.report-emp-name { font-size: 1rem; font-weight: 700; }
.report-emp-dept { font-size: 0.8rem; color: var(--text-muted); }

.report-summary {
  display: flex;
  gap: 2rem;
}
.report-summary-item { text-align: center; }
.report-summary-val { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.report-summary-lbl { font-size: 0.75rem; color: var(--text-muted); }

/* =================== MODAL =================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--text-muted); padding: 0.25rem;
  border-radius: 4px; transition: all var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

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

@media (max-width: 700px) {
  .sidebar { transform: translateX(-100%); }
  .admin-main { margin-left: 0; padding: 1rem; }
  .main-content { padding: 1rem; }
  .app-header { padding: 0 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .employee-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 0.6rem 0.7rem; }
}
