/* ── Palette ─────────────────────────────────────────────────────────────── */
:root {
  --bg:         #1e2847;
  --surface:    #303C6C;
  --surface2:   #3a4a80;
  --border:     rgba(180,223,229,0.22);
  --accent:     #F4976C;
  --accent-dim: rgba(244,151,108,0.15);
  --yellow:     #FBE8A6;
  --yellow-dim: rgba(251,232,166,0.15);
  --light:      #B4DFE5;
  --lightest:   #D2FDFF;
  --muted:      rgba(212,253,255,0.5);
  --teal:       #2ECFCE;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: 'Outfit', sans-serif; background: var(--bg); color: var(--lightest);
       display: flex; flex-direction: column; transition: background 0.3s; }

/* ── Face-light: glowing orbs beside camera ── */
.face-light-orb {
  display: none; position: absolute; top: 50%; transform: translateY(-50%);
  pointer-events: none; z-index: 0;
  width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle,
    #ffffff 0%, #ffffff 15%, #ffffffe6 25%, #ffffffbb 40%,
    #ffffff77 55%, #ffffff33 70%, transparent 85%);
  box-shadow: 0 0 80px 40px rgba(255,255,255,0.5), 0 0 160px 80px rgba(255,255,255,0.25);
}
.face-light-orb.left  { left: 0; transform: translate(-50%, -50%); }
.face-light-orb.right { right: 0; transform: translate(50%, -50%); }
body.face-light .face-light-orb { display: block; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; z-index: 10;
}
.logo-area { display: flex; align-items: center; gap: 10px; }
.logo-img  { height: 34px; width: auto; }
.logo-text {
  font-family: 'Rajdhani', 'Syne', sans-serif;
  font-size: 1.55rem; font-weight: 700;
  letter-spacing: 5px; color: var(--teal);
  text-transform: uppercase; line-height: 1;
}
.logo-text .tilde { color: rgba(46,207,206,0.55); letter-spacing: 4px; }
.logo-sub {
  font-size: 0.58rem; color: #ffffff;
  letter-spacing: 2.5px; text-transform: uppercase;
  margin-top: 4px; line-height: 1;
}
.header-link {
  color: var(--muted); text-decoration: none; font-size: 0.8rem;
  border: 1px solid var(--border); padding: 6px 14px; border-radius: 8px;
  transition: all 0.2s; cursor: pointer; background: none;
  font-family: 'Outfit', sans-serif;
}
.header-link:hover { border-color: var(--accent); color: var(--lightest); }

/* ── Flip-clock time bar ─────────────────────────────────────────────────── */
.time-bar {
  background: linear-gradient(to bottom, var(--surface), var(--bg));
  border-bottom: 1px solid var(--border);
  padding: 8px 20px 10px;
  display: flex; align-items: stretch; justify-content: center;
  gap: 14px; flex-shrink: 0;
}
.flip-clock { display: flex; align-items: center; gap: 4px; }
.flip-tile {
  border-radius: 8px; text-align: center; position: relative;
  padding: 8px 14px 7px; min-width: 64px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.flip-tile.t-hrs  { background: #E85455; }
.flip-tile.t-min  { background: #44C67A; }
.flip-tile.t-sec  { background: #F5A623; }
.flip-tile .tile-num {
  font-family: 'Rajdhani', 'Syne', sans-serif;
  font-size: 2rem; font-weight: 700; color: #fff; line-height: 1;
  display: block; position: relative;
}
.flip-tile .tile-num::after {
  content: ''; position: absolute;
  left: -10px; right: -10px; top: 50%;
  height: 2px; background: rgba(0,0,0,0.18); pointer-events: none;
}
.flip-tile .tile-label {
  font-size: 0.48rem; letter-spacing: 2px;
  color: rgba(255,255,255,0.75); margin-top: 3px; text-transform: uppercase;
}
/* #16 AM/PM tile */
.flip-tile.t-ampm { background: var(--surface2); border: 1px solid var(--border); min-width: 38px; }
.flip-tile.t-ampm .tile-num { font-size: 1.1rem; color: var(--yellow); }
.flip-sep {
  font-family: 'Rajdhani', sans-serif; font-size: 1.5rem; font-weight: 700;
  color: var(--muted); margin-bottom: 14px; line-height: 1;
}
.date-tile {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px 7px; text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  /* Match exact height of .flip-tile: padding 8px+7px + tile-num 2rem line-height + tile-label ~0.48rem+3px */
  min-height: 0;
  align-self: stretch;
}
.date-tile .tile-num {
  font-family: 'Rajdhani', 'Syne', sans-serif;
  font-size: 1.15rem; font-weight: 700; color: var(--yellow);
  letter-spacing: 2px; line-height: 1.25;
}
@keyframes tileFlip {
  0%   { transform: translateY(-30%) scaleY(0.7); opacity: 0; }
  60%  { transform: translateY(4%)   scaleY(1.05); opacity: 1; }
  100% { transform: translateY(0)    scaleY(1); opacity: 1; }
}
.flip-tile.flipping .tile-num { animation: tileFlip 0.22s ease; }

/* ── Layout: message center above camera, fixed heights ─────────────────── */
/* #5 / #12 fixed message center (compact) + fixed camera */
.msg-center {
  flex-shrink: 0;
  height: 62px; /* fixed compact height — #12 */
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
  overflow: hidden;
}
.msg-inner {
  width: 100%; max-width: min(75vw, 380px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; max-height: 50px;
  overflow: hidden;
}

/* ── Camera ─────────────────────────────────────────────────────────────── */
.camera-section {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 4px 16px 0; min-height: 0; position: relative;
}
.camera-wrap {
  position: relative; background: #0e1730;
  border-radius: 16px; overflow: hidden;
  aspect-ratio: 3/4;
  width: auto; height: 100%; max-height: 100%;
  max-width: min(75vw, 380px);
  border: 2px solid var(--border); transition: border-color 0.3s, box-shadow 0.3s;
}
.camera-wrap.face-found { border-color: var(--accent); box-shadow: 0 0 24px rgba(244,151,108,0.3); }
.camera-wrap.confirmed  { border-color: var(--yellow);  box-shadow: 0 0 28px rgba(251,232,166,0.4); }
#video   { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); pointer-events: none; }

/* Dim camera after match found */
.camera-wrap.dimmed #video { filter: brightness(0.25); transition: filter 0.5s ease; }
.camera-wrap.dimmed #overlay { opacity: 0.3; transition: opacity 0.5s ease; }
.camera-wrap.dimmed .scan-hint { display: none; }

/* "Look directly at the camera" — stays inside camera frame at top */
.scan-hint {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(30,40,71,0.82); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 14px; font-size: 0.8rem; color: var(--muted);
  white-space: nowrap; pointer-events: none; z-index: 6;
}
.scan-hint.active { color: var(--yellow); border-color: rgba(251,232,166,0.3); }

/* #13 Match % overlay inside camera — 30% bigger, white */
#recognizedNameOverlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(30,40,71,0.93));
  padding: 32px 16px 14px;
  display: none; flex-direction: column; align-items: center;
  pointer-events: none;
}
#recognizedNameOverlay.show { display: flex; }
.recognized-name {
  font-family: 'Rajdhani', 'Syne', sans-serif;
  font-size: 2.6rem; font-weight: 700; letter-spacing: 3px;
  color: var(--yellow); text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(0,0,0,0.9); text-align: center;
  animation: namePop 0.3s ease;
}
@keyframes namePop { from{transform:scale(0.85);opacity:0} to{transform:scale(1);opacity:1} }
/* #13 — match % in camera: 30% bigger than before (was 0.82rem → 1.07rem), white */
.recognized-match {
  font-size: 1.07rem; color: #ffffff; margin-top: 4px;
  font-weight: 700; letter-spacing: 1px;
}

#loadingOverlay {
  position: absolute; inset: 0; background: rgba(30,40,71,0.94);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; border-radius: 14px;
}
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent);
           border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 0.88rem; color: var(--muted); }

/* ── Bottom panel ────────────────────────────────────────────────────────── */
.bottom-panel {
  flex-shrink: 0; padding: 6px 14px 12px;
  max-width: min(75vw, 380px); width: 100%; margin: 0 auto;
}

/* #21 Clock-in/out colored background labels (no round icon) */
#staffPanel {
  display: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; animation: slideUp 0.3s ease;
}
@keyframes slideUp { from{transform:translateY(20px);opacity:0} to{transform:translateY(0);opacity:1} }
#staffPanel.show { display: block; }
.staff-info {
  padding: 10px 14px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.staff-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-dim); border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Rajdhani', sans-serif; font-size: 1.1rem; font-weight: 700;
  color: var(--yellow); flex-shrink: 0; overflow: hidden;
}
.staff-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.staff-meta { flex: 1; min-width: 0; }
.staff-name-display { font-family: 'Rajdhani', sans-serif; font-size: 1rem; font-weight: 700;
                      color: var(--lightest); letter-spacing: 1px; }
.staff-current-status { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
/* #13 confidence badge in panel */
.confidence-badge {
  font-size: 0.72rem; color: #ffffff; background: rgba(46,207,206,0.25);
  padding: 3px 9px; border-radius: 20px; border: 1px solid var(--teal);
  font-weight: 700; white-space: nowrap;
}
.action-area { padding: 8px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
/* Action buttons: solid colored bg, text only */
.action-btn {
  padding: 10px 6px;
  border: none; border-radius: 10px;
  font-family: 'Outfit', sans-serif; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  letter-spacing: 0.5px; gap: 2px;
}
.btn-clock-in    { background: #2ecc71; color: #fff; }
.btn-break-start { background: #f1c40f; color: #1e2847; }
.btn-break-end   { background: #e67e22; color: #fff; }
.btn-clock-out   { background: #e74c3c; color: #fff; }
.action-btn:hover    { filter: brightness(1.1); transform: translateY(-1px); }
.action-btn:active   { transform: scale(0.96); }
.action-btn:disabled { cursor: not-allowed; transform: none; }
/* Completed action: dimmed with checkmark + time */
.action-btn.action-done { opacity: 0.45; }
/* Locked action: greyed out, not yet available */
.action-btn.action-locked { background: #2a3555 !important; color: #555 !important; opacity: 0.5; }
.action-btn.action-done .action-time {
  font-size: 0.65rem; font-weight: 500; opacity: 0.9;
}
/* Throb only for available (not done) buttons */
@keyframes throb {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244,151,108,0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 20px 8px rgba(244,151,108,0.5); }
}
.action-btn:not(.action-done) { animation: throb 1.2s ease-in-out infinite; }
.action-btn:not(.action-done):hover { animation: none; }

/* Auto-dismiss timer bar */
.action-timer {
  padding: 4px 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.action-timer.hidden { display: none; }
.timer-bar-wrap {
  width: 100%; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.timer-bar-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width linear;
}
.timer-text { font-size: 0.7rem; color: var(--muted); }

.done-message { padding: 12px; text-align: center; color: var(--muted); font-size: 0.85rem; }
.done-message .icon { font-size: 1.3rem; margin-bottom: 3px; }

#toast {
  position: fixed; top: 80px; left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--accent); color: #1e2847;
  padding: 10px 22px; border-radius: 20px;
  font-weight: 600; font-size: 0.9rem;
  opacity: 0; transition: all 0.3s ease;
  z-index: 9998; pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* ── Message center state items ─────────────────────────────────────────── */
/* #2/#4/#5: All messages live in the msg-center above camera */
.msg-state {
  display: none; align-items: center; justify-content: center;
  gap: 8px; width: 100%; text-align: center;
}
.msg-state.show { display: flex; }
.scan-wave { display: inline-flex; gap: 3px; }
.scan-wave span {
  display: block; width: 3px; height: 12px; background: var(--accent);
  border-radius: 2px; animation: wave 1.2s ease-in-out infinite;
}
.scan-wave span:nth-child(2) { animation-delay: 0.15s; }
.scan-wave span:nth-child(3) { animation-delay: 0.3s; }
@keyframes wave { 0%,100%{transform:scaleY(0.5);opacity:0.4} 50%{transform:scaleY(1);opacity:1} }
.msg-idle-text { font-size: 0.92rem; color: #ffffff; font-weight: 500; letter-spacing: 0.4px; }
.msg-unknown-text { font-size: 0.82rem; color: var(--accent); }
/* #13 match % in message center */
.msg-match-pct { font-size: 0.82rem; color: var(--teal); font-weight: 700; }

/* ── Standby Page ────────────────────────────────────────────────────────── */
.standby-overlay {
  position: fixed; inset: 0; background: var(--bg);
  z-index: 400; display: flex; flex-direction: column;
  align-items: center; padding: 0;
  animation: sdFadeIn 0.5s ease;
}
.standby-overlay.hidden { display: none; }
@keyframes sdFadeIn { from{opacity:0} to{opacity:1} }

/* #1 standby header — same as main header (logo + app name) */
.standby-header {
  width: 100%; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}

.standby-top {
  width: 100%; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: stretch; justify-content: center; gap: 14px;
  flex-shrink: 0;
}
/* Large flip tiles for standby */
.flip-tile.large { padding: 16px 24px 12px; min-width: 110px; border-radius: 12px; }
.flip-tile.large .tile-num { font-size: 3.6rem; }
.flip-tile.large .tile-num::after { left: -24px; right: -24px; }
.flip-tile.large .tile-label { font-size: 0.58rem; margin-top: 6px; }
.flip-sep.large { font-size: 3.6rem; margin-bottom: 28px; }
.date-tile.large {
  padding: 16px 20px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  align-self: stretch; min-height: 0;
}
.date-tile.large .tile-num { font-size: 1.35rem; }

.standby-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0; padding: 18px 20px; text-align: center;
}
.standby-action-icon { font-size: 3rem; margin-bottom: 10px; animation: popIn 0.4s ease; }
@keyframes popIn { from{transform:scale(0);opacity:0} 60%{transform:scale(1.15)} to{transform:scale(1);opacity:1} }

.standby-label {
  font-size: 0.78rem; letter-spacing: 3px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.standby-avatar-wrap {
  width: 80px; height: 80px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--accent); margin: 6px 0 10px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Rajdhani', sans-serif; font-size: 2.2rem; font-weight: 700;
  color: var(--yellow);
}
.standby-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
.standby-name {
  font-family: 'Rajdhani', 'Syne', sans-serif;
  font-size: 2.2rem; font-weight: 700; letter-spacing: 4px;
  color: var(--yellow); text-transform: uppercase; line-height: 1;
}
/* #21 standby action-text with colored bg */
.standby-action-label {
  margin-top: 8px; padding: 5px 18px; border-radius: 8px;
  font-size: 0.95rem; font-weight: 700; letter-spacing: 1px;
  display: inline-block;
}
.standby-action-label.clock-in    { background: #2ecc71; color: #fff; }
.standby-action-label.clock-out   { background: #e74c3c; color: #fff; }
.standby-action-label.break-start { background: #f1c40f; color: #1e2847; }
.standby-action-label.break-end   { background: #e67e22; color: #fff; }

.standby-time { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.standby-return {
  margin-top: 10px; padding: 10px 24px;
  background: rgba(251,232,166,0.12); border: 1px solid rgba(251,232,166,0.3);
  border-radius: 12px; text-align: center;
}
.standby-return-label {
  font-size: 0.7rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 4px;
}
#sdReturnTime {
  font-family: 'Rajdhani','Syne',sans-serif; font-size: 1.9rem; font-weight: 700;
  color: var(--yellow); letter-spacing: 3px;
}

/* #15 Thank You message on standby */
.standby-thankyou {
  font-size: 2.2rem; color: var(--teal); margin-top: 10px;
  letter-spacing: 2px; text-transform: uppercase; font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
}

.standby-btn {
  margin-top: 20px; padding: 16px 44px;
  background: var(--accent); color: #1e2847;
  border: none; border-radius: 14px;
  font-family: 'Rajdhani', sans-serif; font-size: 1.25rem; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 6px 24px rgba(244,151,108,0.35);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.03)} }
.standby-btn:hover { filter: brightness(1.1); animation: none; transform: scale(1.04); }
.standby-btn:active { transform: scale(0.97); }
.standby-countdown { font-size: 0.72rem; color: var(--muted); margin-top: 10px; }

/* ── PIN Modal ───────────────────────────────────────────────────────────── */
.pin-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(10,16,40,0.93); z-index: 500;
  align-items: center; justify-content: center; padding: 20px;
}
.pin-overlay.show { display: flex; }
.pin-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; width: 100%; max-width: 300px;
  padding: 24px 20px; text-align: center; animation: slideUp 0.3s ease;
}
.pin-title { font-family: 'Rajdhani', sans-serif; font-size: 1.2rem; font-weight: 700;
             letter-spacing: 2px; color: var(--lightest); margin-bottom: 4px; }
.pin-sub   { font-size: 0.8rem; color: var(--muted); margin-bottom: 16px; }
.pin-dots  { display: flex; gap: 12px; justify-content: center; margin-bottom: 16px; }
.pin-dot   { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); transition: all 0.2s; }
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-error { font-size: 0.8rem; color: #ff8080; margin-bottom: 10px; min-height: 16px; }
.pin-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-key {
  padding: 13px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface2); color: var(--lightest);
  font-family: 'Rajdhani', sans-serif; font-size: 1.2rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s;
}
.pin-key:hover  { border-color: var(--accent); color: var(--yellow); }
.pin-key:active { transform: scale(0.92); }
.pin-key.cancel { font-family: 'Outfit', sans-serif; font-size: 0.75rem; color: var(--muted); }
