/* ==========================================================================
   Form Multistep Diag Immo — Formulaire multi-etapes "Demande d'information"
   Tous les styles sont scopes sous .diag-immo-multi-step pour eviter les conflits theme.
   Mobile-first : styles de base = mobile, media queries = ecrans larges.
   ========================================================================== */

/* --- Reset & Base --- */
.diag-immo-multi-step {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  font-family: inherit;
  color: #1a1a1a;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.diag-immo-multi-step *,
.diag-immo-multi-step *::before,
.diag-immo-multi-step *::after {
  box-sizing: border-box;
}

/* Empecher le delai double-tap sur les elements interactifs */
.diag-immo-multi-step button,
.diag-immo-multi-step .cetm-card,
.diag-immo-multi-step .cetm-pill,
.diag-immo-multi-step label {
  touch-action: manipulation;
}

/* --- Barre de progression --- */
.cetm-progress {
  margin-bottom: 24px;
}

.cetm-progress__label {
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 8px;
}

.cetm-progress__bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.cetm-progress__fill {
  height: 100%;
  background: #4A90D9;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* --- Conteneur des etapes --- */
.cetm-steps {
  position: relative;
  overflow: hidden;
}

.cetm-step {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
  transform: translateX(40px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.cetm-step.is-active {
  position: relative;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.cetm-step.slide-out-left {
  transform: translateX(-40px);
  opacity: 0;
}

.cetm-step.slide-in-right {
  transform: translateX(40px);
  opacity: 0;
}

.cetm-step.slide-out-right {
  transform: translateX(40px);
  opacity: 0;
}

.cetm-step.slide-in-left {
  transform: translateX(-40px);
  opacity: 0;
}

/* --- Titre de la question --- */
.cetm-step__title {
  font-size: 19px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 20px;
  line-height: 1.3;
}

/* --- Etape 1 : utilise les memes classes .cetm-pill que les etapes 2-4 ---
   Le CSS specifique aux cards n'est plus necessaire sur mobile.
   Sur desktop, on surcharge dans le media query pour repasser en grille 4 colonnes. */

/* --- Choix pill/capsule (etapes 2-4) --- */
.cetm-pills {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cetm-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  background: #f0f4f8;
  border: 2px solid #d0dce8;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 450;
  color: #3a3a3a;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}

.cetm-pill:active {
  border-color: #4A90D9;
  background: #e8f0fb;
}

.cetm-pill.is-selected {
  border-color: #4A90D9;
  background: #e8f0fb;
  color: #4A90D9;
}

.cetm-pill__emoji {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

/* --- Champs de formulaire (etapes 5-6) --- */
.cetm-field {
  margin-bottom: 20px;
}

.cetm-field__label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.cetm-field__input {
  width: 100%;
  padding: 12px 14px;
  /* 16px minimum pour empecher le zoom auto iOS au focus */
  font-size: 16px;
  font-family: inherit;
  border: 2px solid #d0dce8;
  border-radius: 10px;
  outline: none;
  color: #1a1a1a;
  background: #fff;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.cetm-field__input:focus {
  border-color: #4A90D9;
}

.cetm-field__input.is-error {
  border-color: #e74c3c;
}

.cetm-field__error {
  font-size: 13px;
  color: #e74c3c;
  margin-top: 6px;
  display: none;
}

.cetm-field__error.is-visible {
  display: block;
}

/* --- Checkbox --- */
.cetm-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
  cursor: pointer;
  font-size: 14px;
  color: #4b5563;
  line-height: 1.4;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Zone de tap elargie */
  padding: 8px 0;
}

.cetm-checkbox input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 0;
  flex-shrink: 0;
  accent-color: #4A90D9;
  cursor: pointer;
}

.cetm-checkbox.is-error {
  color: #e74c3c;
}

/* --- Navigation --- */
.cetm-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  gap: 12px;
}

.diag-immo-multi-step .cetm-btn-prev {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  background: none !important;
  border: none !important;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280 !important;
  cursor: pointer;
  padding: 12px 4px;
  transition: color 0.2s;
  visibility: visible !important;
  opacity: 1 !important;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.diag-immo-multi-step .cetm-btn-prev:active {
  color: #4A90D9 !important;
}

.diag-immo-multi-step .cetm-btn-next {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px;
  background: #4A90D9 !important;
  color: #fff !important;
  border: none !important;
  border-radius: 10px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  width: 100%;
  max-width: 200px;
  margin-left: auto;
  visibility: visible !important;
  opacity: 1 !important;
}

.cetm-btn-next:active {
  background: #3a7bc8;
}

.cetm-btn-next:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Spinner de chargement */
.cetm-btn-next .cetm-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cetm-spin 0.6s linear infinite;
}

.cetm-btn-next.is-loading .cetm-spinner {
  display: inline-block;
}

.cetm-btn-next.is-loading .cetm-btn-text {
  display: none;
}

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

/* --- Etape 7 : Confirmation --- */
.cetm-confirmation {
  text-align: center;
  padding: 20px 0;
}

.cetm-confirmation__icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.cetm-confirmation__title {
  font-size: 21px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.cetm-confirmation__text {
  font-size: 15px;
  color: #6b7280;
  line-height: 1.5;
}

/* ==========================================================================
   Responsive — ecrans plus larges (tablettes, desktop)
   ========================================================================== */

@media (min-width: 481px) {
  .diag-immo-multi-step {
    padding: 24px 24px 40px;
  }

  .cetm-progress {
    margin-bottom: 32px;
  }

  .cetm-step__title {
    font-size: 22px;
    margin-bottom: 24px;
  }

  /* Etape 1 desktop : grille 4 colonnes avec icone au-dessus */
  [data-step="1"] .cetm-pills {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  [data-step="1"] .cetm-pill {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 12px 18px;
    background: #f8f9fb;
    border-radius: 12px;
    min-height: 88px;
    font-size: 14px;
    text-align: center;
  }

  [data-step="1"] .cetm-pill__emoji {
    font-size: 36px;
  }

  [data-step="1"] .cetm-pill:hover {
    transform: translateY(-2px);
  }

  .cetm-pill {
    padding: 14px 18px;
  }

  .cetm-pill:hover {
    border-color: #4A90D9;
    background: #f0f5fc;
  }

  .cetm-btn-prev:hover {
    color: #4A90D9;
  }

  .cetm-btn-next {
    width: auto;
    max-width: none;
    min-width: 160px;
    padding: 14px 32px;
  }

  .cetm-btn-next:hover {
    background: #3a7bc8;
  }

  .cetm-confirmation__icon {
    font-size: 56px;
  }

  .cetm-confirmation__title {
    font-size: 24px;
  }
}

/* Petits ecrans (iPhone SE, 320px) */
@media (max-width: 360px) {
  .diag-immo-multi-step {
    padding: 12px 10px 28px;
  }

  .cetm-step__title {
    font-size: 17px;
    margin-bottom: 16px;
  }

  .cetm-pill {
    padding: 12px 12px;
    font-size: 14px;
    gap: 8px;
  }

  .cetm-pill__emoji {
    font-size: 18px;
  }

  .cetm-field__label {
    font-size: 14px;
  }

  .cetm-checkbox {
    font-size: 13px;
  }
}
