/* ==========================================================
   Formulaire comparateur mutuelle — v2
   Préfixe .af- pour ne pas entrer en conflit avec Bootstrap 3/5
   ========================================================== */

@property --fill {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 0%;
}

.af-card {
  --af-blue: #1867ff;
  --af-blue-dark: #0f4fd1;
  --af-blue-soft: #eaf1ff;
  --af-ink: #0d1317;
  --af-muted: #5b6b8c;
  --af-line: #dfe5ef;
  --af-field: #f6f8fc;
  --af-ok: #0f9d6b;
  --af-err: #d93a3a;
  --af-radius: 14px;
}

/* Conteneur : remplace les styles inline / .form-container */
.form-container.af-card {
  flex: 0 1 500px;
  max-width: 500px;
  margin: 0;
  padding: 0;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 60px -20px rgba(13, 19, 23, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.6);
  text-align: left !important;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--af-ink);
  overflow: hidden;
  position: relative;
}

.af-card *,
.af-card *::before,
.af-card *::after {
  box-sizing: border-box;
}

/* ---------- En-tête + progression ---------- */
.af-head {
  padding: 26px 30px 0;
}

.af-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--af-blue);
  background: var(--af-blue-soft);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  margin-bottom: 14px;
}

.af-kicker i {
  font-size: 12px;
}

.af-card .af-title {
  font-size: 25px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 22px;
  color: var(--af-ink);
}

.af-progress {
  list-style: none;
  margin: 0;
  padding: 0 0 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-bottom: 1px solid var(--af-line);
}

.af-progress li {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #9aa6bf;
  transition: color 0.3s;
}

.af-progress li::before {
  content: "";
  display: block;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--af-blue) 0 var(--fill, 0%), #e6ebf4 var(--fill, 0%) 100%);
  transition: --fill 0.5s;
}

.af-progress li.is-active {
  color: var(--af-ink);
  --fill: 50%;
}

.af-progress li.is-done {
  color: var(--af-ok);
  --fill: 100%;
}

.af-progress li.is-done::before {
  background: var(--af-blue);
}

.af-progress li span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.af-progress li.is-done span::before {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 11px;
}

/* ---------- Corps ---------- */
.af-card .form-body {
  padding: 24px 30px 26px;
}

.af-card .step {
  display: none;
}

.af-card .step.active {
  display: block;
  animation: afIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.af-card .step.active.from-left {
  animation-name: afInLeft;
}

@keyframes afIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: none; }
}

@keyframes afInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: none; }
}

.af-step-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--af-ink);
}

.af-step-sub {
  font-size: 14px;
  color: var(--af-muted);
  margin: 0 0 18px;
}

.af-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.af-row.af-row-cp {
  grid-template-columns: 0.75fr 1.25fr;
}

.af-group {
  margin-bottom: 14px;
}

.af-card .af-legend {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--af-muted);
  margin: 0 0 8px;
  padding: 0;
  max-width: none;
}

/* ---------- Champ à label flottant ---------- */
.af-field {
  position: relative;
  margin-bottom: 14px;
}

.af-card .af-input {
  display: block;
  width: 100%;
  height: 58px;
  padding: 24px 42px 8px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--af-ink);
  background: var(--af-field);
  border: 1.5px solid transparent;
  border-radius: var(--af-radius);
  outline: none;
  box-shadow: none;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.af-card .af-input:hover {
  background: #eff3fa;
}

.af-card .af-input:focus {
  background: #fff;
  border-color: var(--af-blue);
  box-shadow: 0 0 0 4px rgba(24, 103, 255, 0.14);
}

.af-card select.af-input {
  cursor: pointer;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235b6b8c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.af-card select.af-input:not(.is-chosen) {
  color: transparent;
}

.af-card select.af-input option {
  color: var(--af-ink);
}

.af-card .af-field > label {
  position: absolute;
  left: 17px;
  top: 19px;
  margin: 0;
  max-width: calc(100% - 60px);
  font-size: 16px;
  font-weight: 400;
  color: var(--af-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.18s ease, color 0.18s ease;
}

.af-field.is-filled > label,
.af-field:focus-within > label {
  transform: translateY(-10px) scale(0.76);
}

.af-field:focus-within > label {
  color: var(--af-blue);
}

.af-field .af-state {
  position: absolute;
  right: 16px;
  top: 20px;
  font-size: 15px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.af-field.is-valid .af-state {
  opacity: 1;
  transform: none;
  color: var(--af-ok);
}

.af-field.has-select .af-state {
  right: 40px;
}

/* Erreurs */
.af-err {
  display: none;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--af-err);
}

.af-err::before {
  content: "\f06a";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 12px;
  margin-top: 1px;
}

.has-error > .af-err,
.has-error .af-err {
  display: flex;
}

.af-field.has-error .af-input {
  border-color: var(--af-err);
  background: #fff7f7;
}

.af-field.has-error > label {
  color: var(--af-err);
}

.has-error .af-shake,
.af-field.has-error {
  animation: afShake 0.32s;
}

@keyframes afShake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.af-hint {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--af-muted);
}

/* ---------- Segmenté (civilité, sexe conjoint) ---------- */
.af-seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--af-field);
  border-radius: var(--af-radius);
  border: 1.5px solid transparent;
}

.has-error .af-seg {
  border-color: var(--af-err);
}

.af-seg input,
.af-tiles input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.af-card .af-seg label {
  flex: 1;
  margin: 0;
  max-width: none;
  text-align: center;
  padding: 11px 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--af-muted);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
  user-select: none;
}

.af-card .af-seg label:hover {
  color: var(--af-ink);
}

.af-seg input:checked + label {
  background: #fff;
  color: var(--af-blue);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(13, 19, 23, 0.1);
}

.af-seg input:focus-visible + label,
.af-tiles input:focus-visible + label {
  outline: 2px solid var(--af-blue);
  outline-offset: 2px;
}

/* ---------- Tuiles (situation familiale) ---------- */
.af-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-radius: var(--af-radius);
}

.af-card .af-tiles label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  margin: 0;
  max-width: none;
  padding: 8px;
  text-align: center;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--af-ink);
  background: #fff;
  border: 1.5px solid var(--af-line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, color 0.2s, transform 0.15s;
  user-select: none;
}

.af-card .af-tiles label:hover {
  border-color: #b5c6e6;
}

.af-card .af-tiles label:active {
  transform: scale(0.97);
}

.af-tiles input:checked + label {
  border-color: var(--af-blue);
  background: var(--af-blue-soft);
  color: var(--af-blue);
  font-weight: 700;
}

.has-error .af-tiles label {
  border-color: #f1b7b7;
}

/* ---------- Bloc conjoint (repliable) ---------- */
.af-collapse {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.af-collapse > div {
  overflow: hidden;
}

.af-collapse.is-open {
  grid-template-rows: 1fr;
}

.af-sub {
  margin-top: 14px;
  padding: 16px 16px 2px;
  border-radius: 16px;
  background: #fbfcff;
  border: 1px dashed #c9d6ee;
}

.af-sub-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--af-ink);
}

.af-sub-title i {
  color: var(--af-blue);
}

.af-sub .af-input {
  background-color: #fff;
  border-color: var(--af-line);
}

/* ---------- Compteur enfants ---------- */
.af-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 10px 10px 16px;
  background: var(--af-field);
  border-radius: var(--af-radius);
}

.af-counter-label {
  font-size: 15px;
  font-weight: 500;
}

.af-counter-label small {
  display: block;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--af-muted);
}

.af-counter-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}

.af-card .af-round {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--af-line);
  background: #fff;
  color: var(--af-ink);
  font-size: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, opacity 0.2s;
  padding: 0;
}

.af-card .af-round:hover:not(:disabled) {
  border-color: var(--af-blue);
  color: var(--af-blue);
}

.af-card .af-round:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.af-card #nbEnfants {
  width: 34px;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--af-ink);
  padding: 0;
  -moz-appearance: textfield;
  pointer-events: none;
}

.af-card #nbEnfants::-webkit-inner-spin-button,
.af-card #nbEnfants::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#enfantsFields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
  margin-top: 14px;
}

#enfantsFields .af-field {
  animation: afIn 0.3s ease;
}

/* ---------- Suggestions de villes ---------- */
.af-cities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 14px;
}

.af-card .af-cities button {
  border: 1.5px solid var(--af-line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--af-ink);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.af-card .af-cities button:hover,
.af-card .af-cities button.is-picked {
  border-color: var(--af-blue);
  color: var(--af-blue);
}

/* ---------- Téléphone ---------- */
.af-card .af-tel .af-input {
  padding-left: 96px;
}

.af-card .af-tel > label {
  left: 97px;
}

.af-prefix {
  position: absolute;
  left: 8px;
  top: 8px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--af-ink);
  background: #fff;
  border-radius: 9px;
  box-shadow: 0 1px 3px rgba(13, 19, 23, 0.08);
  pointer-events: none;
}

.af-flag {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(90deg, #1f3fa8 0 33.3%, #fff 33.3% 66.6%, #e1323b 66.6%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* ---------- Navigation ---------- */
.af-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}

.af-card .af-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 56px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--af-radius);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.15s, box-shadow 0.2s, color 0.2s;
}

.af-card .af-btn:focus-visible {
  outline: 3px solid rgba(24, 103, 255, 0.4);
  outline-offset: 2px;
}

.af-card .af-btn-main {
  flex: 1;
  color: #fff;
  background: var(--af-blue);
  box-shadow: 0 10px 22px -8px rgba(24, 103, 255, 0.7);
  position: relative;
  overflow: hidden;
}

.af-card .af-btn-main:hover:not(:disabled) {
  background: var(--af-blue-dark);
  transform: translateY(-1px);
}

.af-card .af-btn-main:active:not(:disabled) {
  transform: translateY(1px);
}

.af-card .af-btn-main i {
  transition: transform 0.2s;
}

.af-card .af-btn-main:hover i.fa-arrow-right {
  transform: translateX(3px);
}

.af-card .af-btn-back {
  width: 56px;
  padding: 0;
  flex: 0 0 56px;
  color: var(--af-ink);
  background: var(--af-field);
}

.af-card .af-btn-back:hover {
  background: #e8edf6;
}

.af-card .af-btn-back[hidden],
.af-card .af-btn[hidden] {
  display: none;
}

.af-card .sub.btn-success {
  background: var(--af-ok);
  box-shadow: 0 10px 22px -8px rgba(15, 157, 107, 0.7);
}

.af-card .sub.btn-success:hover:not(:disabled) {
  background: #0b855a;
}

.af-card .af-btn:disabled {
  cursor: progress;
  opacity: 0.85;
}

.af-spin {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: afSpin 0.7s linear infinite;
}

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

.af-trust {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  color: var(--af-muted);
}

.af-trust li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.af-trust i {
  color: var(--af-ok);
}

.af-consent {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: #8592ad;
}

/* ---------- Message serveur ---------- */
.af-card .success-form {
  display: none;
  padding: 0;
  margin-top: 16px;
  float: none;
  width: auto;
}

.af-card .success-form .alert {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 0;
  font-size: 14px;
  line-height: 1.45;
}

.af-card .success-form .alert-danger {
  background: #fff1f1;
  color: #a12626;
}

.af-card .success-form .alert-warning {
  background: #fff8e8;
  color: #8a5a00;
}

/* ---------- Écran de succès ---------- */
.af-done {
  display: none;
  text-align: center;
  padding: 44px 30px 46px;
}

.af-card.is-sent .af-head,
.af-card.is-sent .form-body {
  display: none;
}

.af-card.is-sent .af-done {
  display: block;
  animation: afIn 0.45s ease;
}

.af-check {
  width: 84px;
  height: 84px;
  margin: 0 auto 22px;
}

.af-check circle {
  fill: none;
  stroke: var(--af-ok);
  stroke-width: 3;
  stroke-dasharray: 240;
  stroke-dashoffset: 240;
  animation: afDraw 0.6s ease forwards;
}

.af-check path {
  fill: none;
  stroke: var(--af-ok);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: afDraw 0.4s 0.5s ease forwards;
}

@keyframes afDraw {
  to { stroke-dashoffset: 0; }
}

.af-done h3 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}

.af-done p {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--af-muted);
  max-width: 34ch;
  margin: 0 auto;
}

.af-done-call {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--af-blue-soft);
  color: var(--af-blue);
  font-size: 14px;
  font-weight: 500;
}

/* ---------- Responsive ---------- */
@media (max-width: 1300px) {
  .form-container.af-card {
    flex: 1 1 100%;
    max-width: 560px;
    margin: 24px auto 0;
  }
}

@media (max-width: 520px) {
  .form-container.af-card {
    border-radius: 20px;
  }

  .af-head {
    padding: 22px 20px 0;
  }

  .af-card .form-body {
    padding: 20px 20px 22px;
  }

  .af-card .af-title {
    font-size: 22px;
  }

  .af-row,
  .af-row.af-row-cp {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .af-tiles {
    grid-template-columns: repeat(2, 1fr);
  }

  #enfantsFields {
    grid-template-columns: 1fr;
  }

  .af-card .af-seg label {
    font-size: 14px;
    padding: 11px 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .af-card *,
  .af-card *::before,
  .af-card *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }

  .af-check circle,
  .af-check path {
    stroke-dashoffset: 0;
  }
}
