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

:root {
  --blue:       #5b9cf6;
  --blue-dark:  #3b7de8;
  --blue-light: #e8f1fe;
  --purple:     #9b7fe8;
  --purple-light: #f0ebff;
  --grad:       linear-gradient(135deg, #5b9cf6 0%, #9b7fe8 100%);
  --grad-soft:  linear-gradient(135deg, #e8f1fe 0%, #f0ebff 100%);

  --text-primary:   #1a2332;
  --text-secondary: #4a5568;
  --text-muted:     #6b7280;

  --border:         #e2e8f0;
  --border-focus:   #5b9cf6;
  --bg-page:        #f0f4f8;
  --bg-card:        #ffffff;
  --bg-input:       #f8faff;

  --success:  #10b981;
  --error:    #ef4444;
  --warning:  #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-card: 0 8px 40px rgba(91, 156, 246, 0.15), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-btn:  0 4px 16px rgba(91, 156, 246, 0.35);
  --shadow-input: 0 0 0 3px rgba(91, 156, 246, 0.15);
}

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ─── Arrière-plan avec orbes ───────────────────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: float 20s ease-in-out infinite;
}

.orb-1 {
  width: 500px; height: 500px;
  background: var(--blue);
  top: -150px; left: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px; height: 400px;
  background: var(--purple);
  bottom: -120px; right: -80px;
  animation-delay: -7s;
}

.orb-3 {
  width: 300px; height: 300px;
  background: #a5c8ff;
  top: 40%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  33%  { transform: translateY(-30px) scale(1.05); }
  66%  { transform: translateY(20px) scale(0.97); }
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.page-wrapper {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 24px;
}

/* ─── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  border: 1px solid rgba(91, 156, 246, 0.1);
}

/* ─── Card Header ───────────────────────────────────────────────────────────── */
.card-header {
  background: var(--grad);
  padding: 36px 40px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.logo-wrap {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.logo-img {
  height: 44px;
  width: auto;
  filter: brightness(0) invert(1);
  transition: transform 0.3s ease;
}

.logo-img:hover { transform: scale(1.03); }

.card-title {
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.card-subtitle {
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  font-weight: 400;
}

/* ─── Steps Indicator ───────────────────────────────────────────────────────── */
.steps-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 32px 0;
  gap: 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.step-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.step-check {
  display: none;
  width: 16px;
  height: 16px;
  stroke: #ffffff;
}

.step-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  margin-bottom: 22px;
  border-radius: 2px;
  transition: background 0.4s ease;
  max-width: 60px;
}

/* Step states */
.step.active .step-circle {
  background: var(--grad);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(91, 156, 246, 0.4);
}

.step.active .step-num { color: #ffffff; }
.step.active .step-label { color: var(--blue); }

.step.completed .step-circle {
  background: var(--success);
  border-color: transparent;
}

.step.completed .step-num { display: none; }
.step.completed .step-check { display: block; }
.step.completed .step-label { color: var(--success); }

.step-line.completed { background: var(--success); }
.step-line.active { background: var(--blue); }

/* ─── Form Steps ────────────────────────────────────────────────────────────── */
.form-step {
  display: none;
  padding: 32px 40px 36px;
  animation: fadeSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-step.active { display: block; }

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

.step-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}

.step-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 28px;
}

.step-desc strong { color: var(--text-primary); }

/* ─── Fields ────────────────────────────────────────────────────────────────── */
.field-group {
  margin-bottom: 20px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.1px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.field-input {
  width: 100%;
  height: 48px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 44px 0 44px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
  appearance: none;
}

.field-input::placeholder { color: var(--text-muted); }

.field-input:focus {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: var(--shadow-input);
}

.field-input.is-error {
  border-color: var(--error);
  background: #fff5f5;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.field-input.is-success {
  border-color: var(--success);
  background: #f0fdf4;
}

.toggle-password {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  transition: color 0.2s;
  display: flex;
  align-items: center;
}

.toggle-password:hover { color: var(--text-primary); }

.eye-icon { width: 18px; height: 18px; }

.field-error {
  display: block;
  font-size: 12px;
  color: var(--error);
  margin-top: 6px;
  min-height: 16px;
  font-weight: 500;
}

/* ─── OTP Grid ──────────────────────────────────────────────────────────────── */
.otp-grid {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.otp-digit {
  width: 52px;
  height: 58px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
  font-family: 'Inter', monospace;
  caret-color: var(--blue);
}

.otp-digit:focus {
  border-color: var(--blue);
  background: #ffffff;
  box-shadow: var(--shadow-input);
  transform: translateY(-2px);
}

.otp-digit.filled {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue-dark);
}

.otp-digit.is-error {
  border-color: var(--error);
  background: #fff5f5;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ─── Password strength ─────────────────────────────────────────────────────── */
.strength-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.strength-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.4s ease, background-color 0.4s ease;
}

.strength-fill.weak    { width: 25%; background: var(--error); }
.strength-fill.fair    { width: 50%; background: var(--warning); }
.strength-fill.good    { width: 75%; background: #3b82f6; }
.strength-fill.strong  { width: 100%; background: var(--success); }

.strength-label {
  font-size: 12px;
  font-weight: 600;
  min-width: 52px;
  text-align: right;
  color: var(--text-muted);
}

.strength-label.weak   { color: var(--error); }
.strength-label.fair   { color: var(--warning); }
.strength-label.good   { color: #3b82f6; }
.strength-label.strong { color: var(--success); }

/* ─── Rules list ────────────────────────────────────────────────────────────── */
.rules-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 12px;
}

.rule {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.rule-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.rule.valid {
  color: var(--success);
}

.rule.valid .rule-icon {
  stroke: var(--success);
}

.rule.valid .rule-icon circle { display: none; }

/* Replace circle with checkmark for valid rules via CSS */
.rule.valid .rule-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2310b981' stroke-width='2.5'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: contain;
}

/* ─── Session Timer ─────────────────────────────────────────────────────────── */
.session-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 20px;
}

.session-timer svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--warning);
}

.session-timer.urgent {
  background: #fff5f5;
  border-color: #fca5a5;
  color: #991b1b;
}

.session-timer.urgent svg { color: var(--error); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--grad);
  color: #ffffff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(91, 156, 246, 0.45);
}

.btn-primary:not(:disabled):active {
  transform: translateY(0);
  box-shadow: var(--shadow-btn);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-secondary:not(:disabled):hover {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.btn-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.btn-primary:not(:disabled):hover .btn-arrow {
  transform: translateX(3px);
}

/* Loading state */
.btn.loading .btn-text,
.btn.loading .btn-arrow { opacity: 0; }

.btn.loading .btn-spinner { opacity: 1; }

.btn-spinner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.7s linear infinite;
  transition: opacity 0.2s;
}

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

.btn-secondary .btn-spinner {
  border-color: rgba(91, 156, 246, 0.3);
  border-top-color: var(--blue);
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 12px 0 0;
  transition: color 0.2s;
}

.btn-back:hover { color: var(--blue); }
.btn-back svg { width: 14px; height: 14px; }

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  transition: color 0.2s;
}

.btn-link:hover { color: var(--blue-dark); }

/* ─── Resend ────────────────────────────────────────────────────────────────── */
.resend-wrap {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Success State ─────────────────────────────────────────────────────────── */
#step-success {
  text-align: center;
}

.success-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  border: 4px solid #6ee7b7;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

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

.success-icon svg {
  width: 32px;
  height: 32px;
  stroke: var(--success);
  stroke-width: 3;
}

.success-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--blue-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
  margin: 24px 0;
}

.success-info svg {
  width: 18px;
  height: 18px;
  color: var(--blue);
  flex-shrink: 0;
  margin-top: 1px;
}

.success-info p {
  font-size: 13px;
  color: var(--blue-dark);
  line-height: 1.55;
}

/* ─── Global Alert ──────────────────────────────────────────────────────────── */
.global-alert {
  margin: 0 40px 24px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: none;
  line-height: 1.5;
}

.global-alert.error {
  display: block;
  background: #fff5f5;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.global-alert.success {
  display: block;
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.page-footer {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .card-header { padding: 28px 24px 24px; }
  .form-step { padding: 24px 24px 28px; }
  .steps-indicator { padding: 20px 24px 0; }
  .global-alert { margin: 0 24px 20px; }

  .otp-digit {
    width: 42px;
    height: 50px;
    font-size: 20px;
  }

  .otp-grid { gap: 7px; }
}

@media (max-width: 360px) {
  .otp-digit { width: 36px; height: 44px; font-size: 18px; }
  .step-label { display: none; }
}

/* ─── Accessibility ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
