/* Primary color is injected by PHP as an inline style on .sfo-form-wrap */
/* Default fallback is #6366f1, overridden dynamically from plugin settings */

.sfo-form-wrap {
    --sfo-primary-color: #6366f1;
    /* overridden by PHP inline style */
    max-width: 580px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Multi-step progress bar */
.sfo-steps-bar {
    display: flex;
    align-items: center;
    margin-bottom: 28px;
}

.sfo-step-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #94a3b8;
    flex-shrink: 0;
    transition: all .3s;
}

.sfo-step-dot.active,
.sfo-step-dot.done {
    background: var(--sfo-primary-color);
    color: #fff;
}

.sfo-step-line {
    flex: 1;
    height: 2px;
    background: #e2e8f0;
    margin: 0 6px;
}

/* Form shell */
.sfo-form {
    width: 100%;
}

/* Field wrap */
.sfo-field-wrap {
    margin-bottom: 18px;
}

.sfo-field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.sfo-required {
    color: #ef4444;
    margin-left: 3px;
}

/* Inputs */
.sfo-form .sfo-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #1f2937;
    transition: border .18s, box-shadow .18s;
    box-sizing: border-box;
    background: #fff;
}

.sfo-form .sfo-input:focus {
    border-color: var(--sfo-primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .05);
}

.sfo-form textarea.sfo-input {
    resize: vertical;
    min-height: 100px;
}

.sfo-form select.sfo-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

/* Radio / Checkbox group */
.sfo-radio-group,
.sfo-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sfo-radio-label,
.sfo-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
}

.sfo-radio-label input,
.sfo-checkbox-label input {
    accent-color: var(--sfo-primary-color);
    width: 16px;
    height: 16px;
}

/* File upload */
.sfo-file {
    padding: 8px;
    font-size: 13px;
}

/* Heading / Divider */
.sfo-field-heading {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    margin: 6px 0 12px;
}

.sfo-field-divider {
    border: none;
    border-top: 1.5px solid #e2e8f0;
    margin: 10px 0 18px;
}

/* Field error */
.sfo-field-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.sfo-field-error.visible {
    display: block;
}

.sfo-form .sfo-input.sfo-has-error {
    border-color: #ef4444;
}

/* ====== OTP Section ====== */
.sfo-otp-section {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 18px;
}

.sfo-otp-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.sfo-otp-icon {
    font-size: 26px;
    flex-shrink: 0;
}

.sfo-otp-header strong {
    font-size: 14px;
    color: #1e293b;
    display: block;
    margin-bottom: 2px;
}

.sfo-otp-header p {
    margin: 0;
    font-size: 12px;
    color: #64748b;
}

.sfo-otp-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.sfo-otp-row .sfo-input {
    flex: 1;
    min-width: 0;
}

/* Send / Verify OTP Button */
.sfo-btn-otp {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    background: var(--sfo-primary-color);
    color: #fff;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .18s;
}

.sfo-btn-otp:hover {
    filter: brightness(0.9);
}

.sfo-btn-otp:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}

/* 6-digit OTP inputs */
.sfo-otp-digits {
    display: flex;
    gap: 8px;
}

.sfo-otp-digit {
    width: 42px;
    height: 50px;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: var(--sfo-primary-color);
    transition: border .15s, transform .1s;
    box-sizing: border-box;
}

.sfo-otp-digit:focus {
    border-color: var(--sfo-primary-color);
    outline: none;
    transform: scale(1.05);
}

.sfo-otp-digit.filled {
    border-color: var(--sfo-primary-color);
    background: #f8fafc;
}

/* OTP status messages */
.sfo-otp-status {
    font-size: 13px;
    margin-top: 6px;
    font-weight: 500;
}

.sfo-otp-status.success {
    color: #059669;
}

.sfo-otp-status.error {
    color: #dc2626;
}

.sfo-otp-status.info {
    color: #2563eb;
}

/* Resend */
.sfo-btn-ghost {
    background: transparent;
    color: var(--sfo-primary-color);
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    text-decoration: underline;
}

.sfo-resend-timer {
    font-size: 12px;
    color: #64748b;
    margin-left: 6px;
}

/* Verified badge */
.sfo-verified-badge {
    background: #d1fae5;
    border: 1.5px solid #6ee7b7;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #065f46;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sfo-verified-badge span {
    font-style: italic;
    color: #059669;
}

/* Submit button */
.sfo-btn-submit {
    width: 100%;
    padding: 13px;
    font-size: 15px;
    font-weight: 700;
    background: var(--sfo-primary-color);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity .2s, transform .15s;
    letter-spacing: .02em;
}

.sfo-btn-submit:hover:not(:disabled) {
    opacity: .9;
    transform: translateY(-1px);
}

.sfo-btn-submit:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.sfo-btn-full {
    width: 100%;
}

.sfo-form-footer {
    margin-top: 8px;
}

/* Multi-step nav */
.sfo-btn-next,
.sfo-btn-prev {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background .18s;
}

.sfo-btn-next {
    background: var(--sfo-primary-color);
    color: #fff;
    width: 100%;
    margin-top: 8px;
}

.sfo-btn-next:hover {
    filter: brightness(0.9);
}

.sfo-btn-prev {
    background: #f1f5f9;
    color: #374151;
    width: 100%;
    margin-top: 6px;
}

.sfo-btn-prev:hover {
    background: #e2e8f0;
}

/* Success message */
.sfo-success-msg {
    text-align: center;
    padding: 30px;
    background: #d1fae5;
    border: 2px solid #6ee7b7;
    border-radius: 12px;
    color: #065f46;
    font-size: 16px;
    font-weight: 600;
    animation: sfoFadeIn .4s ease;
}

@keyframes sfoFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* Conditional hidden fields */
.sfo-conditional {
    transition: opacity .25s;
}

.sfo-conditional.sfo-hidden {
    display: none;
}

/* Loading spinner overlay on submit */
.sfo-submitting .sfo-btn-submit::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .6);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sfospin .6s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

@keyframes sfospin {
    to {
        transform: rotate(360deg);
    }
}

/* ======================================================
   FORM LAYOUT MODES
   ====================================================== */

/* --- Universal Flexible Layout (All Forms) --- */
.sfo-step-panel {
    display: flex;
    flex-wrap: wrap;
    margin-left: -10px;
    margin-right: -10px;
}

.sfo-field-wrap,
.sfo-otp-section,
.sfo-verified-badge,
.sfo-form-footer,
.sfo-btn-next,
.sfo-btn-prev {
    padding-left: 10px;
    padding-right: 10px;
    box-sizing: border-box;
    /* width: 100%; Removed fallback to ensure sfo-col-* works */
}

/* ── Exact Column Widths (Active on ALL screens) ── */
.sfo-step-panel .sfo-col-100 {
    width: 100% !important;
}

.sfo-step-panel .sfo-col-50 {
    width: 50% !important;
}

/* Always full-width elements */
.sfo-field-heading,
.sfo-field-divider,
.sfo-otp-section,
.sfo-verified-badge,
.sfo-form-footer,
.sfo-btn-next,
.sfo-btn-prev {
    width: 100% !important;
}

/* --- Horizontal (Label left · Input right) --- */
.sfo-layout-horizontal .sfo-field-wrap {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}

.sfo-layout-horizontal .sfo-field-label {
    flex: 0 0 160px;
    text-align: right;
    padding-top: 10px;
    font-size: 13px;
    color: #374151;
}

.sfo-layout-horizontal .sfo-field-wrap>.sfo-input,
.sfo-layout-horizontal .sfo-field-wrap>.sfo-radio-group,
.sfo-layout-horizontal .sfo-field-wrap>.sfo-checkbox-group,
.sfo-layout-horizontal .sfo-field-wrap>select.sfo-input,
.sfo-layout-horizontal .sfo-field-wrap>textarea.sfo-input {
    flex: 1;
}

.sfo-layout-horizontal .sfo-field-wrap>.sfo-field-error {
    flex-basis: 100%;
    margin-left: 176px;
}

.sfo-layout-horizontal .sfo-field-heading,
.sfo-layout-horizontal .sfo-field-divider {
    flex-basis: 100%;
}

/* Horizontal: collapse to vertical on mobile */
@media (max-width: 560px) {
    .sfo-layout-horizontal .sfo-field-wrap {
        flex-direction: column;
    }

    .sfo-layout-horizontal .sfo-field-label {
        flex: none;
        text-align: left;
        padding-top: 0;
    }

    .sfo-layout-horizontal .sfo-field-wrap>.sfo-field-error {
        margin-left: 0;
    }
}

/* ====== GDPR Consent Field ====== */
.sfo-gdpr-wrap {
    margin-bottom: 16px;
}

.sfo-gdpr-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    line-height: 1.5;
}

.sfo-gdpr-label input[type="checkbox"] {
    accent-color: var(--sfo-primary-color);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.sfo-gdpr-label a {
    color: var(--sfo-primary-color);
}

.sfo-gdpr-label a:hover {
    text-decoration: underline;
}