/* =========================================================================
   Simple Signup Form — Modern light + blue theme
   Class names match the markup exactly; no HTML/JS changes required.
   ========================================================================= */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --grad: linear-gradient(135deg, #2f7ddb 0%, #1d4ed8 100%);
  --text-dark: #0f172a;
  --text-medium: #475569;
  --text-soft: #64748b;
  --background-light: #f1f5f9;
  --white: #fff;
  --border-color: #e2e8f0;
  --field-bg: #f8fafc;
  --danger: #e11d48;
  --danger-bg: #fef2f2;
  --radius: 16px;
  --radius-sm: 10px;
}

/* Scope-ish reset (only affects the form region's typography/box model) */
.container *,
.loading-overlay * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ---------- Layout ---------- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 18px;
}

.form-container {
  --pad: 44px;
  position: relative;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: var(--pad);
  overflow: hidden;
  box-shadow: 0 18px 50px -12px rgba(15, 23, 42, 0.18);
}

/* H1 becomes a full-bleed gradient header strip at the top of the card */
.form-container h1 {
  margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 32px;
  padding: 30px var(--pad);
  background: var(--grad);
  color: var(--white);
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ---------- Autosave note ---------- */
.saved-note {
  font-size: 13px;
  color: #15803d;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 22px;
}

/* ---------- Progress / Stepper ---------- */
.progress-wrap {
  margin-bottom: 40px;
  padding-bottom: 34px;
  border-bottom: 1px solid var(--border-color);
}

.progress-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  max-width: 580px;
  margin: 0 auto;
  --besc-progress: 0; /* 0..1, set by JS as steps advance */
}

/* Unfilled track */
.progress-bar::before,
/* Filled track (grows with progress) */
.progress-bar::after {
  content: "";
  position: absolute;
  top: 19px;
  left: 22px;
  height: 4px;
  border-radius: 4px;
  z-index: 1;
}

.progress-bar::before {
  right: 22px;
  background: var(--border-color);
}

.progress-bar::after {
  width: calc((100% - 44px) * var(--besc-progress));
  background: var(--grad);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-step {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-soft);
  position: relative;
  z-index: 2;
  transition: color 0.25s ease, border-color 0.25s ease,
    background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

/* Active step: filled with a soft focus ring */
.progress-step.active {
  border-color: var(--primary-color);
  background: var(--grad);
  color: var(--white);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.16),
    0 6px 14px -3px rgba(37, 99, 235, 0.5);
  transform: scale(1.06);
}

/* Completed step: filled and shows a checkmark instead of the number */
.progress-step.completed {
  border-color: var(--primary-color);
  background: var(--grad);
  color: transparent; /* hide the number; ::before draws the tick */
  box-shadow: 0 4px 10px -3px rgba(37, 99, 235, 0.45);
}

.progress-step.completed::before {
  content: "\2713"; /* ✓ */
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
}

.step-title {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-soft);
  transition: color 0.25s ease;
}

.progress-step.active .step-title {
  color: var(--primary-dark);
}

.progress-step.completed .step-title {
  color: var(--text-dark);
}

/* ---------- Steps ---------- */
.step { display: none; }
.step.active { display: block; animation: besc-fade 0.35s ease; }

@keyframes besc-fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Form grid ---------- */
.form-row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -10px;
}

.form-group {
  flex: 1 0 calc(50% - 20px);
  margin: 0 10px 22px;
  min-width: 260px;
}

.form-group.full-width {
  flex: 1 0 calc(100% - 20px);
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dark);
}

label.required::after {
  content: " *";
  color: var(--danger);
  font-weight: 700;
}

/* ---------- Inputs ---------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-dark);
  background: var(--field-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  background: var(--white);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input::placeholder,
textarea::placeholder { color: #94a3b8; }

textarea {
  min-height: 130px;
  resize: vertical;
}

select[multiple] { min-height: 130px; }

.hint {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 6px;
}

.char-count {
  font-size: 12px;
  color: var(--text-soft);
  text-align: right;
  margin-top: 5px;
}

/* ---------- Chips (pill style) ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chips.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.sr-only {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

.chip-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--white);
  color: var(--text-medium);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  text-align: center;
  transition: all 0.15s ease;
}

.chips.grid .chip-label { border-radius: var(--radius-sm); }

.chip-label:hover {
  border-color: var(--primary-color);
  color: var(--primary-dark);
}

input[type="radio"].chip:checked + .chip-label,
input[type="checkbox"].chip:checked + .chip-label {
  background: var(--grad);
  border-color: transparent;
  color: var(--white);
  font-weight: 600;
  box-shadow: 0 4px 12px -3px rgba(37, 99, 235, 0.55);
}

input[type="radio"].chip:focus + .chip-label,
input[type="checkbox"].chip:focus + .chip-label {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* ---------- Inline units / toggles ---------- */
.inline {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.inline > * { flex: 1; }

.unit-toggle {
  display: flex;
  gap: 18px;
  margin: 0 0 12px;
}

.unit-toggle label {
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin-bottom: 0;
  color: var(--text-medium);
}

input[type="radio"],
input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  cursor: pointer;
  accent-color: var(--primary-color);
}

/* ---------- Buttons ---------- */
.btn-container {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.btn {
  padding: 13px 26px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-prev {
  background: var(--white);
  border-color: var(--border-color);
  color: var(--text-medium);
}
.btn-prev:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-next,
.btn-submit {
  background: var(--grad);
  color: var(--white);
  box-shadow: 0 8px 20px -6px rgba(37, 99, 235, 0.6);
}
.btn-next:hover,
.btn-submit:hover {
  box-shadow: 0 10px 26px -6px rgba(37, 99, 235, 0.7);
  transform: translateY(-1px);
}

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

/* Push a lone Next button to the right */
.btn-container .btn-next:only-child { margin-left: auto; }

/* ---------- File upload ---------- */
.file-upload {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 38px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--field-bg);
  transition: all 0.15s ease;
}
.file-upload:hover {
  border-color: var(--primary-color);
  background: var(--primary-soft);
}
.file-upload p {
  margin: 4px 0;
  color: var(--text-medium);
}
.file-upload-icon {
  font-size: 36px;
  margin-bottom: 10px;
}
.file-input { display: none; }

.file-list { margin-top: 12px; }

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
}

.file-remove {
  color: var(--danger);
  cursor: pointer;
  font-weight: bold;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}

/* ---------- Loading overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 250, 252, 0.85);
  backdrop-filter: blur(2px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

.spinner {
  width: 46px;
  height: 46px;
  border: 4px solid #dbeafe;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

/* ---------- Errors ---------- */
.error-summary {
  border: 1px solid #fecdd3;
  background: var(--danger-bg);
  color: var(--text-dark);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
}
.error-summary strong { color: var(--danger); }
.error-summary ul { margin: 8px 0 0 18px; }
.error-summary a { color: var(--danger); text-decoration: none; }
.error-summary a:hover { text-decoration: underline; }

.has-error input[type="text"],
.has-error input[type="email"],
.has-error input[type="password"],
.has-error input[type="number"],
.has-error select,
.has-error textarea {
  border-color: var(--danger);
  background: #fff5f6;
}

.error-message {
  font-size: 13px;
  color: var(--danger);
  margin-top: 5px;
}

.group-error { border-color: var(--danger) !important; }

.success-message {
  border: 1px solid #bbf7d0 !important;
  border-radius: var(--radius) !important;
  background: #f0fdf4 !important;
  padding: 48px !important;
  text-align: center !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .form-group { min-width: 220px; }
}

@media (max-width: 768px) {
  .container { padding: 24px 12px; }

  .form-container { --pad: 22px; }

  .form-container h1 { font-size: 24px; }

  .form-row { margin: 0; }

  .form-group,
  .form-group.full-width {
    flex: 1 0 100%;
    margin: 0 0 18px;
  }

  .progress-step { width: 34px; height: 34px; font-size: 13px; }
  .progress-step.completed::before { font-size: 16px; }
  .progress-bar::before,
  .progress-bar::after { top: 16px; left: 17px; }
  .progress-bar::before { right: 17px; }
  .progress-bar::after { width: calc((100% - 34px) * var(--besc-progress)); }
  .step-title { top: 42px; font-size: 9px; letter-spacing: 0.4px; }

  .inline { flex-direction: column; }
  .inline > * { width: 100%; }

  .btn-container { flex-direction: column-reverse; }
  .btn { width: 100%; }
  .btn-container .btn-next:only-child { margin-left: 0; }
}
