/* ═══════════════════════════════════════════════════
   DM Search Form — Frontend Styles v2.3
   Aération formulaire + API villes gouvernement
═══════════════════════════════════════════════════ */

:root {
  --dmf-bg:               #f9f9fb;
  --dmf-card:             #ffffff;
  --dmf-text:             #111827;
  --dmf-muted:            #6b7280;
  --dmf-border:           #e5e7eb;
  --dmf-accent:           #111827;
  --dmf-accent-hover:     #000000;
  --dmf-success:          #10b981;
  --dmf-error:            #ef4444;
  --dmf-radius:           18px;
  --dmf-radius-sm:        12px;
  --dmf-shadow:           0 4px 28px rgba(0,0,0,.07);
  --dmf-chip-active-bg:   #111827;
  --dmf-chip-active-text: #fff;
  --dmf-transition:       0.18s ease;
  --dmf-section-gap:      24px;  /* espacement entre sections */
}

.dmsf-wrapper * { box-sizing: border-box; }
.dmsf-wrapper {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
  font-family: inherit;
}

/* ══ PAGE SUCCÈS ════════════════════════════════════ */
.dmsf-success-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  z-index: 999999; display: flex; align-items: center;
  justify-content: center; padding: 16px;
  backdrop-filter: blur(6px); animation: dmfFadeIn .4s ease;
}
.dmsf-success-box {
  background: #fff; border-radius: 22px; max-width: 520px; width: 100%;
  padding: 52px 44px; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
  animation: dmfSlideUp .5s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.dmsf-success-icon {
  width: 76px; height: 76px; background: #f0fdf4; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 26px; font-size: 38px;
}
.dmsf-success-title { font-size: 24px; font-weight: 800; color: #111827; margin: 0 0 14px; line-height: 1.2; }
.dmsf-success-text  { font-size: 15px; color: #4b5563; line-height: 1.7; margin: 0 0 22px; }
.dmsf-success-recap {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 16px 20px; margin: 0 0 22px; text-align: left;
}
.dmsf-success-recap-row { display: flex; gap: 10px; margin-bottom: 8px; font-size: 14px; }
.dmsf-success-recap-row:last-child { margin: 0; }
.dmsf-success-recap-label { font-weight: 700; color: #374151; min-width: 90px; }
.dmsf-success-recap-val   { color: #4b5563; }
.dmsf-success-sign  { font-size: 13px; color: #9ca3af; font-style: italic; }
.dmsf-success-close {
  position: absolute; top: 16px; right: 16px;
  background: #f3f4f6; border: 1.5px solid #e5e7eb;
  border-radius: 8px; width: 38px; height: 38px;
  cursor: pointer; color: #374151;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; padding: 0;
}
.dmsf-success-close svg { display: block; pointer-events: none; }
.dmsf-success-close:hover { background: #111827; border-color: #111827; color: #fff; }
@media (max-width: 480px) {
  .dmsf-success-box { padding: 40px 20px; }
  .dmsf-success-title { font-size: 20px; }
}

/* ══ PROGRESS BAR STICKY ════════════════════════════ */
.dmsf-progress {
  position: sticky;
  top: var(--dmsf-sticky-top, 0px);
  z-index: 200;
  background: rgba(255,255,255,.98);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px 16px 10px;
  margin: 0 -16px 28px;
  border-bottom: 1px solid var(--dmf-border);
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.dmsf-progress-bar {
  height: 3px; background: #e5e7eb; border-radius: 99px;
  overflow: hidden; margin-bottom: 10px;
}
.dmsf-progress-fill {
  height: 100%; background: #111827; border-radius: 99px;
  transition: width 0.45s cubic-bezier(.4,0,.2,1);
}
.dmsf-progress-steps { display: flex; justify-content: space-between; }
.dmsf-step-label {
  font-size: 11px; font-weight: 600; color: #9ca3af;
  display: flex; align-items: center; gap: 5px;
  transition: color 0.2s; white-space: nowrap;
}
.dmsf-step-label-text { display: inline; }
.dmsf-step-label::before {
  content: attr(data-step);
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: #e5e7eb; color: #9ca3af;
  font-size: 10px; font-weight: 700;
  transition: background 0.2s, color 0.2s; flex-shrink: 0;
}
.dmsf-step-label.active { color: #111827; }
.dmsf-step-label.active::before { background: #111827; color: #fff; }
.dmsf-step-label.done::before   { background: #10b981; color: #fff; content: '✓'; }
@media (max-width: 500px) {
  .dmsf-step-label-text { display: none; }
  .dmsf-step-label { font-size: 0; }
  .dmsf-step-label::before { font-size: 10px; width: 24px; height: 24px; }
}

/* ══ CARD ════════════════════════════════════════════ */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--dmf-radius);
  box-shadow: var(--dmf-shadow);
  padding: 32px;
  animation: dmfFadeSlide .3s ease both;
}
@keyframes dmfFadeSlide {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dmfFadeIn  { from { opacity: 0; }            to { opacity: 1; }             }
@keyframes dmfSlideUp { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 600px) { .card { padding: 20px 16px; } }

/* ══ STEP HEADER ═════════════════════════════════════ */
.dmf-step-header {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 28px; padding-bottom: 22px;
  border-bottom: 1px solid #f3f4f6;
}
.dmf-step-badge {
  flex-shrink: 0; width: 44px; height: 44px;
  background: #111827; color: #fff; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; letter-spacing: -.5px;
}
.dmf-step-header h2 {
  margin: 0 0 4px; font-size: 20px; color: #111827;
  font-weight: 800; line-height: 1.2;
}
.dmf-step-desc { margin: 0; font-size: 13px; color: #6b7280; line-height: 1.5; }
.dmf-optional { font-size: 12px; font-weight: 400; color: #9ca3af; }

/* ══ SÉPARATEURS DE SECTION ══════════════════════════ */
.dmf-section-block {
  margin-top: var(--dmf-section-gap);
  padding-top: var(--dmf-section-gap);
  border-top: 1px solid #f3f4f6;
}
.dmf-section-block:first-child { margin-top: 0; padding-top: 0; border-top: none; }

/* ══ GRID ════════════════════════════════════════════ */
.dmf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dmf-grid-3 { grid-template-columns: repeat(3, 1fr); }
.dmf-full { grid-column: 1 / -1; }
@media (max-width: 600px) {
  .dmf-grid, .dmf-grid-3 { grid-template-columns: 1fr; gap: 14px; }
}

/* ══ FIELDS ══════════════════════════════════════════ */
.dmf-field { display: flex; flex-direction: column; gap: 7px; }
.dmf-field + .dmf-field { margin-top: 4px; }

.dmf-field label,
.dmf-section-title {
  display: block;
  font-size: 11px; font-weight: 700; color: #374151;
  letter-spacing: .06em; text-transform: uppercase;
}
.dmf-section-title { margin: 0 0 10px; }
.dmf-sub-label {
  display: block; font-size: 13px; font-weight: 600;
  color: #374151; margin-bottom: 8px; letter-spacing: 0;
}

input[type=text], input[type=tel], input[type=email],
input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 13px 15px;
  border: 1.5px solid #e5e7eb; border-radius: var(--dmf-radius-sm);
  background: #fff; color: #111827; font-size: 15px;
  outline: none; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
input:focus, select:focus, textarea:focus {
  border-color: #111827; box-shadow: 0 0 0 3px rgba(17,24,39,.08);
}
input::placeholder, textarea::placeholder { color: #c4c9d4; }
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.dmf-hint { font-size: 12px; color: #6b7280; margin-top: 4px; line-height: 1.5; }
@media (max-width: 600px) {
  input[type=text], input[type=tel], input[type=email],
  input[type=number], select, textarea { font-size: 16px; padding: 14px 13px; }
}

/* ══ ERREURS ═════════════════════════════════════════ */
.dmf-error { font-size: 12px; color: #ef4444; min-height: 16px; font-weight: 500; }
.dmf-field input.is-invalid, .dmf-field select.is-invalid { border-color: #ef4444; }

/* ══ CHIPS ═══════════════════════════════════════════ */
.dmf-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dmf-chips-type { gap: 10px; }
.dmf-chips-sm { gap: 6px; }

.dmf-radio-chip, .dmf-check-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border: 1.5px solid #e5e7eb;
  border-radius: 999px; background: #fff; cursor: pointer;
  font-size: 13.5px; font-weight: 500; color: #111827;
  transition: all 0.18s; user-select: none; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.dmf-radio-chip:hover, .dmf-check-chip:hover {
  border-color: #9ca3af; background: #f9fafb;
}
.dmf-radio-chip input, .dmf-check-chip input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.dmf-radio-chip:has(input:checked), .dmf-check-chip:has(input:checked) {
  background: #111827; color: #fff; border-color: #111827;
}
.dmf-chip-selected { background: #111827 !important; color: #fff !important; border-color: #111827 !important; }

/* Type chips */
.dmf-chip-type {
  flex-direction: column; text-align: center;
  padding: 16px 14px; border-radius: 14px;
  font-size: 12.5px; line-height: 1.3; min-width: 84px;
}
.dmf-chip-type span { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 26px; }
@media (max-width: 500px) {
  .dmf-chip-type { min-width: 72px; padding: 12px 10px; font-size: 11.5px; }
  .dmf-chip-type span { font-size: 22px; }
}
.dmf-check-chip--standalone { width: 100%; border-radius: 14px; padding: 11px 16px; }

/* Consent */
.dmf-consent-label {
  display: flex; gap: 12px; align-items: flex-start;
  cursor: pointer; font-size: 14px; color: #374151; line-height: 1.6;
}
.dmf-consent-label input {
  margin-top: 3px; flex-shrink: 0; accent-color: #111827; width: 17px; height: 17px;
}
.dmf-consent-label a { color: #111827; font-weight: 600; }
.dmf-conditional[hidden] { display: none !important; }

/* ══ STEP FOOTER ═════════════════════════════════════ */
.dmf-step-footer {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 32px; padding-top: 24px;
  border-top: 1px solid #f3f4f6;
}

/* ══ BOUTONS ═════════════════════════════════════════ */
.dmf-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 24px; border-radius: var(--dmf-radius-sm);
  font-size: 14px; font-weight: 700; cursor: pointer;
  border: 2px solid transparent; transition: all 0.18s;
  font-family: inherit; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.dmf-btn:disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

.dmf-btn-ghost {
  background: #fff; color: #374151; border-color: #d1d5db;
}
.dmf-btn-ghost:hover:not(:disabled) { background: #f9fafb; color: #111827; border-color: #9ca3af; }
.dmf-btn-ghost:active:not(:disabled) { background: #f3f4f6; }

.dmf-btn-primary {
  background: #111827; color: #fff; border-color: #111827;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.dmf-btn-primary:hover:not(:disabled) {
  background: #000; border-color: #000;
  box-shadow: 0 4px 16px rgba(0,0,0,.28);
  transform: translateY(-1px);
}
.dmf-btn-primary:active:not(:disabled) {
  background: #1f2937; transform: translateY(0); box-shadow: none;
}
@media (max-width: 500px) { .dmf-btn { padding: 12px 18px; font-size: 13.5px; } }

/* ══ MODAL ═══════════════════════════════════════════ */
.dmf-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 12px; z-index: 99999;
  backdrop-filter: blur(4px); animation: dmfFadeIn .2s ease;
}
.dmf-modal[hidden] { display: none; }
.dmf-modal-box {
  max-width: 700px; width: 100%; background: #fff;
  border-radius: var(--dmf-radius); box-shadow: 0 24px 80px rgba(0,0,0,.3);
  overflow: hidden; animation: dmfSlideUp .3s cubic-bezier(.4,0,.2,1);
  max-height: 94vh; display: flex; flex-direction: column;
}
.dmf-modal-header {
  background: #111827; color: #fff; padding: 18px 22px;
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.dmf-modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
.dmf-modal-close {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; padding: 0;
}
.dmf-modal-close svg { pointer-events: none; }
.dmf-modal-close:hover { background: rgba(255,255,255,.25); }
.dmf-modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.dmf-modal-intro { margin: 0 0 14px; font-size: 13px; color: #6b7280; line-height: 1.5; }
.dmf-modal-footer {
  padding: 16px 22px; display: flex; justify-content: flex-end;
  gap: 10px; border-top: 1px solid #e5e7eb; background: #fafafa; flex-shrink: 0;
}
.dmf-summary table { width: 100%; border-collapse: collapse; }
.dmf-summary td { padding: 9px 12px; font-size: 13px; vertical-align: top; border-bottom: 1px solid #e5e7eb; }
.dmf-summary td:first-child { background: #f9fafb; font-weight: 700; color: #111827; width: 38%; }
.dmf-summary tr:last-child td { border-bottom: none; }
.dmf-summary .dmf-summary-section {
  background: #111827 !important; color: #fff !important;
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  padding: 6px 12px; font-weight: 700;
}

/* ══ AUTOCOMPLETE VILLES (API gouv.fr) ══════════════ */
.dmsf-city-wrapper { position: relative; }
.dmsf-city-input-row {
  display: flex; flex-wrap: wrap; gap: 7px;
  min-height: 52px; padding: 9px 12px;
  border: 1.5px solid #e5e7eb; border-radius: var(--dmf-radius-sm);
  background: #fff; cursor: text; align-items: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.dmsf-city-input-row:focus-within {
  border-color: #111827; box-shadow: 0 0 0 3px rgba(17,24,39,.08);
}
/* Tag commune sélectionnée */
.dmsf-city-tag {
  display: inline-flex; align-items: center; gap: 7px;
  background: #111827; color: #fff; border-radius: 999px;
  padding: 6px 8px 6px 13px; font-size: 13px; font-weight: 600; white-space: nowrap;
  max-width: 200px;
}
.dmsf-city-tag-name { overflow: hidden; text-overflow: ellipsis; }
.dmsf-city-tag-remove {
  background: rgba(255,255,255,.18);
  border: none; color: #fff;
  width: 24px; height: 24px; border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; flex-shrink: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  /* Grande zone de clic tactile */
  min-width: 24px; min-height: 24px;
  touch-action: manipulation;
}
.dmsf-city-tag-remove svg { display: block; pointer-events: none; }
.dmsf-city-tag-remove:hover,
.dmsf-city-tag-remove:focus-visible { background: rgba(255,255,255,.45); outline: none; }

/* Input de saisie dans le tag-input */
.dmsf-city-typing {
  border: none; outline: none; font-size: 15px; font-family: inherit;
  color: #111827; flex: 1; min-width: 140px;
  background: transparent; padding: 3px 4px;
}
@media (max-width: 600px) { .dmsf-city-typing { font-size: 16px; min-width: 100px; } }
.dmsf-city-typing::placeholder { color: #c4c9d4; }

/* Dropdown suggestions */
.dmsf-city-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1.5px solid #e5e7eb; border-radius: var(--dmf-radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,.13); z-index: 1000;
  max-height: 260px; overflow-y: auto; display: none;
}
.dmsf-city-dropdown.open { display: block; }

/* Option dans le dropdown */
.dmsf-city-option {
  padding: 11px 16px; font-size: 14px; cursor: pointer;
  color: #111827; transition: background 0.1s;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #f3f4f6;
}
.dmsf-city-option:last-child { border-bottom: none; }
.dmsf-city-option:hover,
.dmsf-city-option.highlighted { background: #f3f4f6; }
.dmsf-city-option-main { flex: 1; }
.dmsf-city-option-name { font-weight: 600; }
.dmsf-city-option-cp   { font-size: 12px; color: #6b7280; margin-top: 1px; }
.dmsf-city-dept {
  font-size: 11px; color: #9ca3af; background: #f3f4f6;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  flex-shrink: 0;
}
.dmsf-city-empty {
  padding: 14px 16px; font-size: 13px; color: #6b7280; font-style: italic;
  display: flex; align-items: center; gap: 8px;
}

/* Statut chargement */
.dmsf-city-loading {
  padding: 12px 16px; font-size: 13px; color: #6b7280;
  display: flex; align-items: center; gap: 10px;
}
.dmsf-city-spinner {
  width: 16px; height: 16px; border: 2px solid #e5e7eb;
  border-top-color: #111827; border-radius: 50%;
  animation: dmfSpin .7s linear infinite; flex-shrink: 0;
}
@keyframes dmfSpin { to { transform: rotate(360deg); } }

.dmsf-city-hint { font-size: 12px; color: #6b7280; margin-top: 6px; line-height: 1.5; }

/* ══ NOTICE (fallback) ═══════════════════════════════ */
.dmsf-notice {
  max-width: 860px; margin: 0 auto 18px; padding: 13px 20px;
  border-radius: var(--dmf-radius-sm); font-size: 14px; font-weight: 500;
}
.dmsf-notice-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.dmsf-notice-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
