/* =====================================================
   FORMS CSS — WAM Dance Studio
   Design system des champs de formulaires.
   Couvre : balises natives, Fluent Forms, MailPoet.
   Chargé sur les pages contenant des formulaires.
   ===================================================== */

/* =====================================================
   TOKENS LOCAUX FORMULAIRES
   Centralisés ici pour faciliter les ajustements.
   ===================================================== */
:root {
    --wam-field-border-default: 2px solid var(--wp--preset--color--background-500);
    --wam-field-border-focus: 2px solid var(--wp--preset--color--accent-green);
    --wam-field-border-error: 2px solid var(--wp--preset--color--accent-orange);
    --wam-field-radius: var(--wam-radius-md);
    /* 12px */
    --wam-field-px: var(--wam-spacing-sm);
    /* 16px */
    --wam-field-py: var(--wam-spacing-2xs);
    /* 8px */
    --wam-field-font-size: var(--wam-font-size-md);
    /* 20px */
    --wam-label-font-size: var(--wam-font-size-sm);
    /* 14px */
    --wam-field-gap: var(--wam-spacing-2xs);
    /* 8px */
}

/* =====================================================
   GROUPE LABEL + CHAMP
   Balises natives + Fluent Forms + MailPoet
   ===================================================== */

/* Groupe wrapper — Fluent Forms */
.ff-el-group,
.mailpoet_paragraph {
    display: flex;
    flex-direction: column;
    gap: var(--wam-field-gap);
    margin-bottom: var(--wam-spacing-lg) !important;
}

/* =====================================================
   LABELS
   ===================================================== */

label,
.ff-el-input--label label,
.ff-el-input--label p,
.mailpoet_paragraph label {
    font-family: var(--wam-font-body);
    font-size: var(--wam-label-font-size);
    font-weight: 400;
    line-height: 1.25;
    color: var(--wp--preset--color--text-normal);
    padding: 0 var(--wam-spacing-2xs);
    margin: 0;
    cursor: pointer;
}

/* Astérisque champ requis (Fluent Forms) */
.ff-el-input--label.ff-el-is-required.asterisk-right label::after {
    content: ' *';
    color: var(--wam-color-pink);
}

/* Astérisque formulaire WAM et global */
.required,
abbr.required {
    color: var(--wam-color-pink) !important;
    text-decoration: none !important;
    border-bottom: none !important;
}

/* =====================================================
   CHAMPS TEXTE — input, textarea, select
   ===================================================== */

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="url"],
input[type="password"],
input[type="search"],
textarea,
select,
.ff-el-form-control {
    display: block;
    width: 100%;
    max-width: 800px;
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-field-font-size) !important;
    font-weight: 400;
    line-height: 1.25;
    color: var(--wp--preset--color--text-normal) !important;
    background: transparent !important;
    border: var(--wam-field-border-default) !important;
    border-radius: var(--wam-field-radius) !important;
    padding: var(--wam-field-py) var(--wam-field-px) !important;
    box-sizing: border-box;
    box-shadow: none !important;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: var(--wam-spacing-2xs) !important;
}

input.cours-search {
    font-size: var(--wam-font-size-md) !important;
}

/* Placeholder */
input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="tel"]::placeholder,
input[type="number"]::placeholder,
input[type="url"]::placeholder,
input[type="password"]::placeholder,
input[type="search"]::placeholder,
textarea::placeholder,
.ff-el-form-control::placeholder {
    color: var(--wp--preset--color--text-disabled) !important;
    opacity: 1;
}

/* Textarea — hauteur min confortable */
textarea,
textarea.ff-el-form-control {
    resize: vertical;
    min-height: 120px;
}

/* Focus — natifs + Fluent Forms */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus,
.ff-el-form-control:focus {
    border: var(--wam-field-border-focus) !important;
    outline: none;
    box-shadow: none !important;
}

/* MailPoet — !important nécessaire : inline styles injectés par le plugin */
.mailpoet_text,
.mailpoet_select {
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-field-font-size) !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    color: var(--wp--preset--color--text-normal) !important;
    background: transparent !important;
    border: var(--wam-field-border-default) !important;
    border-radius: var(--wam-field-radius) !important;
    padding: var(--wam-field-py) var(--wam-field-px) !important;
    width: 100% !important;
    max-width: 800px !important;
    box-shadow: none !important;
    outline: none !important;
}

.mailpoet_text:focus {
    border: var(--wam-field-border-focus) !important;
    box-shadow: none !important;
    outline: none !important;
}

.mailpoet_text::placeholder {
    color: var(--wp--preset--color--text-disabled) !important;
    opacity: 1 !important;
}

/* Select — chevron custom */
select,
.mailpoet_select {
    background-image: url("data:image/svg+xml,%3Csvg width='13' height='13' viewBox='0 0 13 13' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 4L6.5 8.5L11 4' stroke='%23e1cdad' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right var(--wam-field-px) center !important;
    padding-right: calc(var(--wam-field-px) * 2.5) !important;
    cursor: pointer;
    background-color: transparent !important;
}

select option {
    background: var(--wp--preset--color--background-600);
    color: var(--wp--preset--color--text-normal);
}

/* =====================================================
   CHAMP REMPLI — autofill navigateur
   Le navigateur injecte un fond jaune via :-webkit-autofill.
   On le neutralise avec un box-shadow inset transparent.
   ===================================================== */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px transparent inset !important;
    -webkit-text-fill-color: var(--wp--preset--color--text-normal) !important;
    caret-color: var(--wp--preset--color--text-normal);
    transition: background-color 5000s ease-in-out 0s;
    /* délai pour que le fond reste transparent */
}

/* =====================================================
   ÉTATS ERREUR
   ===================================================== */

/* Champ en erreur — Fluent Forms + Natif
   Double ciblage : classe sur le parent (.has-error) ET aria-invalid sur l'input. */
.ff-el-group.has-error .ff-el-form-control,
.ff-el-form-control[aria-invalid="true"],
.wam-contact-form input[aria-invalid="true"],
.wam-contact-form select[aria-invalid="true"],
.wam-contact-form textarea[aria-invalid="true"],
.ff_input_error {
    border: var(--wam-field-border-error) !important;
}

/* Message d'erreur — Fluent Forms + Natif */
.ff-el-group .error,
.ff-el-group .ff-error,
.wam-field-error,
.error-element {
    font-family: var(--wam-font-body);
    font-size: var(--wam-label-font-size);
    line-height: 1.25;
    color: var(--wp--preset--color--accent-orange);
    padding: 0 var(--wam-spacing-2xs);
    margin-top: 4px;
    display: block;
}

/* Message validation MailPoet */
.mailpoet_validate_success {
    color: var(--wp--preset--color--accent-green) !important;
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-label-font-size) !important;
}

.mailpoet_validate_error {
    color: var(--wp--preset--color--accent-orange) !important;
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-label-font-size) !important;
}

/* =====================================================
   BOUTONS SOUMISSION
   → Les classes .ff-btn-submit, .ff_btn_style, .mailpoet_submit
     sont scopées sous .wamformcss dans components.css.
     Pas d'!important — la spécificité du wrapper suffit.
   ===================================================== */

/* Zone bouton Fluent Forms — alignement gauche, pas full width */
.wamformcss .ff_submit_btn_wrapper {
    margin-top: var(--wam-spacing-lg);
    display: flex;
    justify-content: flex-start;
}

/* Zone bouton MailPoet — idem */
.wamformcss .mailpoet_paragraph:has(.mailpoet_submit) {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 0;
}

/* =====================================================
   FLUENT FORMS — CORRECTIONS LAYOUT
   ===================================================== */

/*
 * Fluent Forms injecte un layout en colonnes via .ff-t-container / .ff-t-cell.
 * On harmonise les gaps avec nos tokens.
 */
.ff-t-container {
    gap: var(--wam-spacing-sm) !important;
}

.ff-el-group .ff-el-input--content {
    margin-top: 0 !important;
}

/* =====================================================
   MAILPOET — CORRECTIONS LAYOUT
   ===================================================== */

/*
 * MailPoet injecte des styles inline massifs.
 * On reset les éléments clés sans tout casser.
 */
.mailpoet_form {
    font-family: var(--wam-font-body) !important;
}

/* Image décorative MailPoet — on la masque (hors charte) */
.mailpoet_form_image {
    display: none !important;
}

/* Titres MailPoet — on ramène dans la charte */
.mailpoet-heading {
    font-family: var(--wam-font-body) !important;
    color: var(--wp--preset--color--text-normal) !important;
    text-align: center;
}

/* Texte légal MailPoet */
.mailpoet_form_paragraph.last {
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-label-font-size) !important;
    color: var(--wp--preset--color--text-disabled) !important;
    text-align: center;
}

.mailpoet_form_paragraph.last a {
    color: var(--wp--preset--color--text-subtext) !important;
}

/* Espaceur MailPoet — neutralisé */
.mailpoet_spacer {
    display: none !important;
}

/* =====================================================
   FORMULAIRE DE CONTACT NATIF (SHORTCODE)
   ===================================================== */
.wam-contact-form-wrapper {
    margin: var(--wam-spacing-lg) 0;
}

.wam-contact-form {
    max-width: 800px;
    gap: 0;
}

.wam-contact-form-wrapper .wam-form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--wam-spacing-lg);
    margin-bottom: var(--wam-spacing-lg);
}

@media (min-width: 768px) {
    .wam-contact-form-wrapper .wam-form-row.form-row-2 {
        grid-template-columns: 1fr 1fr;
    }
}

.wam-contact-form-wrapper .wam-form-group {
    display: flex;
    flex-direction: column;
    gap: var(--wam-field-gap);
    margin-bottom: var(--wam-spacing-lg);
}

/* Messages de retour AJAX */
.wam-form-response {
    margin-top: var(--wam-spacing-md);
    padding: var(--wam-spacing-sm);
    border-radius: var(--wam-field-radius);
    font-family: var(--wam-font-body);
    font-size: var(--wam-font-size-xs);
    text-align: center;
    display: none;
    /* Masqué par défaut */
}

.wam-form-response.is-visible {
    display: block;
}

.wam-form-response.is-success {
    background-color: rgba(30, 166, 114, 0.1);
    color: var(--wam-color-green);
    border: 1px solid var(--wam-color-green);
}

.wam-form-response.is-error {
    background-color: rgba(222, 59, 83, 0.1);
    color: var(--wam-color-orange);
    border: 1px solid var(--wam-color-orange);
}

.wam-form-response p {
    margin: 0;
}

/* Notice champs obligatoires */
.wam-contact-form-notice {
    font-size: var(--wam-font-size-xs);
    margin-bottom: var(--wam-spacing-lg);
    color: var(--wam-color-subtext);
    max-width: 800px;
}

.wam-contact-form-notice .required {
    color: var(--wam-color-pink);
}

/* Animation Bouton Chargement "Shimmer" */
.wam-contact-form .btn {
    position: relative;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

/* Cache Honeypot Anti-Spam */
.wam-hp-field {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.wam-contact-form .btn.is-loading {
    pointer-events: none;
    opacity: 0.8;
}

.wam-contact-form .btn.is-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: button-shimmer 1.5s infinite;
}

@keyframes button-shimmer {
    100% {
        left: 200%;
    }
}

/* =====================================================
   BOOKLY FRONT-END FORM OVERRIDES
   Préparation pour l'intégration de la réservation Bookly.
   À ajuster en prod selon les besoins.
   ===================================================== */

/* --- Conteneur global du formulaire Bookly --- */
.bookly-form {
    font-family: var(--wam-font-body) !important;
    color: var(--wp--preset--color--text-normal) !important;
}

/* --- Typographie générale et Labels --- */
.bookly-form .bookly-form-group label {
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-label-font-size) !important;
    font-weight: 400 !important;
    color: var(--wp--preset--color--text-normal) !important;
    margin-bottom: var(--wam-field-gap) !important;
    display: block !important;
}

/* --- Champs Select et Inputs --- */
.bookly-form select,
.bookly-form input[type="text"],
.bookly-form .bookly-date-from {
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-field-font-size) !important;
    color: var(--wp--preset--color--text-normal) !important;
    background-color: transparent !important;
    border: var(--wam-field-border-default) !important;
    border-radius: var(--wam-field-radius) !important;
    padding: var(--wam-field-py) var(--wam-field-px) !important;
    width: 100% !important;
    max-width: 800px !important;
    box-shadow: none !important;
    outline: none !important;
    transition: border-color 0.2s ease !important;
}

.bookly-form select:focus,
.bookly-form input[type="text"]:focus {
    border: var(--wam-field-border-focus) !important;
}

/* Override du background pour select (Chevron WAM) */
.bookly-form select {
    background-image: url("data:image/svg+xml,%3Csvg width='13' height='13' viewBox='0 0 13 13' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 4L6.5 8.5L11 4' stroke='%23e1cdad' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right var(--wam-field-px) center !important;
    padding-right: calc(var(--wam-field-px) * 2.5) !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}
.bookly-form select option {
    background: var(--wp--preset--color--background-600) !important;
    color: var(--wp--preset--color--text-normal) !important;
}

/* --- Jours de la semaine (Checkboxes) --- */
.bookly-week-days {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: var(--wam-spacing-sm) !important;
    margin-top: var(--wam-spacing-sm) !important;
}
.bookly-week-days .bookly-form-group {
    display: flex !important;
    flex-direction: column-reverse !important;
    align-items: center !important;
    width: auto !important;
    float: none !important;
}
.bookly-week-days label {
    font-size: var(--wam-font-size-xs) !important;
    margin: 0 0 4px 0 !important;
}

/* --- Calendrier Datepicker --- */
/* (Couleurs générales du calendrier popup) */
.bookly-js-datepicker-calendar {
    background-color: var(--wp--preset--color--background-600) !important;
    border: 1px solid var(--wp--preset--color--background-500) !important;
    border-radius: var(--wam-radius-md) !important;
    padding: var(--wam-spacing-sm) !important;
    color: var(--wp--preset--color--text-normal) !important;
}

/* --- Étape Choix de l'Heure (Time Step) --- */
.bookly-time-step {
    margin-top: var(--wam-spacing-lg) !important;
}

/* En-tête des colonnes (Jour) : ex: "mer, Mai 20" */
.bookly-time-step .bookly-day {
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-font-size-sm) !important;
    font-weight: 600 !important;
    color: var(--wam-color-text) !important;
    background-color: transparent !important;
    border: none !important;
    padding: var(--wam-spacing-xs) 0 !important;
    text-transform: capitalize !important;
}

/* Boutons Heures (Créneaux) : ex: "08:00" */
.bookly-time-step .bookly-hour {
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-font-size-sm) !important;
    color: var(--wp--preset--color--text-normal) !important;
    background-color: transparent !important;
    border: 1px solid var(--wp--preset--color--background-500) !important;
    border-radius: var(--wam-radius-sm) !important;
    padding: var(--wam-spacing-2xs) var(--wam-spacing-xs) !important;
    margin-bottom: var(--wam-spacing-2xs) !important;
    width: 100% !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

.bookly-time-step .bookly-hour:hover {
    background-color: var(--wp--preset--color--background-500) !important;
    color: var(--wp--preset--color--text-normal) !important;
    border-color: var(--wp--preset--color--accent-green) !important;
}

/* Créneau sélectionné */
.bookly-time-step .bookly-hour.bookly-active,
.bookly-time-step .bookly-hour:active {
    background-color: var(--wp--preset--color--accent-green) !important;
    color: #fff !important;
    border-color: var(--wp--preset--color--accent-green) !important;
}

/* Cache l'icône de la petite flèche intégrée dans les créneaux Bookly */
.bookly-hour-icon {
    display: none !important;
}

/* --- Boutons d'action (Suivant, Retour) --- */
.bookly-btn {
    font-family: var(--wam-font-body) !important;
    font-size: var(--wam-font-size-sm) !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border-radius: 100px !important; /* Style pilule */
    padding: 12px 24px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    border: none !important;
}

/* Bouton principal (Suivant) */
.bookly-form .bookly-next-step, 
.bookly-form .bookly-mobile-next-step {
    background-color: var(--wp--preset--color--accent-yellow) !important;
    color: var(--wp--preset--color--background-800) !important;
}
.bookly-form .bookly-next-step:hover,
.bookly-form .bookly-mobile-next-step:hover {
    background-color: var(--wp--preset--color--text-normal) !important;
    color: var(--wp--preset--color--background-800) !important;
}

/* Bouton secondaire (Retour) */
.bookly-form .bookly-back-step,
.bookly-form .bookly-mobile-prev-step {
    background-color: transparent !important;
    color: var(--wp--preset--color--text-normal) !important;
    border: 1px solid var(--wp--preset--color--text-normal) !important;
}
.bookly-form .bookly-back-step:hover,
.bookly-form .bookly-mobile-prev-step:hover {
    background-color: var(--wp--preset--color--text-normal) !important;
    color: var(--wp--preset--color--background-800) !important;
}

/* Flèches de navigation du calendrier (Semaine suivante/précédente) */
.bookly-form .bookly-time-next,
.bookly-form .bookly-time-prev {
    background-color: var(--wp--preset--color--background-500) !important;
    color: var(--wp--preset--color--text-normal) !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
}
.bookly-form .bookly-time-next:hover,
.bookly-form .bookly-time-prev:hover {
    background-color: var(--wp--preset--color--accent-green) !important;
    color: #fff !important;
}