:root {
  --blue-primary: #1e60b3;
  --blue-hover: #174d90;
  --blue-light: #ebf3ff;
  --blue-muted: #a3cfff;
  --text-dark: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --input-bg: #f9fafb;
  --white: #ffffff;
  --success: #10b981;
  --bg-gray: #f3f6fb;
  --register-keyboard-inset: 0px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--bg-gray);
  color: var(--text-dark);
  line-height: 1.5;
  overflow-x: hidden;
}

.register-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (Left Panel) ── */
.register-left {
  position: relative;
  width: 35%;
  min-width: 320px;
  background: #2f66b5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--white);
}

.deco-circle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.1);
}

.deco-1 {
  width: 300px;
  height: 300px;
  top: -100px;
  right: -80px;
}
.deco-2 {
  width: 200px;
  height: 200px;
  bottom: 10%;
  left: -50px;
}
.deco-3 {
  width: 120px;
  height: 120px;
  bottom: 30%;
  right: -20px;
  background: rgba(255, 255, 255, 0.05);
}

.left-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  z-index: 10;
}

.left-brand img {
  width: 38px;
  height: 38px;
  filter: brightness(0) invert(1);
}

.left-brand-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.5px;
}

.left-brand-text span {
  color: var(--blue-muted);
}

.left-tagline {
  z-index: 10;
  margin-top: auto;
  margin-bottom: auto;
}

.left-tagline h2 {
  font-family: "DM Serif Display", serif;
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  line-height: 1.15;
  font-weight: 400;
}

.left-tagline h2 em {
  font-style: italic;
  color: var(--blue-muted);
}

.left-footer {
  z-index: 10;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* ── Right Panel ── */
.register-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2.25rem 3rem;
  background: var(--white);
  overflow-y: auto;
}

.form-container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

/* ── Stepper ── */
.stepper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  position: relative;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  transition: opacity 0.3s;
}

.stepper::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  z-index: 1;
  transform: translateY(-50%);
}

.step-item {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  position: relative;
  z-index: 2;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.step-item.active {
  background: var(--blue-primary);
  border-color: var(--blue-primary);
  color: var(--white);
}

.step-item.completed {
  background: var(--blue-primary);
  border-color: var(--blue-primary);
  color: var(--white);
}

.step-item span.step-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  font-size: 0.7rem;
  white-space: nowrap;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
}

.step-item.active span.step-label {
  color: var(--blue-primary);
}

/* ── Step Content ── */
.step-content {
  display: none;
}

.step-content.active {
  display: block !important;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-header {
  margin-bottom: 1.75rem;
}

.role-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--blue-light);
  color: var(--blue-primary);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.step-header h1 {
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.step-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.extraction-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
}

.extraction-notice i { margin-top: 0.15rem; color: var(--blue-primary); }
.extraction-notice strong, .extraction-notice span { display: block; }
.extraction-notice span { margin-top: 0.15rem; color: var(--text-muted); font-size: 0.8rem; }
.form-group input.was-prefilled { border-color: #8aa6c7; background: #f8fbff; }

/* ── Role Cards (Step 1) ── */
.role-selection {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.role-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.role-card:hover {
  border-color: var(--blue-primary);
  background: var(--blue-light);
}

.role-card.selected {
  border-color: var(--blue-primary);
  background: var(--blue-light);
  box-shadow: 0 0 0 1px var(--blue-primary);
}

.role-icon {
  width: 60px;
  height: 60px;
  background: #f0f4f8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--blue-primary);
}

.role-card.selected .role-icon {
  background: var(--blue-primary);
  color: var(--white);
}

.role-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.role-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Form Groups ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.privacy-agreement {
  margin: -1rem 0 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: .8rem;
  line-height: 1.5;
}

.privacy-agreement summary {
  cursor: pointer;
  color: var(--blue-primary);
  font-weight: 700;
}

.privacy-agreement details p {
  margin: .7rem 0 0;
}

.privacy-agreement label {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  margin-top: .9rem;
  color: var(--text-main);
  cursor: pointer;
}

.privacy-agreement input {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  margin-top: .15rem;
  accent-color: var(--blue-primary);
}

.privacy-modal[hidden] { display: none !important; pointer-events: none; }
.privacy-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 1.25rem; }
.privacy-modal__backdrop { position: absolute; inset: 0; background: rgba(15, 35, 65, .56); }
.privacy-modal__dialog { position: relative; width: min(100%, 780px); max-height: min(820px, calc(100vh - 2.5rem)); overflow: auto; padding: 0; border-radius: 16px; background: var(--white); box-shadow: 0 24px 70px rgba(15, 35, 65, .25); }
.privacy-modal__header { padding: 1.6rem 2rem 1.25rem; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, #f5f9ff, #ffffff); }
.privacy-modal__eyebrow { color: var(--blue-primary); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.privacy-modal__dialog h2 { margin: .45rem 0; color: var(--text-main); font-size: 1.75rem; }
.privacy-modal__header p { margin: 0; color: var(--text-muted); font-size: .92rem; line-height: 1.55; }
.privacy-modal__body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; padding: 1.35rem 2rem .5rem; }
.privacy-modal__body section { padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.privacy-modal__body section:last-child { grid-column: 1 / -1; }
.privacy-modal__body h3 { margin: 0 0 .45rem; color: var(--text-main); font-size: .9rem; }
.privacy-modal__body p { margin: 0; color: var(--text-muted); font-size: .78rem; line-height: 1.55; }
.privacy-modal__agreement { display: flex; align-items: flex-start; gap: .75rem; margin: 1rem 2rem 0; padding: 1.1rem; border: 1px solid #cfe0f9; border-radius: 9px; background: var(--blue-light); color: var(--text-main); font-size: .88rem; line-height: 1.5; cursor: pointer; }
.privacy-modal__agreement input { width: 1rem; height: 1rem; flex: 0 0 auto; margin-top: .15rem; accent-color: var(--blue-primary); }
.privacy-modal__actions { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: .75rem; margin: 1rem 2rem 1.5rem; }
.privacy-modal__actions button { min-height: 48px; justify-content: center; }
.privacy-modal__actions .btn-primary:disabled { cursor: not-allowed; opacity: .55; }
@media (max-width: 620px) { .privacy-modal__dialog { max-height: calc(100vh - 1.5rem); } .privacy-modal__header { padding: 1.35rem 1.25rem 1rem; } .privacy-modal__body { grid-template-columns: 1fr; padding: 1rem 1.25rem .25rem; } .privacy-modal__agreement { margin: .85rem 1.25rem 0; } .privacy-modal__actions { margin: .85rem 1.25rem 1.25rem; } .privacy-modal__actions .btn-primary { flex: 1; } }

.form-grid.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.full-width {
  grid-column: span 2;
}

.three-col .full-width {
  grid-column: span 3;
}

.form-grid > .form-group {
  min-width: 0;
}

.form-group.agent-only {
  display: none;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.form-group label span {
  color: #ef4444;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s;
  background: var(--input-bg);
}

.form-group input:focus {
  border-color: var(--blue-primary);
  outline: none;
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(30, 96, 179, 0.1);
}

/* ── Verification Step (Step 3) ── */
.id-upload-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: start;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

.upload-box {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--input-bg);
}

.upload-box:hover {
  border-color: var(--blue-primary);
  background: var(--blue-light);
}

.upload-box i {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.id-detection-status {
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.id-detection-status.is-loading {
  color: var(--blue-primary);
}

.id-detection-status.is-success {
  color: #24734f;
}

.id-detection-status.is-error {
  color: #b42318;
}

.upload-box.is-invalid {
  border-color: #d92d20;
}

.upload-box.is-valid {
  border-color: #3f7c5d;
}

.upload-box:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.form-group select.is-detecting {
  color: var(--text-muted);
  cursor: progress;
}

.upload-box p {
  font-weight: 600;
}

.upload-box > span {
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.upload-preview {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--white);
}

.upload-box.has-preview {
  display: block;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: var(--white);
}

.upload-box.has-preview > i,
.upload-box.has-preview > p,
.upload-box.has-preview > span,
.upload-box.has-preview > .upload-success {
  display: none !important;
}

.upload-box.has-preview .upload-preview {
  display: block;
  position: relative;
  inset: auto;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}

.face-scan-section {
  padding-top: 0.25rem;
}

.face-scan-section > p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.camera-frame {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 4 / 3;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
}

.camera-frame video,
.camera-frame .camera-placeholder,
.face-preview {
  width: 100%;
  height: 100%;
}

.camera-frame video {
  position: relative;
  z-index: 2;
  display: none;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.face-preview {
  display: none;
  max-width: 420px;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  object-fit: cover;
}

.camera-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.camera-actions .btn-primary,
.camera-actions .btn-secondary {
  width: auto;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
}

.btn-secondary {
  color: var(--text-dark);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.face-scan-area {
  background: #000;
  border-radius: 12px;
  aspect-ratio: 16/9;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--white);
  overflow: hidden;
  margin-top: 1.5rem;
  cursor: pointer;
}

.face-scan-area i {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.face-scan-area p {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ── Success Step (Step 4) ── */
.success-card {
  text-align: center;
  padding: 2rem 0;
}

.success-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
}

.success-card h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.success-card p {
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto 2rem;
}

.verification-pending {
  background: var(--bg-gray);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.verification-pending span {
  display: block;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* ── Buttons ── */
.btn-row {
  margin-top: 2rem;
}

.btn-primary {
  width: 100%;
  background: var(--blue-primary);
  color: var(--white);
  border: none;
  padding: 1rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 96, 179, 0.2);
}

.signin-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.signin-link a {
  color: var(--blue-primary);
  text-decoration: none;
  font-weight: 600;
}

.signin-link a:hover {
  text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .register-left {
    width: 300px;
  }
  .register-right {
    padding: 3rem 2rem;
  }
}

@media (max-width: 768px) {
  .register-wrapper {
    display: block;
  }
  .register-left {
    display: none;
  }
  .register-right {
    min-height: auto;
    padding: 1.5rem 1rem calc(2rem + var(--register-keyboard-inset));
    overflow: visible;
  }
  .role-selection {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid.three-col {
    grid-template-columns: 1fr;
  }
  .full-width,
  .three-col .full-width,
  .register-grid-span-2 {
    grid-column: span 1;
  }
  .id-upload-grid {
    grid-template-columns: 1fr;
  }
}

.upload-box {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 130px;
  flex-direction: column;
}

.preview-image {
  width: 20px;
  height: 30px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #ddd;
}

.ui-hidden {
  display: none;
}

.register-grid-span-2 {
  grid-column: span 2;
}

/* This rule follows the desktop span declaration above so it reliably wins
   on phones and cannot create an implicit second grid column. */
@media (max-width: 768px) {
  html {
    scroll-padding-bottom: 48vh;
  }

  .register-grid-span-2 {
    grid-column: span 1;
  }

  .step-header h1 {
    font-size: 1.6rem;
  }

  .form-grid {
    gap: 1.1rem;
  }

  .form-group input,
  .form-group select {
    min-width: 0;
  }

  .form-group {
    scroll-margin-block: 3rem 48vh;
  }

  /* Keep password controls before the large address section on phones so
     they remain practical even in browsers with restrictive keyboard panning. */
  .form-grid.three-col > .form-group:has(#password) {
    order: 1;
  }

  .form-grid.three-col > .form-group:has(#confirmPassword) {
    order: 2;
  }

  .form-grid.three-col > #address-container {
    order: 3;
  }
}
