/* ==========================================================================
   register.css — public visitor registration page
   ========================================================================== */

/* ---------- Top bar ---------- */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  background: var(--surface-0);
  border-bottom: 1px solid var(--ink-100);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-brand { display: flex; align-items: center; gap: var(--sp-2); }
.topbar-dot { width: 7px; height: 7px; border-radius: 50%; }
.topbar-dot + .topbar-dot { margin-left: -2px; }
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin-left: var(--sp-2); letter-spacing: -0.01em; }
.topbar-badge {
  font-size: 12px; font-weight: 600; color: var(--accent-600);
  background: var(--accent-100); padding: 5px 12px; border-radius: var(--r-full);
}

/* ---------- Split layout ---------- */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  min-height: calc(100vh - 56px);
}
.form-pane { padding: var(--sp-8) var(--sp-6); border-right: 1px solid var(--ink-100); }
.form-pane-inner { max-width: 480px; margin: 0 auto; }

.intro { margin-bottom: var(--sp-8); }
.intro h1 { font-size: 26px; font-weight: 800; color: var(--ink-900); }
.intro-sub { margin-top: var(--sp-2); font-size: 14px; color: var(--ink-500); line-height: 1.55; }

.preview-pane { background: var(--surface-100); display: flex; align-items: flex-start; justify-content: center; padding: var(--sp-8) var(--sp-6); }
.preview-sticky { position: sticky; top: 88px; width: 100%; max-width: 340px; }
.preview-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-500); margin-bottom: var(--sp-3); }

/* ---------- Form fields ---------- */
/* Two-column form rows (desktop & mobile) */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.form-row .field {
  margin-bottom: 0;
}
.form-col {
  min-width: 0;
}
.field { margin-bottom: var(--sp-5); position: relative; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-700); margin-bottom: var(--sp-2); }
.field-hint { min-height: 16px; font-size: 12px; color: var(--danger-500); margin-top: var(--sp-1); }

.input {
  width: 100%;
  height: 44px;
  padding: 0 var(--sp-4);
  border: 1.5px solid var(--ink-100);
  border-radius: var(--r-md);
  font-size: 14.5px;
  font-family: var(--font-body);
  color: var(--ink-900);
  background: var(--surface-0);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input::placeholder { color: var(--ink-300); }
.input:focus { outline: none; border-color: var(--accent-500); box-shadow: 0 0 0 3px var(--accent-100); }
.input.is-invalid { border-color: var(--danger-500); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; border: none; cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent-500); color: #fff; box-shadow: 0 2px 8px rgba(91,79,224,0.28); }
.btn-primary:hover:not(:disabled) { background: var(--accent-600); }
.btn-secondary { background: var(--surface-100); color: var(--ink-700); }
.btn-secondary:hover:not(:disabled) { background: var(--ink-100); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; font-size: 15px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: none; color: var(--accent-500); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; }
.link-btn:disabled { color: var(--ink-300); cursor: not-allowed; }
.icon-btn { background: var(--surface-100); border: none; border-radius: var(--r-sm); width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--ink-700); }

.form-footnote { font-size: 11.5px; color: var(--ink-300); margin-top: var(--sp-4); line-height: 1.5; }

/* ---------- Photo picker ---------- */
.photo-picker { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.photo-preview {
  width: 68px; height: 68px; border-radius: 50%; background: var(--surface-100);
  display: grid; place-items: center; color: var(--ink-300); overflow: hidden;
  border: 2px dashed var(--ink-100); flex-shrink: 0;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Phone / country picker ---------- */
.phone-row { display: flex; gap: var(--sp-2); position: relative; }
.country-select {
  display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 10px;
  border: 1.5px solid var(--ink-100); border-radius: var(--r-md); background: var(--surface-0);
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-900); flex-shrink: 0;
}
.country-select .fi { border-radius: 3px; width: 18px; height: 13px; }
.phone-input { flex: 1; min-width: 0; }

.country-popover {
  position: absolute; top: calc(100% + 8px); left: 0; width: min(320px, 86vw); max-height: 340px;
  background: var(--surface-0); border: 1px solid var(--ink-100); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); z-index: 40; padding: var(--sp-3); display: flex; flex-direction: column;
  opacity: 0; transform: translateY(-6px); transition: opacity var(--transition-fast), transform var(--transition-fast);
  pointer-events: none;
}
.country-popover.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.country-popover .input { height: 42px; margin-bottom: var(--sp-2); font-size: 14px; flex-shrink: 0; }
.country-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.country-list li {
  display: flex; align-items: center; gap: var(--sp-2); padding: 9px 8px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 13.5px;
}
.country-list li:hover { background: var(--surface-100); }
.country-list .fi { width: 18px; height: 13px; border-radius: 2px; flex-shrink: 0; }
.country-list .cname { flex: 1; }
.country-list .cdial { color: var(--ink-300); font-weight: 600; }
.country-list .skeleton-row { background: var(--surface-100); border-radius: var(--r-sm); height: 34px; margin-bottom: 6px; animation: skeleton-pulse 1.1s ease-in-out infinite; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---------- OTP ---------- */
.otp-block { margin-top: var(--sp-4); padding: var(--sp-4); background: var(--surface-100); border-radius: var(--r-md); }
.otp-copy { font-size: 13px; color: var(--ink-700); margin-bottom: var(--sp-3); }
.otp-inputs { display: flex; gap: 8px; }
.otp-digit {
  width: 40px; height: 48px; text-align: center; font-size: 20px; font-weight: 700;
  border: 1.5px solid var(--ink-100); border-radius: var(--r-sm); background: var(--surface-0); color: var(--ink-900);
}
.otp-digit:focus { outline: none; border-color: var(--accent-500); box-shadow: 0 0 0 3px var(--accent-100); }
.otp-footer { display: flex; justify-content: space-between; align-items: center; margin-top: var(--sp-3); font-size: 12.5px; color: var(--ink-500); }

.verified-pill {
  margin-top: var(--sp-3); display: inline-flex; align-items: center; gap: 6px;
  background: var(--success-100); color: var(--success-500); font-size: 13px; font-weight: 600;
  padding: 8px 12px; border-radius: var(--r-full);
}
.verified-pill .link-btn { margin-left: 6px; color: var(--success-500); text-decoration: underline; }

/* ---------- Badge canvas (shared: preview pane + bottom sheet) ---------- */
.badge-canvas {
  position: relative; width: 100%; aspect-ratio: 1181 / 1653;
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-lg);
  background: var(--surface-0);
}
.badge-canvas svg.badge-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.badge-overlay-photo {
  position: absolute; border-radius: 50%; background: var(--surface-100) center/cover no-repeat;
  border: 2px solid var(--accent-500); display: grid; place-items: center; color: var(--ink-300); overflow: hidden;
}
.badge-overlay-photo svg { width: 34%; height: 34%; }
.badge-overlay-text {
  position: absolute; transform: translate(-50%, -50%); text-align: center; white-space: nowrap;
  font-family: var(--font-body); line-height: 1;
}
.badge-overlay-id {
  position: absolute; transform: translate(-50%, -50%); background: var(--cmyk-black); color: #fff;
  border-radius: var(--r-full); font-weight: 700; white-space: nowrap; display: flex; align-items: center; justify-content: center;
}
.badge-overlay-qr { position: absolute; background: #fff; }
.badge-overlay-qr canvas, .badge-overlay-qr img { width: 100%; height: 100%; }

/* ---------- Mobile bottom sheet / FAB ---------- */
.preview-fab { display: none; }
.sheet-backdrop { display: none; }
.bottom-sheet { display: none; }

/* ---------- Modals (camera / success / loading) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,20,31,0.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: var(--sp-4);
}
.camera-modal, .success-modal {
  background: var(--surface-0); border-radius: var(--r-lg); width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.camera-modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--ink-100); }
.camera-modal-head h3 { font-size: 16px; }
.camera-viewport { position: relative; aspect-ratio: 4/3; background: #000; }
.camera-viewport video, .camera-viewport img { width: 100%; height: 100%; object-fit: cover; }
.camera-controls { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); padding: var(--sp-5); }
.shutter-btn {
  width: 60px; height: 60px; border-radius: 50%; background: #fff; border: 4px solid var(--ink-100);
  cursor: pointer; transition: transform var(--transition-fast);
}
.shutter-btn:active { transform: scale(0.9); }

.success-modal { text-align: center; padding: var(--sp-8) var(--sp-6); }
.success-icon {
  width: 56px; height: 56px; border-radius: 50%; background: var(--success-100); color: var(--success-500);
  display: grid; place-items: center; margin: 0 auto var(--sp-4);
}
.success-modal h2 { font-size: 20px; margin-bottom: var(--sp-1); }
.success-code { font-size: 13px; font-weight: 700; color: var(--accent-500); letter-spacing: 0.04em; margin-bottom: var(--sp-4); }
.success-badge-img { width: 60%; margin: 0 auto var(--sp-4); border-radius: var(--r-md); box-shadow: var(--shadow-md); }
.success-note { font-size: 13px; color: var(--ink-500); margin-bottom: var(--sp-6); line-height: 1.5; }
.success-actions { display: flex; flex-direction: column; gap: var(--sp-2); }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.9); backdrop-filter: blur(3px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-4); z-index: 200;
}
.spinner { width: 36px; height: 36px; border: 3px solid var(--accent-100); border-top-color: var(--accent-500); border-radius: 50%; animation: spin 0.8s linear infinite; }
#loadingText { font-size: 14px; font-weight: 600; color: var(--ink-700); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Mobile — app-like: single column form + draggable bottom sheet preview
   ========================================================================== */
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .preview-pane { display: none; }
  .form-pane { border-right: none; padding: var(--sp-5) var(--sp-4) 100px; }
  .intro h1 { font-size: 22px; }
  /* Keep two columns on mobile too */
  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
  }
  .form-row .input {
    font-size: 13px;
    padding: 0 var(--sp-3);
  }
  .form-row .field-label {
    font-size: 11.5px;
  }
  .preview-fab {
    display: flex; align-items: center; gap: 8px; position: fixed; left: 50%; bottom: 20px;
    transform: translateX(-50%); z-index: 50; background: var(--ink-900); color: #fff;
    border: none; padding: 12px 20px; border-radius: var(--r-full); font-size: 13.5px; font-weight: 600;
    box-shadow: var(--shadow-lg); cursor: pointer;
  }

  .sheet-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(20,20,31,0.5); z-index: 60;
    opacity: 0; transition: opacity var(--transition-base);
  }
  .sheet-backdrop.is-open { opacity: 1; }

  .bottom-sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: var(--surface-0); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
    padding: var(--sp-2) var(--sp-5) var(--sp-6); max-height: 88vh; overflow-y: auto;
    transform: translateY(100%); transition: transform var(--transition-base);
    touch-action: pan-y; /* Allow vertical touch scrolling */
    user-select: none;
    -webkit-user-select: none;
  }
  .bottom-sheet.is-open { transform: translateY(0); }
  .sheet-handle-area { display: flex; justify-content: center; padding: var(--sp-3) 0 var(--sp-2); cursor: grab; }
  .sheet-handle { width: 40px; height: 4px; border-radius: var(--r-full); background: var(--ink-100); }
  .bottom-sheet .badge-canvas { max-width: 320px; margin: 0 auto; }
}

@media (max-width: 420px) {
  .otp-digit { width: 15vw; max-width: 42px; }
}