/**
 * CF7 Magic Wizard - Styles frontend
 *
 * Toutes les couleurs sont contrôlées via des CSS custom properties
 * injectées sur le wrapper .cf7mw-wrapper depuis PHP. Les valeurs de
 * fallback ci-dessous correspondent à la palette par défaut.
 */

.cf7mw-wrapper {
    --cf7mw-circle-active: #2563eb;
    --cf7mw-circle-done: #2563eb;
    --cf7mw-circle-inactive: #e5e7eb;
    --cf7mw-line-active: #2563eb;
    --cf7mw-line-inactive: #e5e7eb;
    --cf7mw-text-active: #2563eb;
    --cf7mw-text-inactive: #6b7280;
    --cf7mw-btn-bg: #2563eb;
    --cf7mw-btn-text: #ffffff;
    --cf7mw-btn-bg-hover: #1d4ed8;
    --cf7mw-btn-prev-bg: #f3f4f6;
    --cf7mw-btn-prev-text: #374151;
    --cf7mw-progress-bar: #2563eb;
    --cf7mw-progress-track: #e5e7eb;
    --cf7mw-circle-size: 36px;
    --cf7mw-radius: 999px;
    --cf7mw-font: inherit;
    --cf7mw-transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);

    display: block;
    width: 100%;
    box-sizing: border-box;
    font-family: var(--cf7mw-font);
}

.cf7mw-wrapper *,
.cf7mw-wrapper *::before,
.cf7mw-wrapper *::after {
    box-sizing: border-box;
}

/* -----------------------------------------------------------------
 * Indicateur d'étapes (cercles + noms + lignes)
 *
 * Stratégie : chaque étape (li) occupe 1/N de la largeur, le cercle
 * est centré dans son item. Les lignes connectrices sont peintes en
 * ::before/::after sur chaque item — la ::before va du bord gauche
 * de l'item jusqu'au centre du cercle, la ::after va du centre du
 * cercle jusqu'au bord droit. Ainsi les lignes se rejoignent
 * parfaitement, quel que soit le nombre d'étapes.
 * ----------------------------------------------------------------- */

.cf7mw-indicator {
    margin: 0 0 70px 0;
}

.cf7mw-indicator__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.cf7mw-indicator__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 0;
    position: relative;
}

/* Lignes connectrices : ::before relie au cercle précédent,
   ::after relie au cercle suivant. Calées verticalement au centre
   du cercle (top = moitié de sa hauteur). */
.cf7mw-indicator__item::before,
.cf7mw-indicator__item::after {
    content: '';
    position: absolute;
    top: calc(var(--cf7mw-circle-size) / 2);
    height: 2px;
    margin-top: -1px;
    background-color: var(--cf7mw-line-inactive);
    z-index: 1;
    transition: background-color var(--cf7mw-transition);
}
.cf7mw-indicator__item::before {
    left: 0;
    right: 50%;
}
.cf7mw-indicator__item::after {
    left: 50%;
    right: 0;
}
.cf7mw-indicator__item:first-child::before { display: none; }
.cf7mw-indicator__item:last-child::after   { display: none; }

.cf7mw-indicator__node {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cf7mw-indicator__circle {
    flex: 0 0 auto;
    width: var(--cf7mw-circle-size);
    height: var(--cf7mw-circle-size);
    border-radius: var(--cf7mw-radius);
    background-color: var(--cf7mw-circle-inactive);
    color: var(--cf7mw-text-inactive);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    transition: background-color var(--cf7mw-transition), color var(--cf7mw-transition), transform var(--cf7mw-transition), box-shadow var(--cf7mw-transition);
    position: relative;
    z-index: 3;
    border: 2px solid transparent;
}

.cf7mw-indicator__number { display: inline-block; }

.cf7mw-indicator__check {
    width: 60%;
    height: 60%;
    display: none;
    color: #ffffff;
}

.cf7mw-indicator__label {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--cf7mw-text-inactive);
    transition: color var(--cf7mw-transition);
    max-width: 100%;
    word-break: break-word;
    padding: 0 4px;
}

.cf7mw-indicator__name {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}

.cf7mw-indicator__subtitle {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.85;
    line-height: 1.3;
}

/* États : étape active */
.cf7mw-indicator__item.is-active .cf7mw-indicator__circle {
    background-color: var(--cf7mw-circle-active);
    color: #ffffff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cf7mw-circle-active) 18%, transparent);
}
.cf7mw-indicator__item.is-active .cf7mw-indicator__label {
    color: var(--cf7mw-text-active);
}
/* La ligne arrivant sur l'étape active est colorée */
.cf7mw-indicator__item.is-active::before {
    background-color: var(--cf7mw-line-active);
}

/* États : étape complétée */
.cf7mw-indicator__item.is-done .cf7mw-indicator__circle {
    background-color: var(--cf7mw-circle-done);
    color: #ffffff;
}
.cf7mw-indicator__item.is-done .cf7mw-indicator__number { display: none; }
.cf7mw-indicator__item.is-done .cf7mw-indicator__check  { display: inline-block; }
.cf7mw-indicator__item.is-done::before,
.cf7mw-indicator__item.is-done::after {
    background-color: var(--cf7mw-line-active);
}
.cf7mw-indicator__item.is-done .cf7mw-indicator__label {
    color: var(--cf7mw-text-active);
}

/* -----------------------------------------------------------------
 * Étapes (panneaux du formulaire)
 * ----------------------------------------------------------------- */

.cf7mw-step {
    display: none;
    animation: cf7mw-fade-in 320ms cubic-bezier(0.4, 0, 0.2, 1);
}
.cf7mw-step.is-active {
    display: block;
}
/* Clearfix : indispensable car beaucoup de thèmes utilisent .column.one
   { float:left; width:50% } à l'intérieur des formulaires, ce qui ferait
   passer la barre de navigation à côté du dernier champ. */
.cf7mw-step.is-active::after {
    content: '';
    display: table;
    clear: both;
}

@keyframes cf7mw-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cf7mw-step__nav {
    clear: both;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.cf7mw-step__nav-spacer {
    flex: 1 1 auto;
}

.cf7mw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 8px;
    border: 0;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--cf7mw-transition), color var(--cf7mw-transition), transform 120ms ease;
    min-height: 44px; /* accessibilité tactile */
}
.cf7mw-btn:active { transform: translateY(1px); }
.cf7mw-btn:focus-visible {
    outline: 2px solid var(--cf7mw-circle-active);
    outline-offset: 2px;
}

.cf7mw-btn--next {
    background-color: var(--cf7mw-btn-bg);
    color: var(--cf7mw-btn-text);
}
.cf7mw-btn--next:hover {
    background-color: var(--cf7mw-btn-bg-hover);
    color: var(--cf7mw-btn-text);
}

.cf7mw-btn--prev {
    background-color: var(--cf7mw-btn-prev-bg);
    color: var(--cf7mw-btn-prev-text);
}
.cf7mw-btn--prev:hover {
    filter: brightness(0.97);
}

/* On masque les boutons submit/next quand ils ne concernent pas l'étape active */
.cf7mw-step[aria-hidden="true"] .wpcf7-submit {
    display: none !important;
}

/* -----------------------------------------------------------------
 * Barre de progression
 * ----------------------------------------------------------------- */

.cf7mw-progress {
    margin-top: 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cf7mw-progress__track {
    flex: 1 1 auto;
    height: 8px;
    border-radius: 999px;
    background-color: var(--cf7mw-progress-track);
    overflow: hidden;
}

.cf7mw-progress__bar {
    height: 100%;
    width: 0%;
    background-color: var(--cf7mw-progress-bar);
    border-radius: 999px;
    transition: width 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.cf7mw-progress__label {
    flex: 0 0 auto;
    font-size: 13px;
    color: var(--cf7mw-text-inactive);
    font-variant-numeric: tabular-nums;
    min-width: 38px;
    text-align: right;
}

/* -----------------------------------------------------------------
 * Erreurs de validation client
 * ----------------------------------------------------------------- */

.cf7mw-field-error {
    color: #b91c1c;
    font-size: 13px;
    margin-top: 4px;
    display: block;
}

.cf7mw-step .wpcf7-not-valid {
    border-color: #b91c1c !important;
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.18);
}

/* -----------------------------------------------------------------
 * Responsive
 * ----------------------------------------------------------------- */

/* Tablette : on conserve la disposition horizontale mais on réduit la taille des labels */
@media (max-width: 768px) {
    .cf7mw-indicator__name {
        font-size: 13px;
    }
    .cf7mw-indicator__subtitle {
        font-size: 11px;
    }
    .cf7mw-wrapper { --cf7mw-circle-size: 32px; }
}

/* Mobile : on bascule en mode compact horizontal scrollable, sans casser les lignes */
@media (max-width: 560px) {
    .cf7mw-indicator__list {
        gap: 4px;
    }
    .cf7mw-indicator__name {
        font-size: 12px;
    }
    .cf7mw-indicator__subtitle {
        display: none; /* on masque les sous-titres pour gagner de la place */
    }
    .cf7mw-wrapper { --cf7mw-circle-size: 28px; }
    .cf7mw-indicator__circle { font-size: 12px; }

    .cf7mw-btn {
        flex: 1 1 auto;
        padding: 12px 18px;
    }
    .cf7mw-step__nav {
        gap: 8px;
    }
}

/* Très petit écran : on masque les noms et on ne garde que les numéros + lignes */
@media (max-width: 380px) {
    .cf7mw-indicator__label {
        display: none;
    }
}

/* Préférence utilisateur : moins d'animation */
@media (prefers-reduced-motion: reduce) {
    .cf7mw-step,
    .cf7mw-progress__bar,
    .cf7mw-indicator__circle,
    .cf7mw-indicator__line,
    .cf7mw-indicator__label {
        transition: none !important;
        animation: none !important;
    }
}
