@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --bg: #F7F9FC;
  --bg-glow: #EAF1FE;
  --surface: #FFFFFF;
  --surface-2: #F3F5F9;
  --border: #E3E7EE;
  --text: #1F2937;
  --text-muted: #6B7280;
  --accent: #2563EB;
  --accent-rgb: 37, 99, 235;
  --accent-dim: #E3ECFD;
  --amber: #D97706;
  --red: #DC2626;
  --red-rgb: 220, 38, 38;
  --radius: 14px;
  --font-display: 'Poppins', sans-serif;
  --font-body: 'Poppins', sans-serif;
  --font-mono: 'Poppins', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(600px 380px at 50% -8%, var(--bg-glow), transparent 70%),
    var(--bg);
}

a { color: inherit; }

header.topbar {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

main.with-tabbar {
  padding-bottom: 100px;
}

nav.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(20, 28, 46, 0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 480px) {
  nav.tabbar { left: 50%; transform: translateX(-50%); }
}

nav.tabbar a {
  flex: 1;
  text-align: center;
  padding: 11px 4px 9px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  border-top: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

nav.tabbar a svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

nav.tabbar a.active {
  color: var(--accent);
  border-top-color: var(--accent);
}

/* --- Hero / greeting --- */

.hero {
  text-align: center;
  margin-bottom: 22px;
}

.hero .greeting {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero .clock-big {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.hero .date-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

h1.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
}

p.page-sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 20px;
  line-height: 1.5;
  text-align: center;
}

/* --- Scan frame: bingkai kamera ringkas (bukan full layar), cukup lega utk beberapa wajah --- */

.scan-orb {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 16 / 10;
  margin: 0 auto;
  border-radius: 22px;
  overflow: hidden;
  background: #000;
  border: 2px solid var(--border);
  transition: border-color .25s ease, box-shadow .25s ease;
}

.scan-orb.searching {
  animation: framePulse 2.4s ease-in-out infinite;
}

.scan-orb.locked {
  border-color: var(--accent);
  box-shadow: 0 0 26px 2px var(--accent-dim);
  animation: none;
}

.scan-orb.error {
  border-color: var(--red);
  box-shadow: 0 0 26px 2px #3A1A1A;
  animation: none;
}

@keyframes framePulse {
  0%, 100% { border-color: var(--border); }
  50% { border-color: var(--accent-dim); }
}

.scan-orb-inner {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
}

.scan-orb-inner video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.status-pill {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  min-height: 18px;
  text-align: center;
}

.status-pill .ring {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background .2s ease, box-shadow .2s ease;
}
.status-pill.ok .ring { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.status-pill.err .ring { background: var(--red); box-shadow: 0 0 0 3px #3A1A1A; }
.status-pill.busy .ring { background: var(--amber); box-shadow: 0 0 0 3px #3D2E10; }

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.field input {
  width: 100%;
  padding: 12px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
}

button.primary {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  margin-top: 6px;
  transition: background .15s ease, transform .1s ease, opacity .15s ease;
}
button.primary:hover:not(:disabled) { background: #1D4ED8; }
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }

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

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.list-row:last-child { border-bottom: none; }

.list-row .who { display: flex; flex-direction: column; gap: 2px; }
.list-row .who .name { font-size: 14.5px; font-weight: 500; }
.list-row .who .nip { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge.in { background: var(--accent-dim); color: var(--accent); }
.badge.out { background: #3D2E10; color: var(--amber); }

.timestamp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 4px 6px;
}
.delete-btn:hover { color: var(--red); }

.empty-state {
  text-align: center;
  padding: 40px 10px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.loading-veil {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(600px 380px at 50% -8%, var(--bg-glow), transparent 70%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  z-index: 50;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.filter-row input {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* --- Toast notifikasi hasil scan --- */

.scan-toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%) translateY(16px);
  width: calc(100% - 36px);
  max-width: 440px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 60;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}

.scan-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.scan-toast.error { border-color: var(--red); }

.scan-toast-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.scan-toast.error .scan-toast-icon {
  background: #3A1A1A;
  color: var(--red);
}

.scan-toast-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}

.scan-toast-sub {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Notifikasi wajah duplikat (otomatis, harus jelas & menonjol) --- */

.scan-toast.duplicate {
  border-width: 2px;
  border-color: var(--red);
  animation: toastPulse 1.5s ease-in-out infinite;
}

.scan-toast.duplicate .scan-toast-name {
  font-size: 16px;
}

@keyframes toastPulse {
  0%, 100% { box-shadow: 0 12px 32px rgba(0,0,0,0.45), 0 0 0 0 rgba(var(--red-rgb), 0.45); }
  50% { box-shadow: 0 12px 32px rgba(0,0,0,0.45), 0 0 0 9px rgba(var(--red-rgb), 0); }
}

/* --- Notifikasi sukses (harus jelas juga) --- */

.scan-toast.success-pulse {
  border-width: 2px;
  animation: toastPulseSuccess 1.1s ease-in-out 2;
}

.scan-toast.success-pulse .scan-toast-name {
  font-size: 16px;
}

@keyframes toastPulseSuccess {
  0%, 100% { box-shadow: 0 12px 32px rgba(0,0,0,0.45), 0 0 0 0 rgba(var(--accent-rgb), 0.5); }
  50% { box-shadow: 0 12px 32px rgba(0,0,0,0.45), 0 0 0 10px rgba(var(--accent-rgb), 0); }
}
