/* ============================================
   NOMADA SCANNER — ALL STYLES
   Designed for dark venues, big touch targets,
   and high-contrast scan results.
   ============================================ */

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

html, body {
  height: 100%;
  overflow: hidden;            /* Prevent page scroll — we handle everything */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0a0a;
  color: #ffffff;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screen Switching ──────────────────────── */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ════════════════════════════════════════════
   PIN SCREEN
   ════════════════════════════════════════════ */
.pin-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pin-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: #00d9ff;
  margin-bottom: 4px;
}

.pin-subtitle {
  font-size: 1.1rem;
  color: #888;
  margin-bottom: 32px;
  letter-spacing: 0.05em;
}

.pin-prompt {
  font-size: 1rem;
  color: #aaa;
  margin-bottom: 24px;
}

/* PIN Dots */
.pin-dots {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #555;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.pin-dot.filled {
  background: #00d9ff;
  border-color: #00d9ff;
}

/* Shake animation (wrong PIN) */
.pin-dots.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

/* PIN Error */
.pin-error {
  height: 20px;
  font-size: 0.85rem;
  color: #DC2626;
  margin-bottom: 24px;
  opacity: 0;
  transition: opacity 0.2s;
}

.pin-error.visible {
  opacity: 1;
}

/* Number Pad */
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 12px;
}

.pin-key {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid #333;
  background: transparent;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.pin-key:active {
  background: rgba(0, 217, 255, 0.15);
  border-color: #00d9ff;
}

.pin-key:disabled {
  opacity: 0.3;
  cursor: default;
}

.pin-key-action {
  font-size: 1.3rem;
  color: #888;
  border-color: #222;
}

/* ════════════════════════════════════════════
   SCANNER SCREEN
   ════════════════════════════════════════════ */

/* Top Bar */
.scanner-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #111;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #00d9ff;
}

.topbar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #333;
  background: transparent;
  color: #ccc;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.topbar-btn:active {
  background: rgba(255, 255, 255, 0.1);
}

/* Refresh spinning animation */
.topbar-btn.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Refresh status message */
.refresh-status {
  text-align: center;
  font-size: 0.75rem;
  color: #00d9ff;
  padding: 4px 0;
  background: #111;
  opacity: 0;
  transition: opacity 0.3s;
  flex-shrink: 0;
}

.refresh-status.visible {
  opacity: 1;
}

/* Scanner Body (camera area) */
.scanner-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

.scanner-viewfinder {
  width: 100%;
  height: 100%;
}

/* Override html5-qrcode default styles */
#scanner-viewfinder video {
  object-fit: cover !important;
}

.scan-ready-text {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  pointer-events: none;
  z-index: 5;
}

.scanner-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #DC2626;
  font-size: 0.9rem;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 5;
}

.scanner-error.visible {
  opacity: 1;
}

/* ── Scan Result Overlay ───────────────────── */
.scan-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
}

.scan-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.scan-overlay.result-female {
  background: #EC4899;         /* Pink */
}

.scan-overlay.result-male {
  background: #2563EB;         /* Blue */
}

.scan-overlay.result-rejected {
  background: #DC2626;         /* Red */
}

.scan-overlay-text {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── Dismiss / Next Button ─────────────────── */
.dismiss-btn {
  position: absolute;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.dismiss-btn.visible {
  display: flex;
}

.dismiss-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

/* Hand preference positions */
.dismiss-btn.right-hand {
  right: 24px;
}

.dismiss-btn.left-hand {
  left: 24px;
}

/* ── Scanner Footer ────────────────────────── */
.scanner-footer {
  padding: 10px 12px;
  background: #111;
  border-top: 1px solid #222;
  flex-shrink: 0;
  z-index: 10;
}

.mini-history {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #aaa;
  min-height: 20px;
  overflow-x: auto;
  white-space: nowrap;
}

.mini-history-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mini-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.mini-divider {
  color: #444;
  margin: 0 4px;
}

.history-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #333;
  border-radius: 8px;
  background: transparent;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
}

.history-btn:active {
  background: rgba(255, 255, 255, 0.05);
}

/* ════════════════════════════════════════════
   HISTORY PANEL (Slide-Up Sheet)
   ════════════════════════════════════════════ */
.history-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 80vh;
  background: #141414;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-panel.open {
  transform: translateY(0);
}

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.history-panel-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.history-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #222;
  color: #aaa;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Counters */
.history-counters {
  display: flex;
  gap: 24px;
  padding: 16px 20px 8px;
  flex-shrink: 0;
}

.history-counter-block {
  display: flex;
  flex-direction: column;
}

.history-counter-label {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.history-counter-value {
  font-size: 2rem;
  font-weight: 800;
  color: #00d9ff;
}

.history-counter-rejected {
  color: #DC2626;
}

.history-breakdown {
  padding: 0 20px 12px;
  font-size: 0.8rem;
  color: #888;
  flex-shrink: 0;
}

/* Scan List */
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid #1a1a1a;
  font-size: 0.78rem;
}

.history-num {
  color: #555;
  min-width: 28px;
  text-align: right;
}

.history-id {
  color: #aaa;
  font-family: monospace;
  min-width: 90px;
}

.history-type {
  min-width: 60px;
}

.history-status {
  color: #888;
  min-width: 65px;
}

.history-time {
  color: #666;
  min-width: 80px;
}

.history-ago {
  color: #555;
  margin-left: auto;
}

.history-empty {
  text-align: center;
  color: #555;
  padding: 40px 0;
}