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

:root, [data-theme="dark"] {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --accent: #06b6d4;
  --success: #10b981;
  --error: #ef4444;
  --bg: #0f0e17;
  --card-bg: #1a1929;
  --card-border: rgba(255,255,255,0.07);
  --text: #f0eff7;
  --text-muted: #a09fc0;
  --radius: 20px;
}

[data-theme="light"] {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --accent: #06b6d4;
  --success: #10b981;
  --error: #ef4444;
  --bg: #f4f3ff;
  --card-bg: #ffffff;
  --card-border: rgba(0,0,0,0.07);
  --text: #1e1b3a;
  --text-muted: #6b6a8a;
  --radius: 20px;
}

/* ── Body & Background ── */
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

/* Radial gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(79,70,229,0.25) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(6,182,212,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 60% 40%, rgba(129,140,248,0.08) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

/* Floating grid lines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(79,70,229,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,70,229,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 0;
  pointer-events: none;
}

/* ── Page Container ── */
.page-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
}

/* ── Page Transitions ── */
.page {
  display: none;
  animation: pageIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.page.active {
  display: block;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── App Badge ── */
.app-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.app-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  box-shadow: 0 8px 24px rgba(79,70,229,0.4);
}

.app-icon-success {
  background: linear-gradient(135deg, var(--success), #059669);
  box-shadow: 0 8px 24px rgba(16,185,129,0.4);
}

.app-name {
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.app-name span {
  color: var(--primary-light);
}

/* ── Card ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow:
    0 32px 64px rgba(0,0,0,0.4),
    0 0 0 1px rgba(255,255,255,0.04) inset;
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

/* Top shine line */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}

/* ── Step Indicator ── */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: all 0.3s ease;
}

.step-dot.active {
  width: 24px;
  border-radius: 4px;
  background: var(--primary-light);
}

.step-dot.done {
  background: var(--success);
}

/* ── Page Headings ── */
.page-title {
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
  line-height: 1.5;
}

/* ── Input Field ── */
.field {
  margin-bottom: 20px;
}

.field label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.field label i {
  color: var(--primary-light);
  font-size: 13px;
}

.field input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.25s ease;
  outline: none;
}

.field input::placeholder {
  color: rgba(255,255,255,0.25);
}

.field input:focus {
  border-color: var(--primary-light);
  background: rgba(79,70,229,0.08);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.15);
}

/* Light mode input styling */
[data-theme="light"] .field input {
  background: #ffffff;
  border: 1.5px solid rgba(79,70,229,0.25);
  color: var(--text);
}

[data-theme="light"] .field input::placeholder {
  color: rgba(79,70,229,0.35);
}

[data-theme="light"] .field input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.1);
}

/* ── Buttons ── */
.btn {
  width: 100%;
  padding: 15px 20px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #6d28d9 100%);
  color: white;
  box-shadow: 0 8px 24px rgba(79,70,229,0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(79,70,229,0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  border: 1.5px solid rgba(255,255,255,0.08);
  margin-top: 10px;
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

/* ── Status Messages ── */
.status-msg {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  min-height: 0;
  display: none;
}

.status-msg.show {
  display: block;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.status-msg.error {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.2);
}

.status-msg.info {
  background: rgba(6,182,212,0.1);
  color: #67e8f9;
  border: 1px solid rgba(6,182,212,0.2);
}

.status-msg.success {
  background: rgba(16,185,129,0.1);
  color: #6ee7b7;
  border: 1px solid rgba(16,185,129,0.2);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.9) translateY(4px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);   }
}

/* ── Camera Frame ── */
.camera-frame {
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  position: relative;
  margin-bottom: 8px;
  border: 1.5px solid rgba(79,70,229,0.3);
  box-shadow: 0 0 32px rgba(79,70,229,0.15);
}

#video {
  width: 100%;
  display: block;
  border-radius: 14px;
}

/* ── Scan Overlay ── */
.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-box {
  width: 180px;
  height: 180px;
  position: relative;
}

.scan-box::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid rgba(79,70,229,0.2);
  border-radius: 8px;
}

/* Animated scan line */
.scan-line {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-light), var(--accent), var(--primary-light), transparent);
  border-radius: 2px;
  animation: scanLine 2.5s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(129,140,248,0.6);
}

@keyframes scanLine {
  0%, 100% { top: 10px; opacity: 1; }
  50%       { top: calc(100% - 14px); opacity: 0.8; }
}

/* Corner marks */
.corner-mark {
  position: absolute;
  width: 22px;
  height: 22px;
}

.corner-mark::before,
.corner-mark::after {
  content: '';
  position: absolute;
  background: var(--primary-light);
  border-radius: 2px;
}

.corner-mark::before { width: 100%; height: 3px; }
.corner-mark::after  { width: 3px;  height: 100%; }

.corner-mark.tl { top: -3px;    left: -3px;   }
.corner-mark.tr { top: -3px;    right: -3px;  transform: scaleX(-1);  }
.corner-mark.bl { bottom: -3px; left: -3px;   transform: scaleY(-1);  }
.corner-mark.br { bottom: -3px; right: -3px;  transform: scale(-1);   }

/* ── Success Page ── */
.success-header {
  text-align: center;
  margin-bottom: 32px;
}

.success-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(16,185,129,0.12);
  border: 2px solid rgba(16,185,129,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 44px;
  color: var(--success);
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 40px rgba(16,185,129,0.2);
}

@keyframes scaleIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.success-header h2 {
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.success-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Detail Grid (Success) ── */
.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid rgba(255,255,255,0.06);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row .label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-row .value {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  max-width: 60%;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .card {
    padding: 28px 20px;
  }

  .page-title {
    font-size: 22px;
  }

  .scan-box {
    width: 150px;
    height: 150px;
  }
}
