.btn {
  display: inline-block;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  font-size: 1rem;
}

.btn[hidden] {
  display: none;
}

.btn--primary {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.btn--primary:hover {
  background: var(--color-accent-dark);
}

.btn--primary:focus-visible {
  outline: 2px solid var(--color-navy);
  outline-offset: 2px;
}

.btn--small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn--secondary {
  background: transparent;
  color: var(--color-navy);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-bg-alt);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.form-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: 0 20px 40px rgba(11, 31, 58, 0.06);
  margin-top: var(--space-3);
}

.form-alert {
  background: #fdecea;
  border: 1px solid #d0342c;
  border-radius: var(--radius-sm);
  color: #d0342c;
  padding: var(--space-2);
  margin-bottom: var(--space-3);
}

.form-alert--success {
  background: #e6f4ea;
  border-color: #1f7a3d;
  color: #1f7a3d;
}

.required {
  color: #d0342c;
}

.form-nav {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Précédent stays wherever it naturally falls (left, first in DOM order);
   the forward action (Suivant or the final Envoyer ma demande, never both
   visible at once) is pushed to the right via auto margin instead of relying
   on justify-content, so this still looks right on step 1 where Précédent
   is hidden and there's only one button to place. */
.form-nav #form-next,
.form-nav #form-submit {
  margin-left: auto;
}

.form-recap {
  list-style: none;
  padding: var(--space-3);
  margin: 0;
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.5rem;
}

.form-recap li {
  display: flex;
  gap: 0.4rem;
}

.form-recap-section {
  margin-bottom: var(--space-3);
}

.form-recap-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.form-recap-section__header h3 {
  margin: 0;
  font-size: 1rem;
}

.btn-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--color-primary-dark);
}

.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: var(--space-2);
}

.field[hidden] {
  display: none;
}

.field label {
  font-weight: 600;
  font-size: 0.9rem;
}

.field input,
.field select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  /* Explicit white background: without this, native controls (most
     visibly <select> and <input type="date"> on Safari/iOS) fall back
     to the platform's own control chrome, which renders as light grey
     even though the field is enabled and editable. */
  background-color: var(--color-bg);
}

.field select {
  /* Reset native select chrome (which is what was pulling in Safari's
     grey system background) and draw our own chevron so the field
     still reads as a dropdown. */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235b6472' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='5.5 8 10 12.5 14.5 8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px;
  padding-right: 2.25rem;
}

.field input[type="file"] {
  /* Safari/iOS doesn't reliably stretch file inputs to fill a flex
     column parent the way it does other inputs, so it renders at its
     native (button + filename) content width instead. */
  width: 100%;
}

.field input:hover:not(:disabled):not([readonly]),
.field select:hover:not(:disabled) {
  border-color: var(--color-text-muted);
}

.field input:focus-visible,
.field select:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(36, 87, 255, 0.15);
}

.field input:disabled,
.field select:disabled,
.field input[readonly] {
  background-color: var(--color-bg-alt);
  color: var(--color-text-muted);
  border-color: var(--color-border);
  cursor: not-allowed;
}

.field--error input,
.field--error select {
  border-color: #d0342c;
}

.autocomplete-wrapper {
  position: relative;
}

.autocomplete-wrapper input {
  /* The input is no longer a direct flex child of .field once wrapped,
     so it no longer gets .field's stretch-to-fill behavior for free. */
  width: 100%;
}

.autocomplete-list {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.1), 0 2px 4px rgba(16, 24, 40, 0.06);
}

.autocomplete-list[hidden] {
  display: none;
}

.autocomplete-option {
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
}

.autocomplete-option:hover,
.autocomplete-option.is-active {
  background: var(--color-primary-tint);
}

.field__error {
  color: #d0342c;
  font-size: 0.85rem;
}

.field__hint {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin: 0;
}

fieldset.field {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-2);
}

fieldset.field legend {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0;
  margin-bottom: 0.5rem;
  line-height: 1.3;
  min-height: 2.6em;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.radio-option:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-bg-alt);
}

.radio-option input[type="radio"] {
  flex-shrink: 0;
  width: auto;
}

.checkbox-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 0.6rem;
}

.checkbox-option input[type="checkbox"] {
  flex-shrink: 0;
  width: auto;
  margin-top: 0.2rem;
}

.signature-pad {
  display: block;
  width: 100%;
  max-width: 600px;
  height: 180px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  touch-action: none;
  cursor: crosshair;
}

.signature-handoff {
  margin-top: var(--space-2);
}

.signature-handoff__panel {
  margin-top: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  text-align: center;
}

.signature-handoff__panel img {
  display: block;
  margin: 0 auto var(--space-2);
}

.signature-handoff__status {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0;
}

.grid {
  display: grid;
  gap: var(--space-3);
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

@media (max-width: 768px) {
  .grid--3, .grid--2 {
    /* minmax(0, 1fr), not a bare 1fr: a single-track 1fr column still
       carries an automatic minimum width equal to its widest item's
       min-content size. The phone country <select> (200+ options,
       e.g. "République démocratique du Congo") has a huge min-content
       width, which was blowing this column — and everything sharing
       it (Pays, Téléphone, Langue) — out past the card and viewport. */
    grid-template-columns: minmax(0, 1fr);
  }
}

details.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-2) 0;
}

details.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-navy);
  list-style: none;
}

details.faq-item summary::-webkit-details-marker {
  display: none;
}

details.faq-item summary::before {
  content: "+";
  display: inline-block;
  width: 1.2rem;
  color: var(--color-navy);
  font-weight: 700;
}

details.faq-item[open] summary::before {
  content: "–";
}

.badge {
  display: inline-block;
  background: var(--color-primary-tint);
  color: var(--color-primary-dark);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge--accent {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  margin-bottom: var(--space-1);
}

.badge--success {
  background: #e3f6ec;
  color: #1c7c4d;
}

.badge--danger {
  background: #fdecea;
  color: #b3261e;
}

/* Cookie consent banner */
.cookie-banner {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 60;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -10px 30px rgba(11, 31, 58, 0.08);
}

.cookie-banner__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-3);
}

.cookie-banner__text {
  flex: 1 1 320px;
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.cookie-banner__text a {
  color: var(--color-primary);
  font-weight: 600;
}

.cookie-banner__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.footer-cookie-settings {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.footer-cookie-settings:hover {
  text-decoration: underline;
}

.phone-field {
  display: flex;
  gap: 0.5rem;
  min-width: 0;
}

.phone-field input {
  flex: 1 1 auto;
  min-width: 0;
}

/* The native <select> itself is kept in the DOM as the real value/validity
   source (see country-select-widget.js's own top comment) but never shown —
   .country-select is what actually renders. */
.phone-field select.country-select__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.country-select {
  position: relative;
  flex: 0 0 auto;
}

.country-select__button {
  height: 100%;
  padding: 0.75rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg);
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
}

.country-select__button:hover {
  border-color: var(--color-text-muted);
}

.country-select__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  width: max(220px, 100%);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.1), 0 2px 4px rgba(16, 24, 40, 0.06);
  padding: 0.5rem;
}

.country-select__search {
  width: 100%;
  padding: 0.6rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  margin-bottom: 0.4rem;
}

.country-select__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
}

.country-select__option {
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
}

.country-select__option[hidden] {
  display: none;
}

.country-select__option:hover,
.country-select__option.is-active {
  background: var(--color-primary-tint);
}

/* Mobile hand-off: the trigger card above the ID upload/signature fields,
   and the popup it opens. */
.mobile-handoff-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  background: var(--color-primary-tint);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.mobile-handoff-card__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-primary);
}

.mobile-handoff-card__icon svg {
  width: 20px;
  height: 20px;
}

.mobile-handoff-card__text {
  flex: 1 1 auto;
  min-width: 0;
}

.mobile-handoff-card__text strong {
  display: block;
  font-size: 0.95rem;
  color: var(--color-text);
}

.mobile-handoff-card__text p {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.mobile-handoff-card .btn {
  flex: 0 0 auto;
}

/* Only applies when a .btn-group sits inside the card's text column (the
   step-5 recap's reuse of this card, which has no third flex-child button
   of its own) — the default step-4 QR variant has no .btn-group nested in
   its text at all, so this never affects that one. */
.mobile-handoff-card__text .btn-group {
  margin-top: var(--space-1);
}

@media (max-width: 640px) {
  .mobile-handoff-card {
    flex-wrap: wrap;
  }
  .mobile-handoff-card .btn {
    flex: 1 1 100%;
  }

  /* Scoped to the intake form's own step 4, not the step-5 recap's reuse
     of this same card (a static "your signed documents" summary, no QR
     trigger in it) — offering to continue "on your phone" makes no sense
     once the visitor is already filling this step out on their phone. */
  .form-step[data-step="4"] .mobile-handoff-card {
    display: none;
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 31, 58, 0.55);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  max-height: calc(100vh - 2 * var(--space-2));
  overflow-y: auto;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
  box-shadow: 0 25px 60px rgba(11, 31, 58, 0.3);
}

.modal__close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  background: var(--color-border);
}

.modal__panel h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.modal__panel p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.modal__panel img {
  display: block;
  margin: var(--space-2) auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* Success state shown inside the modal once the phone confirms — a
   distinct visual state (not just a status line) so it reads as "done",
   not as another loading step. */
.handoff-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1.5px solid var(--color-success);
  border-radius: var(--radius-md);
  background: #f0faf5;
}

/* .handoff-success sets display:flex unconditionally, which (being an
   author rule) overrides the browser's own [hidden]{display:none} default
   regardless of the hidden attribute still being present on the element —
   without this, a `hidden` box with this class stays visible the whole
   time. Only mobile.blade.php's success view combines `hidden` directly on
   the .handoff-success element itself (the desktop modal keeps them on
   separate elements, so it was never affected). */
.handoff-success[hidden] {
  display: none;
}

.handoff-success__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-success);
  color: #fff;
}

.handoff-success__icon svg {
  width: 26px;
  height: 26px;
}

.handoff-success p {
  margin: 0;
  color: var(--color-text);
  font-weight: 600;
}

.recap-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-success);
  color: #fff;
  margin-right: 5px;
  vertical-align: -3px;
}

.recap-check svg {
  width: 11px;
  height: 11px;
}

/* Live "À ajouter" / "Ajouté" state next to a document's label — on step
   4's own intro checklist and on the mobile hand-off page, wherever a
   document's status needs to read at a glance before the visitor scrolls
   down to the actual upload control. */
.doc-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.doc-status.is-done {
  color: var(--color-success);
}

.mobile-doc-preview {
  display: block;
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  margin-top: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* 5-segment phase progress bar, replacing the old per-step numbered
   stepper (removed once every wizard page adopted this bar instead). */
.form-phase-bar {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-4);
}

.form-phase-bar__segment {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  overflow: hidden;
}

.form-phase-bar__segment-fill {
  height: 100%;
  background: var(--color-accent);
  transition: width 0.3s ease;
}

.form-phase-bar__segment[data-state="complete"] .form-phase-bar__segment-fill {
  width: 100%;
}

.form-phase-bar__segment[data-state="upcoming"] .form-phase-bar__segment-fill {
  width: 0%;
}

.form-phase-bar__label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

/* Step-level error banners (progressive form engine, Tasks 13-15) — shown
   when a step's blocking backend submission fails (a 409 duplicate-email
   response for #contact-step-error, or a generic error for either banner),
   scoped to their own step rather than one shared form-wide banner. Reuses
   the same red already established by .field__error/.field--error above. */
.form-error-banner {
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  border: 1px solid #d0342c;
  border-radius: var(--radius-sm);
  background: rgba(208, 52, 44, 0.08);
  color: #d0342c;
}

.form-error-banner[hidden] {
  display: none;
}

.form-error-banner p {
  margin: 0;
}

.form-error-banner a[data-espace-client-link] {
  display: inline-block;
  margin-top: var(--space-2);
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
}

@media (max-width: 640px) {
  .form-phase-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-bg);
    padding: var(--space-2) 0;
    margin-bottom: var(--space-2);
  }

  .form-phase-bar__label {
    margin-bottom: var(--space-2);
  }
}
