/* Frontend CSS */
.free-form {
    --ff-surface: #ffffff;
    --ff-surface-muted: #f8fbff;
    --ff-surface-accent: rgba(59, 130, 246, 0.08);
    --ff-border: #d6deea;
    --ff-border-strong: #2563eb;
    --ff-text: #0f172a;
    --ff-text-muted: #475569;
    --ff-danger: #b91c1c;
    --ff-danger-soft: #fef2f2;
    --ff-success: #166534;
    --ff-success-soft: #ecfdf3;
    --ff-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
    max-width: 680px;
    margin: 0 auto;
    padding: clamp(1.25rem, 2vw, 1.75rem);
    border: 1px solid var(--ff-border);
    border-radius: 24px;
    background: linear-gradient(180deg, var(--ff-surface) 0%, var(--ff-surface-muted) 100%);
    box-shadow: var(--ff-shadow);
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.free-form::before {
    content: "";
    position: absolute;
    inset: -20% auto auto 60%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, var(--ff-surface-accent) 0%, rgba(59, 130, 246, 0) 72%);
    pointer-events: none;
    z-index: -1;
}

.free-form-field {
    margin-bottom: 1rem;
}

.free-form-field > label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    color: var(--ff-text);
    font-size: 0.97rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.free-form-required {
    color: #f97316;
}

.free-form-control,
.free-form-field input:not([type="checkbox"]):not([type="radio"]),
.free-form-field textarea,
.free-form-field select {
    width: 100%;
    min-height: 48px;
    padding: 0.8rem 0.95rem;
    border: 1px solid var(--ff-border);
    border-radius: 14px;
    background: #ffffff;
    color: var(--ff-text);
    font-size: 1rem;
    line-height: 1.5;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.free-form-field textarea {
    min-height: 140px;
    resize: vertical;
}

.free-form-control::placeholder,
.free-form-field input::placeholder,
.free-form-field textarea::placeholder {
    color: #94a3b8;
}

.free-form-control:focus,
.free-form-field input:not([type="checkbox"]):not([type="radio"]):focus,
.free-form-field textarea:focus,
.free-form-field select:focus {
    outline: none;
    border-color: var(--ff-border-strong);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.free-form-field.has-error > label {
    color: var(--ff-danger);
}

.free-form-control.is-invalid,
.free-form-field input:not([type="checkbox"]):not([type="radio"]).is-invalid,
.free-form-field textarea.is-invalid,
.free-form-field select.is-invalid {
    border-color: #ef4444;
    background: #fff8f8;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.free-form-choice-group {
    display: grid;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--ff-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.85);
}

.free-form-choice {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0;
    color: var(--ff-text);
    font-size: 0.96rem;
    font-weight: 600;
}

.free-form-choice input[type="checkbox"],
.free-form-choice input[type="radio"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: #2563eb;
}

.free-form-field.has-error .free-form-choice-group {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.free-form-field-error {
    min-height: 1.25rem;
    margin-top: 0.45rem;
    color: var(--ff-danger);
    font-size: 0.875rem;
    font-weight: 600;
}

.free-form-captcha {
    margin: 1.25rem 0 0.75rem;
}

.free-form-captcha-card {
    padding: 1rem 1rem 1.1rem;
    border: 1px solid rgba(37, 99, 235, 0.12);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, rgba(239, 246, 255, 0.92) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.free-form-captcha-card--math {
    display: grid;
    gap: 0.75rem;
}

.free-form-captcha-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    width: fit-content;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.free-form-captcha-question {
    color: var(--ff-text);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.free-form-captcha-help {
    margin: 0;
    color: var(--ff-text-muted);
    font-size: 0.94rem;
}

.free-form-field--captcha {
    margin-bottom: 0;
}

.free-form-honeypot {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.free-form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.free-form-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    min-width: 180px;
    padding: 0.9rem 1.45rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.24);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.free-form-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 18px 34px rgba(37, 99, 235, 0.3);
    filter: saturate(1.05);
}

.free-form-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18), 0 18px 34px rgba(37, 99, 235, 0.26);
}

.free-form-submit:disabled {
    cursor: wait;
    opacity: 0.9;
}

.free-form-submit-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 999px;
    animation: ff-spin 0.8s linear infinite;
}

.free-form-submit.is-loading .free-form-submit-spinner {
    display: inline-block;
}

.free-form-response {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 14px;
    font-weight: 600;
    line-height: 1.5;
}

.free-form-response:focus {
    outline: none;
}

.free-form-response.success {
    background: var(--ff-success-soft);
    color: var(--ff-success);
    border-color: #86efac;
}

.free-form-response.error {
    background: var(--ff-danger-soft);
    color: #991b1b;
    border-color: #fecaca;
}

@keyframes ff-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 640px) {
    .free-form {
        padding: 1rem;
        border-radius: 20px;
    }

    .free-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .free-form-submit {
        width: 100%;
    }
}
