/* LRob Email Toolkit — frontend form styles. Docs: docs/forms.md */

.lrob-etk-form {
    --lrob-etk-cf-font:        inherit;
    --lrob-etk-cf-font-size:   var(--wp--preset--font-size--medium, 1rem);
    --lrob-etk-cf-radius:      8px;
    --lrob-etk-cf-spacing:     1rem;
    --lrob-etk-cf-accent:      var(--wp--preset--color--primary, #2563eb);
    /* Fixed light default — theme base color clashes on dark accents. */
    --lrob-etk-cf-accent-fg:   #fff;
    --lrob-etk-cf-border:      var(--wp--preset--color--tertiary, #cbd5e1);
    --lrob-etk-cf-border-focus: var(--lrob-etk-cf-accent);
    --lrob-etk-cf-bg:          var(--wp--preset--color--base, #fff);
    /* inherit — contrast preset is FSE-wide, not context-aware */
    --lrob-etk-cf-fg:          inherit;
    /* contrast hook: inputs sit on --cf-bg (light), so needs light-content text */
    --lrob-etk-cf-input-fg:    var(--wp--preset--color--contrast, #0f172a);
    --lrob-etk-cf-muted:       #64748b;
    --lrob-etk-form-error:       #b91c1c;
    --lrob-etk-form-error-bg:    #fef2f2;
    --lrob-etk-cf-success-bg:  #ecfdf5;
    --lrob-etk-cf-success-fg:  #065f46;
    --lrob-etk-cf-shadow-focus: 0 0 0 3px color-mix(in srgb, var(--lrob-etk-cf-accent) 22%, transparent);
    --lrob-etk-cf-shadow:        0 1px 0 rgba(0,0,0,.04), 0 2px 6px rgba(0,0,0,.08);
    --lrob-etk-cf-shadow-hover:  0 2px 4px rgba(0,0,0,.06), 0 6px 12px rgba(0,0,0,.10);
    --lrob-etk-cf-shadow-menu:   0 6px 16px rgba(0,0,0,.12);
    --lrob-etk-cf-trans:       180ms cubic-bezier(.2,.7,.2,1);

    font-family: var(--lrob-etk-cf-font);
    font-size: var(--lrob-etk-cf-font-size);
    color: var(--lrob-etk-cf-fg);
    display: block;
    position: relative;
    max-width: 100%;
}

.lrob-etk-form *, .lrob-etk-form *::before, .lrob-etk-form *::after {
    box-sizing: border-box;
}

.lrob-etk-form .lrob-etk-form-body {
    display: grid;
    gap: var(--lrob-etk-cf-spacing);
}

.lrob-etk-form .lrob-etk-form-row {
    display: grid;
    gap: var(--lrob-etk-cf-spacing);
    grid-template-columns: 1fr;
}
.lrob-etk-form .lrob-etk-form-row[data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
.lrob-etk-form .lrob-etk-form-row[data-cols="3"] { grid-template-columns: repeat(3, 1fr); }
.lrob-etk-form .lrob-etk-form-row[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 600px) {
    .lrob-etk-form .lrob-etk-form-row[data-cols] {
        grid-template-columns: 1fr;
    }
}
.lrob-etk-form .lrob-etk-form-col {
    display: flex;
    flex-direction: column;
    gap: var(--lrob-etk-cf-spacing);
    min-width: 0;
}

/* Field wrapper */
.lrob-etk-form-field {
    display: flex;
    flex-direction: column;
    gap: .35em;
    border: 0;
    padding: 0;
    margin: 0;
    min-width: 0;
}

.lrob-etk-form-label {
    font-weight: 600;
    font-size: .95em;
    line-height: 1.3;
    color: var(--lrob-etk-cf-fg);
    text-transform: none;
}

.lrob-etk-form-required {
    color: var(--lrob-etk-form-error);
    font-weight: 700;
    margin-left: .15em;
}

.lrob-etk-form-helper {
    margin: 0;
    color: var(--lrob-etk-cf-muted);
    font-size: .82em;
    line-height: 1.4;
}

.lrob-etk-form-error {
    margin: 0;
    color: var(--lrob-etk-form-error);
    font-size: .82em;
    line-height: 1.4;
    font-weight: 500;
}

/* Inputs */
.lrob-etk-form input[type="text"],
.lrob-etk-form input[type="email"],
.lrob-etk-form input[type="tel"],
.lrob-etk-form input[type="number"],
.lrob-etk-form input[type="date"],
.lrob-etk-form select,
.lrob-etk-form textarea {
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    color: var(--lrob-etk-cf-input-fg);
    background: var(--lrob-etk-cf-bg);
    border: 1px solid var(--lrob-etk-cf-border);
    border-radius: var(--lrob-etk-cf-radius);
    padding: .65em .85em;
    width: 100%;
    min-height: 2.5em;
    line-height: 1.4;
    transition: border-color var(--lrob-etk-cf-trans), box-shadow var(--lrob-etk-cf-trans), background-color var(--lrob-etk-cf-trans);
}

.lrob-etk-form textarea {
    resize: vertical;
    min-height: 6em;
}

.lrob-etk-form input:focus,
.lrob-etk-form select:focus,
.lrob-etk-form textarea:focus {
    outline: 0;
    border-color: var(--lrob-etk-cf-border-focus);
    box-shadow: var(--lrob-etk-cf-shadow-focus);
}

.lrob-etk-form input::placeholder,
.lrob-etk-form textarea::placeholder {
    color: var(--lrob-etk-cf-muted);
    opacity: .8;
}

/* Field-level error state */
.lrob-etk-form-field.is-invalid input,
.lrob-etk-form-field.is-invalid select,
.lrob-etk-form-field.is-invalid textarea {
    border-color: var(--lrob-etk-form-error);
    background: var(--lrob-etk-form-error-bg);
}

.lrob-etk-form-field.is-invalid .lrob-etk-form-error {
    display: block;
}

/* Options (radio / checkbox group) */
.lrob-etk-form-options {
    display: flex;
    flex-direction: column;
    gap: .35em;
}

.lrob-etk-form-option,
.lrob-etk-form-checkbox-inline {
    display: inline-flex;
    align-items: flex-start;
    gap: .55em;
    cursor: pointer;
    font-weight: 400;
    line-height: 1.35;
    padding: .25em 0;
}

.lrob-etk-form-option input,
.lrob-etk-form-checkbox-inline input {
    appearance: auto;
    -webkit-appearance: auto;
    margin: .2em 0 0 0;
    width: 1em;
    height: 1em;
    accent-color: var(--lrob-etk-cf-accent);
    flex: 0 0 auto;
}

/* Submit */
.lrob-etk-form-field--submit {
    margin-top: .25em;
}

.lrob-etk-form-field--submit.is-align-left  { align-items: flex-start; }
.lrob-etk-form-field--submit.is-align-center{ align-items: center; }
.lrob-etk-form-field--submit.is-align-right { align-items: flex-end; }
.lrob-etk-form-field--submit.is-align-stretch .lrob-etk-form-submit { width: 100%; }

.lrob-etk-form-submit {
    position: relative;
    appearance: none;
    border: 0;
    background: var(--lrob-etk-cf-accent);
    color: var(--lrob-etk-cf-accent-fg);
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    padding: .8em 1.6em;
    border-radius: var(--lrob-etk-cf-radius);
    cursor: pointer;
    transition: transform var(--lrob-etk-cf-trans), opacity var(--lrob-etk-cf-trans), filter var(--lrob-etk-cf-trans), box-shadow var(--lrob-etk-cf-trans);
    box-shadow: var(--lrob-etk-cf-shadow);
}

.lrob-etk-form-submit:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: var(--lrob-etk-cf-shadow-hover);
}

.lrob-etk-form-submit:focus {
    outline: 0;
    box-shadow: var(--lrob-etk-cf-shadow-focus), var(--lrob-etk-cf-shadow);
}

.lrob-etk-form-submit:active {
    transform: translateY(0);
}

.lrob-etk-form-submit[disabled],
.lrob-etk-form-submit.is-busy {
    opacity: .7;
    cursor: progress;
    transform: none;
    filter: none;
}

.lrob-etk-form-submit-spinner {
    display: none;
    width: .9em;
    height: .9em;
    margin-left: .55em;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    vertical-align: -.15em;
    animation: lrob-etk-cf-spin .7s linear infinite;
}

.lrob-etk-form-submit.is-busy .lrob-etk-form-submit-spinner {
    display: inline-block;
}

@keyframes lrob-etk-cf-spin { to { transform: rotate(360deg); } }

/* Status banner above the form */
.lrob-etk-form-status {
    border-radius: var(--lrob-etk-cf-radius);
    padding: .8em 1em;
    margin-bottom: var(--lrob-etk-cf-spacing);
    font-size: .95em;
    line-height: 1.45;
    border: 1px solid transparent;
    animation: lrob-etk-cf-slide-in 280ms cubic-bezier(.2,.7,.2,1);
}

.lrob-etk-form-status.is-success {
    background: var(--lrob-etk-cf-success-bg);
    color: var(--lrob-etk-cf-success-fg);
    border-color: color-mix(in srgb, var(--lrob-etk-cf-success-fg) 18%, transparent);
}

.lrob-etk-form-status.is-error {
    background: var(--lrob-etk-form-error-bg);
    color: var(--lrob-etk-form-error);
    border-color: color-mix(in srgb, var(--lrob-etk-form-error) 25%, transparent);
}

@keyframes lrob-etk-cf-slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Hide the whole form body after a successful send so the user doesn't accidentally
 * spam by clicking again. The status banner remains. */
.lrob-etk-form.is-sent .lrob-etk-form-body { display: none; }

/* Honeypot hard hide (also hidden inline by PHP) */
.lrob-etk-cf-hp {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* Editor parity: placeholder for the embed block when no form is selected */
.lrob-etk-cf-placeholder {
    font-family: -apple-system, system-ui, sans-serif;
    border-radius: var(--lrob-etk-cf-radius);
}

/* Preset: minimal — flat, no shadows, sharper corners */
.lrob-etk-form-preset--minimal {
    --lrob-etk-cf-radius: 4px;
}
.lrob-etk-form-preset--minimal .lrob-etk-form-submit {
    box-shadow: none;
}
.lrob-etk-form-preset--minimal .lrob-etk-form-submit:hover {
    box-shadow: none;
    transform: none;
}

/* Preset: soft — heavier roundness, lighter colors */
.lrob-etk-form-preset--soft {
    --lrob-etk-cf-radius: 14px;
    --lrob-etk-cf-border: #e2e8f0;
    --lrob-etk-cf-accent: #8b5cf6;
    --lrob-etk-cf-shadow-focus: 0 0 0 3px rgba(139, 92, 246, .22);
}

/* Preset: contrast — high-contrast, accessible */
.lrob-etk-form-preset--contrast {
    --lrob-etk-cf-accent: #0f172a;
    --lrob-etk-cf-fg: #0f172a;
    --lrob-etk-cf-border: #0f172a;
    --lrob-etk-cf-shadow-focus: 0 0 0 3px rgba(15, 23, 42, .25);
}

/* Homemade challenge — self-contained so it renders identically inside
 * .lrob-etk-form, the editor preview, AND the captcha-settings preview
 * (which has no .lrob-etk-form input scope). */
.lrob-etk-cf-challenge {
    display: flex;
    flex-direction: column;
    gap: .35em;
}
.lrob-etk-cf-challenge .lrob-etk-cf-label {
    font-weight: 600;
    font-size: .95em;
    line-height: 1.3;
    color: var(--lrob-etk-cf-fg);
}
.lrob-etk-cf-challenge input[type="text"] {
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    color: var(--lrob-etk-cf-input-fg);
    background: var(--lrob-etk-cf-bg);
    border: 1px solid var(--lrob-etk-cf-border);
    border-radius: var(--lrob-etk-cf-radius);
    padding: .5em .7em;
    width: auto;
    max-width: 7em;
    line-height: 1.4;
}
.lrob-etk-cf-challenge .lrob-etk-cf-helper {
    margin: 0;
    font-size: .82em;
    line-height: 1.4;
    color: var(--lrob-etk-cf-muted);
}
.lrob-etk-cf-challenge .lrob-etk-cf-error {
    margin: 0;
    font-size: .82em;
    line-height: 1.4;
    color: var(--lrob-etk-form-error);
}

/* Captcha injected into WP-native forms (comments / login / register /
 * lost-password) via WpHooks — a .lrob-etk-form host with breathing room
 * from the surrounding form fields + submit button. */
.lrob-etk-captcha-wrap {
    margin: 1em 0;
}
.lrob-etk-captcha-wrap--lost-password,
.lrob-etk-captcha-wrap--registration,
.lrob-etk-captcha-wrap--login {
    margin-bottom: 1.25em;
}

/* ---------- Image-recognition challenge ----------
 *
 * 6 radio inputs presented as small SVG tiles. The native radio is
 * visually hidden but keyboard-reachable; the SVG tile carries the
 * visible state via :checked + :focus-visible. Tiles have a fixed size
 * so the picker stays compact regardless of the surrounding form width.
 */
.lrob-etk-cf-challenge--image .lrob-etk-cf-image-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lrob-etk-cf-image-option {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    box-sizing: border-box;
    border: 1px solid var(--lrob-etk-cf-border);
    border-radius: var(--lrob-etk-cf-radius);
    background: var(--lrob-etk-cf-bg);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    margin: 0;
    color: var(--lrob-etk-cf-fg);
}
.lrob-etk-cf-image-option:hover {
    border-color: var(--lrob-etk-cf-accent);
    background: color-mix(in srgb, var(--lrob-etk-cf-accent) 4%, var(--lrob-etk-cf-bg));
}
.lrob-etk-cf-image-option input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.lrob-etk-cf-image-option:has(input[type="radio"]:checked) {
    border-color: var(--lrob-etk-cf-accent);
    border-width: 2px;
    background: color-mix(in srgb, var(--lrob-etk-cf-accent) 8%, transparent);
    color: var(--lrob-etk-cf-accent);
}
.lrob-etk-cf-image-option:has(input[type="radio"]:focus-visible) {
    box-shadow: var(--lrob-etk-cf-shadow-focus);
    outline: none;
}
.lrob-etk-cf-image-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.lrob-etk-cf-image-svg svg {
    width: 26px;
    height: 26px;
    display: block;
}

/* hCaptcha iframe doesn't shrink — allow horizontal scroll rather than overflow. */
.lrob-etk-form .lrob-etk-form-field--challenge {
    overflow-x: auto;
    max-width: 100%;
}
.lrob-etk-form .lrob-etk-cf-hcaptcha .h-captcha {
    min-width: 303px;
}

/* wp-login is ~270px; scale down full-size widgets to fit. */
.lrob-etk-captcha-wrap--narrow .lrob-etk-form-field--challenge {
    overflow: hidden;
}
.lrob-etk-captcha-wrap--narrow .h-captcha:not([data-size="compact"]),
.lrob-etk-captcha-wrap--narrow .g-recaptcha:not([data-size="compact"]),
.lrob-etk-captcha-wrap--narrow .cf-turnstile:not([data-size="compact"]) {
    transform: scale(0.88);
    transform-origin: top left;
}
.lrob-etk-captcha-wrap--narrow .h-captcha[data-size="compact"],
.lrob-etk-captcha-wrap--narrow .g-recaptcha[data-size="compact"],
.lrob-etk-captcha-wrap--narrow .cf-turnstile[data-size="compact"] {
    margin: 0 auto;
}

.lrob-etk-form .lrob-etk-form-captcha-align {
    display: flex;
    flex-direction: column;
}
.lrob-etk-form .lrob-etk-form-captcha-align.is-align-left   { align-items: flex-start; }
.lrob-etk-form .lrob-etk-form-captcha-align.is-align-center { align-items: center; }
.lrob-etk-form .lrob-etk-form-captcha-align.is-align-right  { align-items: flex-end; }

/* --- Phone country picker --- */
.lrob-etk-form .lrob-etk-form-phone {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    background: var(--lrob-etk-cf-bg);
    color: var(--lrob-etk-cf-input-fg);
    border: 1px solid var(--lrob-etk-cf-border);
    border-radius: var(--lrob-etk-cf-radius);
    overflow: visible; /* menu must spill out */
    transition: border-color var(--lrob-etk-cf-trans), box-shadow var(--lrob-etk-cf-trans);
}
.lrob-etk-form .lrob-etk-form-phone:focus-within {
    border-color: var(--lrob-etk-cf-border-focus);
    box-shadow: var(--lrob-etk-cf-shadow-focus);
}
.lrob-etk-form .lrob-etk-form-phone-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    margin: 0;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--lrob-etk-cf-border);
    border-radius: var(--lrob-etk-cf-radius) 0 0 var(--lrob-etk-cf-radius);
    cursor: pointer;
    font: inherit;
    color: var(--lrob-etk-cf-input-fg);
    line-height: 1;
}
.lrob-etk-form .lrob-etk-form-phone-trigger:hover { background: color-mix(in srgb, currentColor 6%, transparent); }
.lrob-etk-form .lrob-etk-form-phone-flag {
    font-size: 18px;
    line-height: 1;
    /* Disable WP emoji-img replacement so flags render as OS glyphs. */
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.lrob-etk-form .lrob-etk-form-phone-dial {
    font-size: 13px;
    opacity: 0.8;
}
.lrob-etk-form .lrob-etk-form-phone-caret {
    font-size: 16px;
    width: 16px;
    height: 16px;
    opacity: 0.6;
}
.lrob-etk-form .lrob-etk-form-phone input[type="tel"] {
    flex: 1;
    border: 0;
    outline: 0;
    box-shadow: none;
    padding: 8px 10px;
    min-width: 0;
    background: transparent;
    color: var(--lrob-etk-cf-input-fg);
    border-radius: 0 var(--lrob-etk-cf-radius) var(--lrob-etk-cf-radius) 0;
}
.lrob-etk-form .lrob-etk-form-phone-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 280px;
    max-width: 360px;
    max-height: 320px;
    background: var(--lrob-etk-cf-bg);
    color: var(--lrob-etk-cf-input-fg);
    border: 1px solid var(--lrob-etk-cf-border);
    border-radius: var(--lrob-etk-cf-radius);
    box-shadow: var(--lrob-etk-cf-shadow-menu);
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.lrob-etk-form .lrob-etk-form-phone-menu[hidden] { display: none; }
.lrob-etk-form .lrob-etk-form-phone-search {
    border: 0;
    border-bottom: 1px solid var(--lrob-etk-cf-border);
    border-radius: var(--lrob-etk-cf-radius) var(--lrob-etk-cf-radius) 0 0;
    padding: 8px 10px;
    outline: 0;
    font: inherit;
    color: var(--lrob-etk-cf-input-fg);
    background: transparent;
    width: 100%;
    box-sizing: border-box;
}
.lrob-etk-form .lrob-etk-form-phone-list {
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    flex: 1;
}
.lrob-etk-form .lrob-etk-form-phone-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    cursor: pointer;
}
.lrob-etk-form .lrob-etk-form-phone-list li:hover,
.lrob-etk-form .lrob-etk-form-phone-list li:focus {
    background: color-mix(in srgb, currentColor 8%, transparent);
}
.lrob-etk-form .lrob-etk-form-phone-list-flag {
    font-size: 18px;
    line-height: 1;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.lrob-etk-form .lrob-etk-form-phone-list-name {
    flex: 1;
    color: var(--lrob-etk-cf-input-fg);
}
.lrob-etk-form .lrob-etk-form-phone-list-dial {
    opacity: 0.65;
    font-size: 12px;
}

/* --- File upload --- */
.lrob-etk-form .lrob-etk-form-file {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}
.lrob-etk-form .lrob-etk-form-file-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: color-mix(in srgb, currentColor 8%, transparent);
    color: inherit;
    border: 1px dashed var(--lrob-etk-cf-border);
    border-radius: var(--lrob-etk-cf-radius);
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
    transition: background var(--lrob-etk-cf-trans), border-color var(--lrob-etk-cf-trans);
}
.lrob-etk-form .lrob-etk-form-file-trigger:hover {
    background: color-mix(in srgb, currentColor 14%, transparent);
    border-color: var(--lrob-etk-cf-border-focus);
}
.lrob-etk-form .lrob-etk-form-file-trigger .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
}
.lrob-etk-form .lrob-etk-form-file-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lrob-etk-form .lrob-etk-form-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: color-mix(in srgb, currentColor 5%, transparent);
    border-radius: var(--lrob-etk-cf-radius);
    font-size: 0.92em;
}
.lrob-etk-form .lrob-etk-form-file-item.is-invalid {
    background: var(--lrob-etk-form-error-bg);
    color: var(--lrob-etk-form-error);
}
.lrob-etk-form .lrob-etk-form-file-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lrob-etk-form .lrob-etk-form-file-item-size {
    opacity: 0.65;
    font-size: 0.85em;
}
.lrob-etk-form .lrob-etk-form-file-hint {
    margin: 0;
    font-size: 0.82em;
    opacity: 0.7;
}
