/* --- Styles for Forms (Comments, Contact Form 7) --- */

/* Comment Form */
.comment-form label {
    display: block;
    margin-bottom: 0.5em;
}
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea,
.wpcf7-form-control.wpcf7-text,
.wpcf7-form-control.wpcf7-textarea {
    /* Shared base styles for text inputs and textareas (comments + CF7)
       Comment form keeps its margin-bottom below via a specific rule. */
    font-family: var(--font-body);
    width: 100%;
    padding: 10px;
    border: 1px solid var(--site-color-border-medium);
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1em;
}

/* Keep the extra bottom margin used by the native comment form */
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    margin-bottom: 1em;
}
/* .comment-form .form-submit input[type="submit"],
.comment-form .form-submit button[type="submit"],
.wpcf7-form input[type="submit"].wpcf7-submit {
    
} */
/* .comment-form .form-submit input[type="submit"]:hover {
    background-color: var(--button-primary-bg-hover-color);
    color: var(--button-primary-text-hover-color);
    border-color: var(--button-primary-border-hover-color);
} */

/* Style for comment form error messages */
.comment-form-error, .wp-die-message {
    color: var(--site-color-text);
    font-weight: bold;
    margin-bottom: 1em;
}

/* Testimonial Form (Contact Form 7) */
.wpcf7-form {
    width: 100%; /* Make sure the form takes the full width of its container column */
    max-width: 100%; /* Redundant but safe */
    box-sizing: border-box; /* Good practice if padding/border were added to the form */
}
/* Make sure paragraphs inside the form do not constrain the width */
.wpcf7-form p {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}
.wpcf7-form .form-row-cf7 {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 1.5em;
}
.wpcf7-form .form-field-half-cf7 {
    /* flex: 1 1 calc(50% - 10px); */
    flex: 1 1 50%;
    margin-bottom: 0;
    box-sizing: border-box;
}
.wpcf7-form .form-field-full-cf7 {
    width: 100%;
    margin-bottom: 1.5em;
    box-sizing: border-box;
}
.wpcf7-form .form-field-half-cf7 input[type="text"],
.wpcf7-form .form-field-half-cf7 input[type="email"],
.wpcf7-form .form-field-full-cf7 textarea {
    /* font-family: var(--font-primary);  */
    /* font-size: 1.05em; */
    width: 100%;
    /* padding: 10px; */
    /* border: 1px solid var(--site-color-border-medium); */
    /* border-radius: 5px; */
    /* box-sizing: border-box; */
}

.wpcf7-form .wpcf7-form-control-wrap {
    display: block; /* Make sure the span wrapper takes the full width of its <p> parent */
}


/* General styles for CF7 input fields (when not in .form-field-xxx) */
/* This ensures they take the full available width */
.wpcf7-form-control.wpcf7-text,
.wpcf7-form-control.wpcf7-textarea {
    font-family: var(--font-navigation, var(--font-body));
    width: 100%;
    padding: 10px;
    border: 1px solid var(--site-color-border-medium);
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1em;
}

/* Make the testimonial textarea more compact on the Témoignages page
   (the form limits input to ~250 chars, so a large textarea looks oversized).
   Allow vertical resize so users can expand if they want. */
.page-temoignages-partenaires-content .child-page-section .wpcf7-form textarea.wpcf7-form-control.wpcf7-textarea {
    min-height: 4.4rem; /* ~4 lines */
    max-height: 10rem; /* don't grow excessively */
    resize: vertical; /* allow users to expand if needed */
}

/* Keep the select-specific appearance tweaks (arrow) only for actual selects */
.wpcf7-form-control.wpcf7-select {
    font-family: var(--font-navigation, var(--font-body));
    width: 100%;
    padding: 10px;
    border: 1px solid var(--site-color-border-medium);
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1em;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%208l5%205%205-5z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 1.2em;
    padding-right: 30px; /* Make space for the arrow */
}

.wpcf7-form-control.wpcf7-select::-ms-expand {
    display: none;
}

.wpcf7-form label { /* General label style for CF7 */
    display: block;
    margin-bottom: 0.5em;
    /* Make sure labels do not constrain the width of their children */
    padding-left: 0;
    padding-right: 0;
    font-weight: normal;
    font-size: 1em;
}
.wpcf7-form .form-field-consent-cf7 {
    text-align: center;
}
.wpcf7-form .form-field-submit-cf7 {
    text-align: center;
    width: 100%;
}
.wpcf7-form .wpcf7-spinner {
    display: block;
    margin: 8px auto 0 auto;
}
.wpcf7-form .form-field-consent-cf7 .wpcf7-list-item {
    display: inline-block;
    text-align: left;
    margin-left: 0;
}
.wpcf7-form input[type="submit"].wpcf7-submit {
    display: table; 
    margin-left: auto;
    margin-right: auto;
    /* line-height: 1.2; */
}
/* .wpcf7-form input[type="submit"].wpcf7-submit:hover {
    background-color: var(--button-primary-bg-hover-color);
    color: var(--button-primary-text-hover-color);
    border-color: var(--button-primary-border-hover-color);
} */

/* Responsive CF7 Styles */
@media screen and (max-width: 768px) {
    .wpcf7-form .form-row-cf7 {
        flex-direction: column;
        gap: 0;
    }
    .wpcf7-form .form-field-half-cf7 {
        margin-bottom: 1.5em;
    }
    .wpcf7-form .form-field-half-cf7,
    .wpcf7-form .form-field-full-cf7 {
        flex-basis: 100%;
        text-align: center;
    }
    /* Center the text content of paragraphs within the form on smaller screens */
    .wpcf7-form p {
        text-align: center;
    }

    .wpcf7-form-control.wpcf7-text,
    .wpcf7-form-control.wpcf7-textarea,
    .wpcf7-form-control.wpcf7-select {
        width: 100%;
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
        display: block;
        text-align: left;
    }
    .wpcf7-form .form-field-consent-cf7 .wpcf7-list-item {
         max-width: 90%;
    }
}

/* --- Overrides to keep CF7 labels left-aligned and the form centered when
   the CF7 form is placed inside front-page-style sections (ex: page-temoignages)
   These rules prevent the parent .front-page-section { text-align: center } from
   centering labels and form content on desktop. Mobile centering rules above
   will still apply where appropriate. */
.page-temoignages-partenaires-content .child-page-section .wpcf7-form {
    max-width: 760px; /* keep the form a readable width */
    margin-left: auto;
    margin-right: auto; /* center the form block inside the section */
    text-align: left; /* ensure inputs and labels are left-aligned by default */
}

.page-temoignages-partenaires-content .child-page-section .wpcf7-form p {
    text-align: left; /* paragraphs inside the form (CF7 outputs <p>) */
}

.page-temoignages-partenaires-content .child-page-section .wpcf7-form label {
    text-align: left; /* explicit: labels must stay left-aligned */
    display: block; /* keep labels on their own line */
}

/* Keep existing mobile rule (center inputs on small screens) — override only when narrow
   viewports need the inputs centered while labels can remain left if desired. */
@media screen and (max-width: 768px) {
    .page-temoignages-partenaires-content .child-page-section .wpcf7-form,
    .page-temoignages-partenaires-content .child-page-section .wpcf7-form,
    .page-temoignages-partenaires-content .child-page-section .wpcf7-form p,
    .page-temoignages-partenaires-content .child-page-section .wpcf7-form .wpcf7-form-control-wrap {
        text-align: center; /* keep the compact/mobile layout centered */
        width: 100%;
        max-width: 650px; /* limit on mobile for nicer reading */
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box;
    }
    /* On mobile, center labels above the inputs so they don't stay stuck on the left edge */
    .page-temoignages-partenaires-content .child-page-section .wpcf7-form label {
        text-align: center;
        display: block;
    }
}

/* Ensure each CF7 paragraph/control-wrap inside the testimonials section
   is constrained to the same centered width as the form on desktop too. */
.page-temoignages-partenaires-content .child-page-section .wpcf7-form p,
.page-temoignages-partenaires-content .child-page-section .wpcf7-form .wpcf7-form-control-wrap {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* Align form-row items to the top so labels for two-column fields line up */
.page-temoignages-partenaires-content .child-page-section .wpcf7-form .form-row-cf7 {
    align-items: flex-start;
}


/* For half fields ensure they use full width of their column */
.page-temoignages-partenaires-content .child-page-section .wpcf7-form .form-field-half-cf7 {
    flex: 1 1 calc(50% - 10px);
}

/* Minimal visibility helpers for CF7 messages on the Témoignages page
   We intentionally avoid changing colors or backgrounds so default CF7
   styles (and user expectations) remain intact. */
.page-temoignages-partenaires-content .child-page-section .wpcf7-not-valid-tip {
    display: inline-block !important;
    margin-top: 6px;
    z-index: 9999;
    position: relative; /* keep it in flow so it doesn't overlap unexpectedly */
}

.page-temoignages-partenaires-content .child-page-section .wpcf7-response-output {
    display: block !important;
    border: transparent;
    margin-top: 12px;
    text-align: center;
}

/* If service families are disabled in the theme, hide the prestation select field
   as it will be empty; server-side removal is preferred, this is a safety fallback. */
body.no-service-families .wpcf7-form select[name*="presta"],
body.no-service-families .wpcf7-form .wpcf7-form-control-wrap[class*="presta"] {
    display: none !important;
}

/* More specific fallback targeting the exact field name and the CF7 data-name wrapper */
body.no-service-families .wpcf7-form select[name="prestation-concernee"],
body.no-service-families .wpcf7-form .wpcf7-form-control-wrap[data-name="prestation-concernee"] {
    display: none !important;
}
