/* ============================================================
   Facture-X — Tunnel de souscription (styles)
   Extrait de app/globals.css (app source Next). N'inclut QUE les règles
   utilisées par subscription-form.tsx (pas la landing marketing).

   Lot 4 : les tokens de design sont scopés sur #fx-tunnel-root pour ne PAS
   polluer le thème WordPress. La plupart des classes sont spécifiques au tunnel
   (offer-*, stepper-*, deployment-*, form-*…) ; les noms partagés avec WP/Elementor
   (.button, .card et variantes) sont explicitement scopés sous #fx-tunnel-root.
   Les polices (Fraunces / Inter / IBM Plex Mono) sont enqueue par le widget (Lot 5) ;
   ici on ne fait que référencer les familles.
   ============================================================ */

#fx-tunnel-root {
  /* Palette (valeurs reprises de globals.css :root) */
  --color-brand-gold-700: #8c7430;
  --color-brand-gold-500: #b1963e;
  --color-brand-gold-100: #efe7d4;
  --color-brand-plum-700: #14110d;
  --color-brand-plum-600: #2a251c;
  --color-brand-plum-500: #6b6862;
  --color-brand-plum-100: #f3efe4;
  --color-neutral-900: #14110d;
  --color-neutral-700: #6b6862;
  --color-neutral-500: #8f8b80;
  --color-neutral-200: #e7e2d4;
  --color-neutral-100: #f7f5ee;
  --color-neutral-000: #ffffff;
  --color-success-500: #1f7a4d;
  --color-error-500: #b42318;

  --shadow-sm: 0 1px 2px rgba(20, 17, 13, 0.05);
  --shadow-md: 0 8px 24px rgba(20, 17, 13, 0.07);
  --shadow-lg: 0 18px 44px rgba(20, 17, 13, 0.10);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;

  --card-background: #ffffff;
  --card-muted-background: #f7f5ee;
  --card-border: #e7e2d4;

  --button-primary-bg: #b1963e;
  --button-primary-border: #b1963e;
  --button-primary-fg: #14110d;
  --button-primary-hover-bg: #9d8133;
  --button-primary-hover-fg: #14110d;

  /* Polices (familles uniquement ; @font-face / Google Fonts gérés par le widget Lot 5) */
  --font-fraunces: 'Fraunces', Georgia, serif;
  --font-inter: 'Inter', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  color: var(--color-neutral-900);
  font-family: var(--font-inter);
  font-size: 16px;
  line-height: 1.625;
}

#fx-tunnel-root *,
#fx-tunnel-root *::before,
#fx-tunnel-root *::after {
  box-sizing: border-box;
}

/* --- Typo utilitaire --- */
.font-display {
  font-family: var(--font-fraunces);
}

/* --- Boutons --- */
/* .button / .card sont des noms partagés avec WP/Elementor : on les scope
   sous #fx-tunnel-root pour ne pas déformer le reste de la page. */
#fx-tunnel-root .button {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 999px;
  font-weight: 800;
  line-height: 1;
  padding: 0 22px;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
  cursor: pointer;
}

#fx-tunnel-root .button-primary {
  border: 1px solid var(--button-primary-border);
  background: var(--button-primary-bg);
  color: var(--button-primary-fg);
  box-shadow: var(--shadow-md);
}

#fx-tunnel-root .button-primary:hover {
  background: var(--button-primary-hover-bg);
  border-color: var(--button-primary-hover-bg);
  color: var(--button-primary-hover-fg);
  transform: translateY(-1px);
}

#fx-tunnel-root .button-secondary {
  border: 1px solid rgba(13, 13, 13, 0.14);
  background: rgba(255, 255, 255, 0.82);
  color: var(--color-neutral-900);
}

#fx-tunnel-root .button-secondary:hover {
  border-color: rgba(87, 44, 138, 0.34);
  background: var(--color-neutral-000);
  color: var(--color-brand-plum-700);
  transform: translateY(-1px);
}

/* --- Carte --- */
#fx-tunnel-root .card {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  background: var(--card-background);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}

/* --- Conteneur du formulaire --- */
.subscription-form {
  padding: clamp(24px, 4vw, 44px);
}

.stepper-counter {
  display: none;
  margin: 0 0 18px;
  color: var(--color-brand-plum-700);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.subscription-stepper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin: 0 0 34px;
  padding: 0;
  list-style: none;
}

.stepper-item {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
}

.stepper-item:last-child {
  flex: 0 0 auto;
}

.stepper-item button {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.stepper-item button:disabled {
  cursor: default;
}

.stepper-dot {
  display: inline-flex;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--card-border);
  border-radius: 999px;
  background: #fff;
  color: var(--color-neutral-500);
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease,
    box-shadow 200ms ease;
}

.stepper-label {
  display: grid;
  gap: 2px;
  color: var(--color-neutral-700);
  font-weight: 800;
  line-height: 1.15;
}

.stepper-label small {
  color: var(--color-neutral-500);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stepper-connector {
  flex: 1 1 auto;
  height: 2px;
  min-width: 18px;
  margin: 0 14px;
  border-radius: 999px;
  background: var(--card-border);
  transition: background-color 220ms ease;
}

.stepper-connector[data-filled="true"] {
  background: var(--color-brand-plum-500);
}

.stepper-item[data-state="current"] .stepper-dot {
  border-color: var(--color-brand-plum-500);
  color: var(--color-brand-plum-700);
  box-shadow: 0 0 0 4px rgba(54, 95, 141, 0.12);
}

.stepper-item[data-state="current"] .stepper-label,
.stepper-item[data-state="current"] .stepper-label small {
  color: var(--color-neutral-900);
}

.stepper-item[data-state="complete"] .stepper-dot {
  border-color: var(--color-brand-plum-500);
  background: var(--color-brand-plum-500);
  color: #fff;
}

.subscription-form-header h2 {
  margin: 22px 0 0;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.subscription-form-header p {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--color-neutral-700);
}

.form-grid {
  display: grid;
  gap: 18px;
  margin-top: 34px;
}

.subscription-step-panel {
  margin-top: 30px;
}

.subscription-step-panel[hidden] {
  display: none;
}

/* --- Résumé offre sélectionnée --- */
.selected-offer-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px 16px;
}

.selected-offer-summary span {
  color: var(--color-neutral-700);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.selected-offer-summary strong {
  color: var(--color-neutral-900);
}

.selected-offer-summary small {
  color: var(--color-brand-plum-700);
  font-weight: 800;
}

/* --- Champs de formulaire --- */
.form-grid label {
  position: relative;
  display: grid;
  gap: 8px;
  color: var(--color-neutral-900);
  font-size: 14px;
  font-weight: 800;
}

.form-grid input,
.form-grid select {
  min-height: 52px;
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-neutral-900);
  font: inherit;
  font-weight: 600;
  outline: none;
  padding: 0 14px;
}

.form-grid input:focus,
.form-grid select:focus {
  border-color: var(--color-brand-plum-500);
  box-shadow: 0 0 0 4px rgba(54, 95, 141, 0.12);
}

.company-search {
  z-index: 2;
}

.input-with-icon {
  position: relative;
  display: block;
}

.input-with-icon svg {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--color-neutral-500);
  transform: translateY(-50%);
}

.input-with-icon input {
  padding-left: 44px;
}

.form-grid small {
  color: var(--color-neutral-700);
  font-weight: 600;
}

.suggestions-list {
  position: absolute;
  right: 0;
  left: 0;
  top: calc(100% + 8px);
  display: grid;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.suggestions-list button {
  display: grid;
  gap: 4px;
  cursor: pointer;
  border: 0;
  border-bottom: 1px solid var(--card-border);
  background: transparent;
  color: var(--color-neutral-900);
  padding: 14px;
  text-align: left;
}

.suggestions-list button:hover {
  background: var(--color-brand-plum-100);
}

.suggestions-list span {
  color: var(--color-neutral-700);
  font-size: 13px;
}

/* --- Pied & actions --- */
.form-footer {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 28px;
}

.step-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.form-footer p {
  display: flex;
  gap: 10px;
  color: var(--color-neutral-700);
  font-size: 14px;
  font-weight: 700;
}

.form-footer button:disabled,
.step-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.step-actions-inline {
  margin-top: 0;
}

/* --- Champ sous-domaine (suffixe) --- */
.input-with-suffix {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
}

.input-with-suffix:focus-within {
  border-color: var(--color-brand-plum-500);
  box-shadow: 0 0 0 4px rgba(54, 95, 141, 0.12);
}

.input-with-suffix input {
  flex: 1 1 auto;
  min-height: 52px;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 4px 0 14px;
}

.input-with-suffix input:focus {
  box-shadow: none !important;
}

.input-suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-left: 1px solid var(--card-border);
  background: rgba(54, 95, 141, 0.06);
  color: var(--color-neutral-700);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.hostname-field .input-with-suffix input[aria-invalid="true"] {
  color: var(--color-neutral-900);
}

/* --- Indices (hostname) --- */
.hint-muted {
  color: var(--color-neutral-500) !important;
  font-weight: 600 !important;
}

.hint-ok {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1a7f5a !important;
  font-weight: 700 !important;
}

.hint-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.hint-error small {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #b4231f !important;
  font-weight: 700 !important;
}

.hostname-suggestions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hostname-suggestions button {
  cursor: pointer;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: #fff;
  color: var(--color-brand-plum-700);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 10px;
}

.hostname-suggestions button:hover {
  border-color: var(--color-brand-plum-500);
  background: var(--color-brand-plum-100);
}

/* --- Alerte d'erreur --- */
.form-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  border: 1px solid rgba(180, 35, 31, 0.28);
  border-radius: 14px;
  background: rgba(180, 35, 31, 0.07);
  color: #8f1c19;
  font-size: 14px;
  font-weight: 700;
  padding: 14px 16px;
}

.form-alert svg {
  flex-shrink: 0;
}

/* --- Spinner --- */
.spin {
  animation: fx-spin 0.9s linear infinite;
}

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

/* --- Panneau de déploiement --- */
.deployment-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.deployment-icon {
  display: inline-flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--color-brand-plum-100);
  color: var(--color-brand-plum-700);
}

.deployment-icon.is-done {
  background: rgba(26, 127, 90, 0.12);
  color: #1a7f5a;
}

.deployment-panel h2 {
  margin: 6px 0 0;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.deployment-panel p {
  max-width: 520px;
  margin: 0;
  color: var(--color-neutral-700);
}

.deployment-offer {
  font-weight: 800 !important;
  color: var(--color-brand-plum-700) !important;
}

.deployment-progress {
  position: relative;
  width: min(420px, 100%);
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--color-brand-plum-100);
}

.deployment-progress > span {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: var(--color-brand-plum-500);
  transition: width 600ms ease;
}

.deployment-progress-indeterminate > span {
  width: 40%;
  animation: fx-indeterminate 1.3s ease-in-out infinite;
}

@keyframes fx-indeterminate {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(310%);
  }
}

.deployment-panel .button {
  margin-top: 6px;
}

.deployment-hostname {
  font-size: 15px;
  color: var(--color-neutral-700) !important;
}

.deployment-hostname strong {
  color: var(--color-neutral-900);
  word-break: break-all;
}

.deployment-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: rgba(54, 95, 141, 0.04);
  padding: 18px 22px;
  text-align: center;
}

.deployment-fallback p {
  color: var(--color-neutral-700) !important;
  font-size: 14px;
  line-height: 1.7;
}

/* --- Offre : prix & badge --- */
.offer-price {
  margin: 10px 0 0;
  color: var(--color-neutral-900);
  font-size: 22px;
  font-weight: 800;
}

.offer-badge {
  display: inline-flex;
  align-self: flex-start;
  border-radius: 999px;
  background: var(--color-brand-gold-100);
  color: var(--color-brand-gold-700);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 6px 11px;
  text-transform: uppercase;
}

/* --- Comparatif des capacités (✓ inclus / – non inclus) --- */
.offer-caps li {
  position: static;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 0;
  font-size: 13.5px;
  line-height: 1.4;
}

.offer-caps li::before {
  content: none;
}

.offer-caps li svg {
  flex-shrink: 0;
}

.offer-caps li.is-on {
  color: var(--color-neutral-900);
  font-weight: 600;
}

.offer-caps li.is-on svg {
  color: var(--color-brand-gold-500);
}

.offer-caps li.is-off {
  color: #9a958a;
  font-weight: 500;
}

.offer-caps li.is-off svg {
  color: #d8d2c4;
}

/* --- Tableau comparatif des offres (desktop) --- */
.offer-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.offer-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 14px;
}

.offer-table th,
.offer-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
}

.offer-table th[scope="row"],
.offer-table-head-label {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  text-align: left;
  font-weight: 600;
  color: var(--color-neutral-700);
  white-space: nowrap;
}

.offer-table-head-label {
  color: var(--color-neutral-500);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.offer-col {
  min-width: 150px;
  text-align: center;
  vertical-align: top;
  border-left: 1px solid var(--card-border);
}

.offer-table th.offer-col {
  position: relative;
  padding-top: 40px;
}

.offer-col .offer-badge {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.offer-col .offer-choose {
  margin-top: 12px;
}

.offer-col-name {
  display: block;
  font-family: var(--font-fraunces);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-neutral-900);
}

.offer-col-price {
  display: block;
  margin-top: 4px;
  color: var(--color-neutral-900);
  font-size: 16px;
  font-weight: 800;
}

.offer-col.is-reco {
  background: var(--color-brand-gold-100);
}

.offer-col.is-selected {
  box-shadow: inset 0 -3px 0 var(--color-brand-gold-500);
}

.offer-table tbody td {
  text-align: center;
  border-left: 1px solid var(--card-border);
}

.offer-table tbody tr:nth-child(even) td,
.offer-table tbody tr:nth-child(even) th[scope="row"] {
  background: #faf8f2;
}

.offer-row-spec td {
  font-weight: 700;
  color: var(--color-neutral-900);
}

.offer-table td.is-on svg {
  color: var(--color-brand-gold-500);
}

.offer-table td.is-off svg {
  color: #d8d2c4;
}

.offer-choose {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  font-size: 14px;
}

/* Mention campagne « gratuit jusqu'au … » */
.offer-col-free {
  display: inline-block;
  margin-top: 6px;
  color: var(--color-brand-gold-700);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

/* --- Offres : cartes empilées (mobile) --- */
.offer-cards {
  display: none;
}

.offer-card-highlighted {
  border-color: var(--color-brand-gold-500);
  box-shadow: 0 0 0 1px var(--color-brand-gold-500), var(--shadow-md);
}

.offer-mcard {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px 20px;
}

.offer-mcard.is-selected {
  border-color: var(--color-brand-gold-500);
  box-shadow: 0 0 0 1px var(--color-brand-gold-500), var(--shadow-md);
}

.offer-mcard-name {
  margin: 8px 0 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.offer-mcard .offer-price {
  margin: 6px 0 0;
}

.offer-mcard-specs {
  margin: 10px 0 0;
  color: var(--color-neutral-700);
  font-size: 13px;
  font-weight: 700;
}

.offer-mcard .offer-caps {
  display: grid;
  gap: 9px;
  margin: 16px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--card-border);
  list-style: none;
}

.offer-mcard .offer-choose {
  width: 100%;
  margin-top: 18px;
}

/* --- Facturation électronique : quota inclus + tarif hors quota ---
   Classes .offer-efact-quota / .offer-efact-overage partagées entre le tableau
   comparatif et les cartes mobiles. */
.offer-efact-quota {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-neutral-900);
}

.offer-efact-overage {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-neutral-500);
}

/* Tableau comparatif */
.offer-efact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  line-height: 1.3;
}

/* Carte mobile */
.offer-mcard-efact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--color-brand-gold-100);
}

.offer-mcard-efact-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-neutral-500);
}

/* --- Case de consentement --- */
.form-consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 26px;
  color: var(--color-neutral-700);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.55;
}

.form-consent input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--color-brand-plum-500);
  cursor: pointer;
}

.form-consent a {
  color: var(--color-brand-plum-700);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 720px) {
  .stepper-counter {
    display: block;
  }

  .stepper-label {
    display: none;
  }

  .subscription-stepper {
    justify-content: space-between;
  }

  .stepper-dot {
    width: 38px;
    height: 38px;
  }

  #fx-tunnel-root .button {
    width: 100%;
  }
}

@media (min-width: 860px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .company-search,
  .instance-field,
  .form-grid label:nth-child(5) {
    grid-column: span 2;
  }

  .form-footer {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .step-actions {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }
}

/* Bascule tableau (desktop) ↔ cartes (mobile) */
@media (max-width: 767px) {
  .offer-table-wrap {
    display: none;
  }

  .offer-cards {
    display: grid;
    gap: 14px;
  }

  .subscription-form-header {
    display: none;
  }

  .form-grid {
    margin-top: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #fx-tunnel-root *,
  #fx-tunnel-root *::before,
  #fx-tunnel-root *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
