:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.wrap-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.login-card { width: 100%; }

h1 { font-size: 1.4rem; margin: 0 0 4px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

label { display: block; font-size: 0.85rem; margin: 14px 0 6px; font-weight: 600; }

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.btn-primary { background: var(--primary); color: #fff; margin-top: 18px; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: #e5e7eb; color: var(--text); }

.btn-link {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.9rem;
  width: auto;
  padding: 6px;
  cursor: pointer;
}

.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 10px; min-height: 1em; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px 16px;
}
.topbar-name { font-weight: 700; font-size: 1.1rem; }
.topbar-sub { font-size: 0.85rem; }

.emp-nav { display: flex; gap: 18px; margin: 0 0 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.emp-nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.85rem; padding-bottom: 8px; border-bottom: 2px solid transparent; }
.emp-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }

.lang-toggle { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.lang-toggle a { color: var(--muted); text-decoration: none; padding: 2px 3px; }
.lang-toggle a.lang-active { color: var(--primary); }
.lang-toggle .lang-sep { color: var(--border); margin: 0 1px; }

.work-progress {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.85rem;
  text-align: center;
}
.work-progress.progress-cukup { background: #dcfce7; color: #166534; }
.work-progress.progress-kurang { background: #fef3c7; color: #92400e; }
.work-progress.progress-wfh { background: #dbeafe; color: #1e40af; }

.status-row { display: flex; gap: 12px; }
.status-box { flex: 1; text-align: center; padding: 10px; background: var(--bg); border-radius: 10px; }
.status-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.status-value { font-size: 1.3rem; font-weight: 700; margin-top: 4px; }

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 16px auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.notice {
  background: #fef3c7;
  color: #92400e;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}
.video-wrap video, .video-wrap canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror seperti kaca */
}

.hint { text-align: center; font-size: 0.85rem; margin-top: 10px; color: var(--muted); }
.hint-ok { color: var(--ok); font-weight: 600; }
.hint-bad { color: var(--danger); font-weight: 600; }

/* ---- Indikator kesiapan (wajah + GPS) sebelum tombol Ambil Foto aktif ----
   Dua badge terpisah supaya karyawan langsung tahu MANA yang belum oke
   (wajah atau lokasi), bukan cuma "gagal" tanpa tahu sebabnya. */
.readiness-row { display: flex; gap: 8px; margin-top: 10px; }
.readiness-chip {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  background: var(--bg); color: var(--muted);
}
.readiness-chip .readiness-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.readiness-chip.readiness-ok { background: #dcfce7; color: var(--ok); }
.readiness-chip.readiness-ok .readiness-dot { background: var(--ok); }
.readiness-chip.readiness-bad { background: #fee2e2; color: var(--danger); }
.readiness-chip.readiness-bad .readiness-dot { background: var(--danger); }
.readiness-summary { text-align: center; font-size: 0.85rem; font-weight: 700; color: var(--danger); margin-top: 10px; }

.preview-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  transform: scaleX(-1);
}

.button-row { display: flex; gap: 10px; margin-top: 12px; }
.button-row .btn { margin-top: 0; }

/* Foto referensi wajah di profil.php -- BUKAN preview kamera live, jadi
   sengaja tidak di-mirror (scaleX(-1)) seperti .preview-img. */
.profile-ref-photo {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.result-msg { text-align: center; margin-top: 12px; font-size: 0.9rem; min-height: 1.2em; }
.result-ok { color: var(--ok); font-weight: 600; }
.result-error { color: var(--danger); font-weight: 600; }

/* ---- Admin ---- */
.admin-wrap { max-width: 980px; margin: 0 auto; padding: 20px; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
table th, table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.9rem; }
table th { background: #f9fafb; font-size: 0.78rem; text-transform: uppercase; color: var(--muted); }
.admin-nav { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-nav a { color: var(--primary); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-late { background: #fef3c7; color: #92400e; }
.badge-missing { background: #fee2e2; color: #991b1b; }
.badge-wfh { background: #dbeafe; color: #1e40af; }
.badge-dayoff { background: #ede9fe; color: #5b21b6; }

@media (max-width: 640px) {
  .admin-wrap { padding: 12px; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
