/* ═══════════════════════════════════════════════════════════════════════════
   MULTI-STEP FORMS — danishafzal.com
   Full design system for multi-step forms with progress, transitions,
   validation states, microcopy and thank-you screen.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Form Page Layout ────────────────────────────────────────────────────── */
.ms-form-page {
  min-height: 100vh;
  padding: 80px 0 60px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.ms-form-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Form Header ─────────────────────────────────────────────────────────── */
.ms-form-header {
  padding: 40px 0 32px;
}

.ms-form-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--orange);
  background: var(--orange-dim);
  border: 1px solid var(--orange-glow);
  padding: 5px 12px;
  border-radius: 99px;
  margin-bottom: 16px;
}

.ms-form-badge-dot {
  width: 6px;
  height: 6px;
  background: var(--orange);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.ms-form-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 10px;
}

.ms-form-subtitle {
  font-size: 1rem;
  color: var(--text-2);
  line-height: 1.65;
  max-width: 520px;
}

/* ── Progress Indicator ──────────────────────────────────────────────────── */
.ms-progress {
  margin-bottom: 32px;
}

.ms-progress-track {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 10px;
}

.ms-progress-step {
  display: flex;
  align-items: center;
  flex: 1;
  position: relative;
}

.ms-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  z-index: 1;
  border: 2px solid var(--border-hover);
  background: var(--bg-card);
  color: var(--text-3);
  font-family: var(--font-display);
}

.ms-step-dot.active {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
  box-shadow: 0 0 0 4px var(--orange-dim);
}

.ms-step-dot.completed {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
}

.ms-step-dot.completed::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/14px no-repeat;
}
.ms-step-dot.completed span { display: none; }

.ms-step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
  transition: background 0.35s ease;
  border-radius: 2px;
}
.ms-step-line.completed { background: var(--orange); }

.ms-progress-labels {
  display: flex;
  justify-content: space-between;
}

.ms-step-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
  transition: color 0.25s ease;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}
.ms-step-label:first-child { text-align: left; padding-left: 0; }
.ms-step-label:last-child { text-align: right; padding-right: 0; }
.ms-step-label.active { color: var(--orange); font-weight: 600; }
.ms-step-label.completed { color: var(--text-2); }

.ms-progress-bar-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 16px;
}

.ms-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-light));
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}

/* ── Form Card ───────────────────────────────────────────────────────────── */
.ms-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Step Container ──────────────────────────────────────────────────────── */
.ms-steps-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ms-step {
  display: none;
  padding: 36px 40px;
  animation: stepFadeIn 0.32s cubic-bezier(0.4,0,0.2,1) both;
}

.ms-step.active { display: block; }
.ms-step.exit-left { animation: stepExitLeft 0.28s cubic-bezier(0.4,0,0.2,1) both; }
.ms-step.exit-right { animation: stepExitRight 0.28s cubic-bezier(0.4,0,0.2,1) both; }
.ms-step.enter-right { animation: stepEnterRight 0.32s cubic-bezier(0.4,0,0.2,1) both; }
.ms-step.enter-left { animation: stepEnterLeft 0.32s cubic-bezier(0.4,0,0.2,1) both; }

@keyframes stepFadeIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes stepExitLeft {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-24px); }
}
@keyframes stepExitRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}
@keyframes stepEnterRight {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes stepEnterLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Step Heading ────────────────────────────────────────────────────────── */
.ms-step-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.ms-step-desc {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ── Field Groups ────────────────────────────────────────────────────────── */
.ms-field {
  margin-bottom: 22px;
}

.ms-field:last-of-type { margin-bottom: 0; }

.ms-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ms-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.ms-label-required {
  color: var(--orange);
  font-size: 0.75rem;
}

.ms-label-opt {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-3);
  margin-left: auto;
  letter-spacing: 0.02em;
}

.ms-hint {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 6px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.ms-hint svg { flex-shrink: 0; margin-top: 1px; opacity: 0.6; }

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.ms-input,
.ms-select,
.ms-textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.6;
}

.ms-input::placeholder,
.ms-textarea::placeholder { color: var(--text-3); }

.ms-input:focus,
.ms-select:focus,
.ms-textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-dim);
  background: var(--bg-card);
}

.ms-input.valid { border-color: #22c55e; }
.ms-input.valid:focus { box-shadow: 0 0 0 3px rgba(34,197,94,0.12); }

.ms-input.error,
.ms-select.error,
.ms-textarea.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
  animation: shake 0.4s cubic-bezier(0.36,0.07,0.19,0.97);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.ms-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6b80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

.ms-textarea {
  resize: vertical;
  min-height: 110px;
}

/* Input with icon prefix */
.ms-input-wrap {
  position: relative;
}

.ms-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  display: flex;
}

.ms-input-wrap .ms-input {
  padding-left: 42px;
}

/* Validation message */
.ms-error-msg {
  font-size: 0.78rem;
  color: #ef4444;
  margin-top: 5px;
  display: none;
  align-items: center;
  gap: 4px;
}
.ms-error-msg.visible { display: flex; }

/* ── Radio / Option Cards ────────────────────────────────────────────────── */
.ms-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ms-options-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ms-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  position: relative;
}

.ms-option:hover {
  border-color: var(--orange-glow);
  background: var(--bg-card);
}

.ms-option input[type="radio"],
.ms-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ms-option-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-hover);
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
}

.ms-option input[type="checkbox"] ~ .ms-option-indicator {
  border-radius: 5px;
}

.ms-option.selected {
  border-color: var(--orange);
  background: var(--orange-dim);
}

.ms-option.selected .ms-option-indicator {
  background: var(--orange);
  border-color: var(--orange);
}

.ms-option.selected .ms-option-indicator::after {
  content: '';
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
}

.ms-option.selected input[type="checkbox"] ~ .ms-option-indicator::after {
  content: '';
  width: 10px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/10px no-repeat;
  border-radius: 0;
}

.ms-option-text strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1px;
  line-height: 1.3;
}

.ms-option-text span {
  font-size: 0.8rem;
  color: var(--text-3);
  line-height: 1.4;
}

.ms-option.selected .ms-option-text strong { color: var(--orange); }
.ms-option.selected .ms-option-text span { color: var(--text-2); }

/* ── Form Footer / Nav ───────────────────────────────────────────────────── */
.ms-form-footer {
  padding: 20px 40px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
}

.ms-btn-back {
  background: transparent;
  border: 1.5px solid var(--border-hover);
  border-radius: 10px;
  padding: 12px 20px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
}

.ms-btn-back:hover {
  border-color: var(--text-2);
  color: var(--text);
}

.ms-btn-back:disabled,
.ms-btn-back[hidden] {
  opacity: 0;
  pointer-events: none;
}

.ms-btn-next,
.ms-btn-submit {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 28px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px var(--orange-glow);
  margin-left: auto;
}

.ms-btn-next:hover,
.ms-btn-submit:hover {
  background: var(--orange-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--orange-glow);
}

.ms-btn-next:active,
.ms-btn-submit:active {
  transform: translateY(0);
}

.ms-btn-submit.loading {
  opacity: 0.8;
  pointer-events: none;
}

.ms-btn-submit.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.ms-step-count {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
}

/* ── Thank You Screen ────────────────────────────────────────────────────── */
.ms-thankyou {
  display: none;
  padding: 60px 40px;
  text-align: center;
  flex-direction: column;
  align-items: center;
  animation: stepFadeIn 0.5s ease both;
}

.ms-thankyou.visible {
  display: flex;
}

.ms-thankyou-icon {
  width: 72px;
  height: 72px;
  background: rgba(34,197,94,0.12);
  border: 2px solid rgba(34,197,94,0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: #22c55e;
  animation: popIn 0.5s 0.2s cubic-bezier(0.34,1.56,0.64,1) both;
}

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

.ms-thankyou h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.ms-thankyou p {
  font-size: 0.95rem;
  color: var(--text-2);
  line-height: 1.7;
  max-width: 420px;
  margin: 0 auto 8px;
}

.ms-thankyou-details {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 20px auto 0;
  max-width: 380px;
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ms-thankyou-detail {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-2);
}

.ms-thankyou-detail svg { color: var(--orange); flex-shrink: 0; }

.ms-thankyou-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Fluent hidden form bridge ───────────────────────────────────────────── */
.ms-fluent-bridge {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ms-form-wrap { padding: 0 16px; }
  .ms-step { padding: 28px 20px; }
  .ms-form-footer { padding: 16px 20px 24px; }
  .ms-row { grid-template-columns: 1fr; }
  .ms-options-row { grid-template-columns: 1fr; }
  .ms-thankyou { padding: 40px 24px; }
  .ms-step-label { display: none; }
  .ms-step-label.active { display: block; font-size: 0.72rem; }
  .ms-btn-back span { display: none; }
  .ms-btn-next span, .ms-btn-submit span { display: none; }
}
