.d4ca-wpforms,
.d4ca-wpforms * {
    box-sizing: border-box;
}

.d4ca-wpforms .wpforms-container {
    max-width: 100%;
}

.d4ca-wpforms input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="hidden"]),
.d4ca-wpforms select,
.d4ca-wpforms textarea {
    max-width: 100% !important;
}

/* Baseline background/text colour for dropdowns, overridable by the
   Select Fields Background/Text Color controls (see
   widgets/class-wpforms-widget.php). WPForms' own "Classic" select style
   ships its own CSS — `.wpforms-field-select-style-classic select` —
   that sets its own background/text colour WITH `!important` already on
   it. Unlike a plain <input type="text">, which has no equivalent
   WPForms theme CSS and so just shows the browser's default white, a
   <select> with the Classic style always has *something* opinionated
   behind it, which is why it can look visibly different from the text
   inputs next to it with zero D4 configuration involved.

   Since WPForms' own rule is already `!important`, matching `!important`
   here isn't enough on its own — with both sides `!important`,
   specificity decides the tie, so this selector is deliberately written
   to out-specify theirs rather than just out-`!important` them:
   `.d4ca-wpforms.d4ca-wpforms` repeats the same class to double its
   specificity weight, and the rule also names WPForms' own
   `.wpforms-field-select-style-classic` class directly so it wins even
   if their actual selector turns out to be more specific than it looks.
   The Select Fields colour controls still override this in turn, since
   Elementor's per-instance generated CSS also carries `!important` on
   its own selector output and loads after this stylesheet. */
.d4ca-wpforms.d4ca-wpforms select:not([multiple]),
.d4ca-wpforms.d4ca-wpforms .wpforms-field-select-style-classic select:not([multiple]) {
    background-color: #fff !important;
    color: #2c3338 !important;
}

.d4ca-wpforms-button-full-yes .d4ca-wpforms button.wpforms-submit {
    width: 100% !important;
}

/* Submit button icon (see widgets/class-wpforms-widget.php). An uploaded
   SVG is rendered as a mask-image pseudo-element directly on WPForms' own
   real <button> — a per-instance <style> tag sets that up, this stylesheet
   only needs to be there to size/position/colour it via the Icon
   controls — so it's genuinely part of the button, not a separate
   element, and needs none of the rules below.

   The rules below are the fallback used only for a font-library icon
   (Font Awesome etc.), which can't be expressed as a mask-image: WPForms
   gives no way to inject real markup inside its own <button>, only two
   action hooks that echo beside it, so that icon is a DOM sibling,
   absolutely positioned over the button's edge rather than truly inside
   it. It sits above the button (z-index) but ignores clicks
   (pointer-events: none) so the button underneath stays fully clickable
   through it. Only applies when an icon is actually set (the
   "has-btn-icon" modifier), so a form with no icon is completely
   unaffected. If the icon overlaps the button's own text, increase the
   button's Padding on that side (see Icon Spacing's description above) —
   there's no way to reserve that space automatically without fighting the
   Padding control. */
.d4ca-wpforms-has-btn-icon .wpforms-submit-container {
    position: relative;
    display: inline-block;
}

.d4ca-wpforms-button-full-yes.d4ca-wpforms-has-btn-icon .wpforms-submit-container {
    display: block;
    width: 100%;
}

.d4ca-wpforms-btn-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    line-height: 1;
    pointer-events: none;
    z-index: 1;
}

.d4ca-wpforms-btn-icon-before {
    left: 16px;
}

.d4ca-wpforms-btn-icon-after {
    right: 16px;
}

.d4ca-wpforms-btn-icon i,
.d4ca-wpforms-btn-icon svg {
    display: block;
}

/* Optional fully custom checkbox/radio appearance. */
.d4ca-custom-choice-yes .d4ca-wpforms input[type="checkbox"],
.d4ca-custom-choice-yes .d4ca-wpforms input[type="radio"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    position: relative;
    display: inline-grid !important;
    place-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 0 8px 0 0 !important;
    padding: 0 !important;
    border: 1px solid #b8bcc2;
    background: #fff;
    color: #fff;
    vertical-align: middle;
    cursor: pointer;
    box-shadow: none;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.d4ca-custom-choice-yes .d4ca-wpforms input[type="checkbox"] {
    border-radius: 3px;
}

.d4ca-custom-choice-yes .d4ca-wpforms input[type="checkbox"]:checked::after {
    content: "";
    width: 32%;
    height: 58%;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-5%, -8%);
    transform-origin: center;
}

.d4ca-custom-choice-yes .d4ca-wpforms input[type="radio"] {
    border-radius: 50%;
}

.d4ca-custom-choice-yes .d4ca-wpforms input[type="radio"]:checked::after {
    content: "";
    width: 44%;
    height: 44%;
    border-radius: 50%;
    background: currentColor;
}

.d4ca-custom-choice-yes .d4ca-wpforms input[type="checkbox"]:focus-visible,
.d4ca-custom-choice-yes .d4ca-wpforms input[type="radio"]:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Optional fully custom select-arrow styling (see widgets/class-wpforms-widget.php
   Style > Select Fields). appearance:none strips the browser's own
   chevron — which differs across OS/browser and can't otherwise be
   recoloured or resized — and ::after draws a replacement sized/coloured
   by the Arrow Size/Color/Offset controls via the custom properties they
   set. Works the same way the custom checkbox/radio ::after above does:
   once appearance:none + position:relative take it out of native platform
   rendering, modern browsers do render generated content on it. Excludes
   [multiple] list boxes, which never had a dropdown arrow to replace. */
.d4ca-custom-select-yes .d4ca-wpforms select:not([multiple]) {
    --d4ca-select-arrow-color: #495057;
    --d4ca-select-arrow-size: 5px;
    --d4ca-select-arrow-offset: 16px;
    -webkit-appearance: none !important;
    appearance: none !important;
    position: relative;
    background-image: none !important;
    padding-right: calc(var(--d4ca-select-arrow-offset) * 2 + var(--d4ca-select-arrow-size)) !important;
}

.d4ca-custom-select-yes .d4ca-wpforms select:not([multiple])::after {
    content: "";
    position: absolute;
    top: 50%;
    right: var(--d4ca-select-arrow-offset);
    width: 0;
    height: 0;
    border-left: var(--d4ca-select-arrow-size) solid transparent;
    border-right: var(--d4ca-select-arrow-size) solid transparent;
    border-top: var(--d4ca-select-arrow-size) solid var(--d4ca-select-arrow-color);
    transform: translateY(-25%);
    pointer-events: none;
}

/* Keep WPForms honeypots inaccessible if delayed JS momentarily misses its inline style. */
.d4ca-wpforms .wpforms-field > label[aria-hidden="true"] + input[aria-hidden="true"][tabindex="-1"] {
    position: absolute !important;
    left: -99999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}


/* D4 WPForms focus compatibility.
 * Keep WPForms Modern's built-in blue focus accent from sitting over the
 * Elementor focus styles. Scoped to D4 WPForms only.
 */
.d4ca-wpforms {
    --wpforms-field-focus-color: transparent;
}

.d4ca-wpforms input:focus,
.d4ca-wpforms input:focus-visible,
.d4ca-wpforms select:focus,
.d4ca-wpforms select:focus-visible,
.d4ca-wpforms textarea:focus,
.d4ca-wpforms textarea:focus-visible {
    outline: none !important;
}
