/* Contact Form 7 Custom Styles - Maintains existing form design */

/* Form wrapper and layout */
.wpcf7 {
    width: 100%;
}

.wpcf7 .form-row-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    align-items: start;
}

.wpcf7 .form-row-wrapper .inner-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
}

/* First inner-row: left column - wraps 4 inputs in 2x2 grid, then checkboxes full width below */
.wpcf7 .form-row-wrapper .inner-row:first-child {
    grid-column: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
}

/* Second inner-row (subject-message): right column - message textarea + submit */
.wpcf7 .form-row-wrapper .inner-row.subject-message {
    grid-column: 2;
    display: flex;
    flex-direction: column;
}

/* Submit button container */
.wpcf7 .form-row-wrapper .inner-row.subject-message .submit {
    display: flex;
    justify-content: flex-end;
}

/* Inputs in left column: 2x2 grid (each takes 50% width minus gap) */
.wpcf7 .form-row-wrapper .inner-row:first-child > :is(.first-name, .last-name, .email, .phone) {
    flex: 1 1 calc(50% - 8px);
    min-width: calc(50% - 8px);
    width: calc(50% - 8px);
}

/* Checkboxes in first inner-row (left column): full width, appear below the 2x2 grid */
.wpcf7 .form-row-wrapper .inner-row:first-child .clausule,
.wpcf7 .form-row-wrapper .inner-row:first-child .email-processing,
.wpcf7 .form-row-wrapper .inner-row:first-child .phone-processing {
    flex: 1 1 100% !important;
    min-width: 100% !important;
    width: 100% !important;
    margin-top: 16px;
    margin-bottom: 8px;
}

.wpcf7 .form-row-wrapper .inner-row .form-group {
    flex: 1 1 calc(50% - 8px);
    min-width: calc(50% - 8px);
    margin-bottom: 0;
}

.wpcf7 .form-row-wrapper .inner-row .form-group label {
    display: block;
    margin-bottom: 8px;
}

/* Message and submit in subject-message take full width of their column */
.wpcf7 .form-row-wrapper .inner-row.subject-message > * {
    flex: 1 1 100%;
    min-width: 100%;
    width: 100%;
}

/* Checkboxes in subject-message: full width, appear below textarea */
.wpcf7 .form-row-wrapper .inner-row.subject-message .clausule,
.wpcf7 .form-row-wrapper .inner-row.subject-message .email-processing,
.wpcf7 .form-row-wrapper .inner-row.subject-message .phone-processing {
    flex: 1 1 100% !important;
    min-width: 100% !important;
    width: 100% !important;
    margin-bottom: 8px;
}

.wpcf7 .form-row-wrapper .inner-row.subject-message .message {
    margin-bottom: 16px;
}

/* Submit button alignment */
.wpcf7 .form-row-wrapper .inner-row.subject-message .submit {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.wpcf7 .form-row-wrapper .inner-row.subject-message .submit p {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin: 0;
}

/* Control order of button and spinner */
.wpcf7 .form-row-wrapper .inner-row.subject-message .submit p .wpcf7-submit {
    order: 2;
}

.wpcf7 .form-row-wrapper .inner-row.subject-message .submit p .wpcf7-spinner {
    order: 1;
    margin-right: 10px;
    margin-left: 0;
}

/* Override CF7 button classes to apply btn-default correctly */
.wpcf7 input[type="submit"].wpcf7-submit.btn.btn-default,
.wpcf7 button[type="submit"].wpcf7-submit.btn.btn-default,
.wpcf7 input[type="submit"].wpcf7-submit.btn.btn-primary,
.wpcf7 button[type="submit"].wpcf7-submit.btn.btn-primary {
    font-size: 16px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    border: none !important;
    transition: all 0.35s ease-in-out !important;
    font-family: "DM Sans", sans-serif !important;
    position: relative !important;
    overflow: hidden !important;
    padding: 8px 16px !important;
    color: #ffffff !important;
    white-space: nowrap !important;
    background: #202126 !important;
    cursor: pointer !important;
    display: inline-block !important;
    width: auto !important;
}

/* Desktop: push button to the right */
@media (min-width: 768px) {
    .wpcf7 input[type="submit"].wpcf7-submit.btn.btn-default,
    .wpcf7 button[type="submit"].wpcf7-submit.btn.btn-default,
    .wpcf7 input[type="submit"].wpcf7-submit.btn.btn-primary,
    .wpcf7 button[type="submit"].wpcf7-submit.btn.btn-primary {
        margin-left: auto !important;
        margin-right: 0 !important;
    }
}

/* Hover state */
.wpcf7 input[type="submit"].wpcf7-submit.btn.btn-default:hover,
.wpcf7 button[type="submit"].wpcf7-submit.btn.btn-default:hover,
.wpcf7 input[type="submit"].wpcf7-submit.btn.btn-primary:hover,
.wpcf7 button[type="submit"].wpcf7-submit.btn.btn-primary:hover {
    background: #ff004e !important;
}

/* Form controls */
.wpcf7 .wpcf7-form-control-wrap {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
}

.wpcf7 input:not([type="checkbox"]):not([type="submit"]):not([type="radio"]),
.wpcf7 textarea,
.wpcf7 select,
.wpcf7 .wpcf7-form-control:not(.wpcf7-acceptance):not([type="checkbox"]) {
    width: 100%;
    background: var(--color-white);
    font-size: 14px;
    border-radius: 0px;
    line-height: 24px !important;
    padding: 8px 16px;
    box-shadow: 0px 1px 2px 0px #1018280d;
    border: none !important;
    font-family: inherit;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    display: block;
}

/* Make sure checkbox wrappers don't get these styles */
.wpcf7 .wpcf7-form-control-wrap.wpcf7-acceptance,
.wpcf7 .clausule .wpcf7-form-control-wrap,
.wpcf7 .email-processing .wpcf7-form-control-wrap,
.wpcf7 .phone-processing .wpcf7-form-control-wrap {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
}

.wpcf7 textarea {
    min-height: 120px;
    resize: vertical;
    width: 100% !important;
}

/* Submit button */
.wpcf7 .submit-wrapper {
    width: 100%;
}

/* Validation and errors */
.wpcf7 .wpcf7-not-valid-tip {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.wpcf7 .wpcf7-not-valid {
    border: 1px solid #dc3545 !important;
}

.wpcf7 .wpcf7-response-output {
    margin: 16px 0;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
}

.wpcf7 .wpcf7-validation-errors {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.wpcf7 .wpcf7-mail-sent-ok {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.wpcf7 .wpcf7-spam-blocked,
.wpcf7 .wpcf7-aborted {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Acceptance/Checkbox fields */
.wpcf7 .clausule-wrapper {
    margin-top: 8px;
}

.wpcf7 .wpcf7-acceptance,
.wpcf7 .clausule,
.wpcf7 .email-processing,
.wpcf7 .phone-processing {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    width: 100% !important;
    border: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

/* CF7 wraps checkboxes in wpcf7-form-control-wrap - make it inline */
.wpcf7 .clausule .wpcf7-form-control-wrap,
.wpcf7 .email-processing .wpcf7-form-control-wrap,
.wpcf7 .phone-processing .wpcf7-form-control-wrap {
    display: inline-flex !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
}

.wpcf7 .wpcf7-acceptance input[type="checkbox"],
.wpcf7 .clausule input[type="checkbox"],
.wpcf7 .email-processing input[type="checkbox"],
.wpcf7 .phone-processing input[type="checkbox"] {
    margin: 3px 8px 0 0 !important;
    padding: 0 !important;
    width: auto !important;
    flex-shrink: 0;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
}

.wpcf7 .wpcf7-acceptance .wpcf7-list-item,
.wpcf7 .clausule .wpcf7-list-item,
.wpcf7 .email-processing .wpcf7-list-item,
.wpcf7 .phone-processing .wpcf7-list-item {
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 0 !important;
}

.wpcf7 .wpcf7-acceptance label,
.wpcf7 .clausule label,
.wpcf7 .email-processing label,
.wpcf7 .phone-processing label {
    font-size: 12px !important;
    line-height: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 1;
    display: inline !important;
    opacity: 0.6 !important;
    color: #202126 !important;
}

.wpcf7 .email-processing label,
.wpcf7 .phone-processing label {
    display: flex !important;
}

.wpcf7 .wpcf7-list-item-label {
    margin: 0 !important;
    padding: 0 !important;
}

.wpcf7 .data-info {
    margin-top: 16px;
}

.wpcf7 .data-info p,
.wpcf7 .data-info .small-text {
    font-size: 12px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* Form wrapper context */
.form-wrapper .wpcf7 {
    background: transparent;
}

.get-in-touch .form-wrapper .wpcf7 .form-row-wrapper {
    flex-direction: column;
}

.get-in-touch .form-wrapper .wpcf7 .form-row-wrapper .inner-row {
    min-width: 100%;
    width: 100%;
    /* Keep the 2-column grid for desktop */
}

/* Widget contact form */
.widget-contact-form .wpcf7 .form-row-wrapper {
    flex-direction: column;
}

.widget-contact-form .wpcf7 .form-row-wrapper .inner-row {
    min-width: 100%;
}

/* Loading spinner */
.wpcf7 .ajax-loader {
    display: none;
}

.wpcf7.submitting .ajax-loader {
    display: inline-block;
    margin-left: 10px;
}

/* Form in modal */
.modal .wpcf7 .form-row-wrapper {
    flex-direction: column;
}

.modal .wpcf7 .form-row-wrapper .inner-row {
    width: 100%;
    min-width: 100%;
}

/* Contact page specific - force mobile layout at all screen sizes */
.contact-page-form .wpcf7 .form-row-wrapper {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    width: 100% !important;
    max-width: 100% !important;
    grid-template-columns: 1fr !important; /* Override grid */
}

/* First inner-row should display as flex with wrapping for 2x2 grid */
.contact-page-form .wpcf7 .form-row-wrapper .inner-row:first-child {
    width: 100% !important;
    max-width: 100% !important;
    grid-column: 1 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 16px !important;
}

/* Subject-message row stacks below - use grid for proper layout */
.contact-page-form .wpcf7 .form-row-wrapper .inner-row.subject-message {
    width: 100% !important;
    max-width: 100% !important;
    grid-column: 1 !important;
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
}

/* First 4 fields use 50% width in 2x2 grid */
.contact-page-form .wpcf7 .form-row-wrapper .inner-row:first-child > :is(.first-name, .last-name, .email, .phone) {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: calc(50% - 8px) !important;
    width: calc(50% - 8px) !important;
    max-width: calc(50% - 8px) !important;
    box-sizing: border-box !important;
}

/* Checkboxes take full width below the 2x2 grid */
.contact-page-form .wpcf7 .form-row-wrapper .inner-row .clausule,
.contact-page-form .wpcf7 .form-row-wrapper .inner-row:first-child .clausule,
.contact-page-form .wpcf7 .form-row-wrapper .inner-row:first-child .email-processing,
.contact-page-form .wpcf7 .form-row-wrapper .inner-row:first-child .phone-processing {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
    margin-top: 0 !important;
    margin-bottom: 8px !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
}

/* Textarea takes full width */
.contact-page-form .wpcf7 .form-row-wrapper .inner-row.subject-message .message {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin-bottom: 16px !important;
}

/* Submit container takes full width and contains the button */
.contact-page-form .wpcf7 .form-row-wrapper .inner-row.subject-message .submit {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
}

.contact-page-form .wpcf7 .form-row-wrapper .inner-row.subject-message .submit p {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    display: block !important;
}

/* Button takes full width and stays within container */
.contact-page-form .wpcf7 input[type="submit"].wpcf7-submit.btn.btn-default,
.contact-page-form .wpcf7 button[type="submit"].wpcf7-submit.btn.btn-default,
.contact-page-form .wpcf7 input[type="submit"].wpcf7-submit.btn.btn-primary,
.contact-page-form .wpcf7 button[type="submit"].wpcf7-submit.btn.btn-primary {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

/* Override desktop margin-left for contact page */
@media (min-width: 768px) {
    .contact-page-form .wpcf7 input[type="submit"].wpcf7-submit.btn.btn-default,
    .contact-page-form .wpcf7 button[type="submit"].wpcf7-submit.btn.btn-default,
    .contact-page-form .wpcf7 input[type="submit"].wpcf7-submit.btn.btn-primary,
    .contact-page-form .wpcf7 button[type="submit"].wpcf7-submit.btn.btn-primary {
        margin-left: 0 !important;
    }
}

/* Responsive adjustments */
@media (max-width: 767px) {
    /* Change to single column layout */
    .wpcf7 .form-row-wrapper {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Both inner-rows stack naturally */
    .wpcf7 .form-row-wrapper .inner-row:first-child,
    .wpcf7 .form-row-wrapper .inner-row.subject-message {
        width: 100% !important;
        max-width: 100% !important;
        grid-column: unset !important;
        box-sizing: border-box !important;
    }

    /* Make all inputs 100% width on mobile */
    .wpcf7 .form-row-wrapper .inner-row:first-child > :is(.first-name, .last-name, .email, .phone) {
        flex: 1 1 100% !important;
        min-width: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Checkboxes full width and contained within viewport */
    .wpcf7 .form-row-wrapper .inner-row .clausule,
    .wpcf7 .form-row-wrapper .inner-row:first-child .clausule,
    .wpcf7 .form-row-wrapper .inner-row:first-child .email-processing,
    .wpcf7 .form-row-wrapper .inner-row:first-child .phone-processing {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
        box-sizing: border-box !important;
        margin-top: 0 !important;
        margin-bottom: 8px !important;
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
    }

    /* Ensure checkbox labels don't overflow */
    .wpcf7 .form-row-wrapper .inner-row .clausule label,
    .wpcf7 .wpcf7-acceptance label {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Message textarea full width */
    .wpcf7 .form-row-wrapper .inner-row.subject-message .message {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Submit button 100% width and left aligned on mobile */
    .wpcf7 .form-row-wrapper .inner-row.subject-message .submit {
        justify-content: flex-start !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .wpcf7 input[type="submit"].wpcf7-submit.btn.btn-default,
    .wpcf7 button[type="submit"].wpcf7-submit.btn.btn-default,
    .wpcf7 input[type="submit"].wpcf7-submit.btn.btn-primary,
    .wpcf7 button[type="submit"].wpcf7-submit.btn.btn-primary {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }

    /* Prevent any overflow */
    .wpcf7 form,
    .wpcf7 .form-row-wrapper,
    .wpcf7 .inner-row {
        overflow: hidden !important;
        max-width: 100% !important;
    }
}

/* Screen reader text */
.wpcf7 .screen-reader-response {
    position: absolute;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    height: 1px;
    width: 1px;
    margin: 0;
    padding: 0;
    border: 0;
}

/* Placeholder styles */
.wpcf7 input::placeholder,
.wpcf7 textarea::placeholder {
    color: #999;
    opacity: 1;
}

/* Focus states */
.wpcf7 input:not([type="checkbox"]):not([type="submit"]):focus,
.wpcf7 textarea:focus,
.wpcf7 select:focus {
    outline: 2px solid #FF004E;
    outline-offset: 2px;
}

