/**
 * FlowInterview Survey Form Styles
 * Mobile-first, clean design using existing --fi-* custom property conventions.
 *
 * @since 0.28.0
 */

:root {
    --survey-brand: var(--brand-color, #2563eb);
    --survey-brand-dark: color-mix(in srgb, var(--survey-brand), #000 15%);
    --survey-gray-50: #f9fafb;
    --survey-gray-100: #f3f4f6;
    --survey-gray-200: #e5e7eb;
    --survey-gray-300: #d1d5db;
    --survey-gray-500: #6b7280;
    --survey-gray-700: #374151;
    --survey-gray-900: #111827;
    --survey-success: #16a34a;
    --survey-danger: #dc2626;
    --survey-radius: 8px;
    --survey-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

/* ── Container ────────────────────────────────────────────────────────── */

.survey-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--survey-gray-900);
    line-height: 1.6;
}

/* ── Entry Form ───────────────────────────────────────────────────────── */

.survey-entry-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--survey-gray-200);
}

.survey-entry-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.survey-entry-description {
    color: var(--survey-gray-500);
    margin: 0 0 0.5rem;
}

.survey-entry-time {
    font-size: 0.875rem;
    color: var(--survey-gray-500);
    margin: 0;
}

.survey-field-group {
    margin-bottom: 1.25rem;
}

.survey-field-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.375rem;
}

.survey-required {
    color: var(--survey-danger);
    margin-left: 2px;
}

.survey-input {
    display: block;
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--survey-gray-900);
    background: #fff;
    border: 1px solid var(--survey-gray-300);
    border-radius: var(--survey-radius);
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

.survey-input:focus {
    outline: none;
    border-color: var(--survey-brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.survey-entry-submit {
    margin-top: 1.5rem;
    text-align: center;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.survey-btn {
    display: inline-block;
    padding: 0.625rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--survey-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
    line-height: 1.5;
}

.survey-btn-primary {
    background: var(--survey-brand);
    color: #fff;
}

.survey-btn-primary:hover {
    background: var(--survey-brand-dark);
}

.survey-btn-secondary {
    background: #fff;
    color: var(--survey-gray-700);
    border-color: var(--survey-gray-300);
}

.survey-btn-secondary:hover {
    background: var(--survey-gray-50);
}

/* ── Form Header ──────────────────────────────────────────────────────── */

.survey-form-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.survey-form-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* ── Section Header ───────────────────────────────────────────────────── */

.survey-section-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--survey-gray-200);
}

.survey-section-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.375rem;
}

.survey-section-header p {
    color: var(--survey-gray-500);
    margin: 0;
    font-size: 0.9375rem;
}

/* ── Question Card ────────────────────────────────────────────────────── */

.survey-question-card {
    border: 1px solid var(--survey-gray-200);
    border-radius: var(--survey-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: #fff;
    transition: border-color 0.15s ease;
}

.survey-question-card.survey-question-invalid {
    border-color: var(--survey-danger);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.survey-question-text {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.survey-question-help {
    font-size: 0.875rem;
    color: var(--survey-gray-500);
    margin-bottom: 0.75rem;
}

.survey-hint {
    font-size: 0.8125rem;
    color: var(--survey-gray-500);
    margin-bottom: 0.5rem;
}

/* ── Radio & Checkbox Options ─────────────────────────────────────────── */

.survey-radio-group,
.survey-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.survey-radio-option,
.survey-checkbox-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--survey-gray-200);
    border-radius: var(--survey-radius);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    user-select: none;
}

.survey-radio-option:hover,
.survey-checkbox-option:hover {
    border-color: var(--survey-brand);
    background: var(--survey-gray-50);
}

.survey-radio-option.is-selected,
.survey-checkbox-option.is-selected {
    border-color: var(--survey-brand);
    background: rgba(37, 99, 235, 0.04);
}

.survey-radio-option input[type="radio"],
.survey-checkbox-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.survey-radio-indicator,
.survey-checkbox-indicator {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--survey-gray-300);
    background: #fff;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.survey-radio-indicator {
    border-radius: 50%;
}

.survey-checkbox-indicator {
    border-radius: 4px;
}

.survey-radio-option.is-selected .survey-radio-indicator {
    border-color: var(--survey-brand);
    background: var(--survey-brand);
    box-shadow: inset 0 0 0 3px #fff;
}

.survey-checkbox-option.is-selected .survey-checkbox-indicator {
    border-color: var(--survey-brand);
    background: var(--survey-brand);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z'/%3E%3C/svg%3E");
    background-size: 14px;
    background-repeat: no-repeat;
    background-position: center;
}

.survey-radio-label,
.survey-checkbox-label {
    font-size: 0.9375rem;
}

/* Other input */
.survey-other-input {
    display: none;
    margin-top: 0.5rem;
    padding-left: 2.375rem;
}

.survey-other-input.is-visible {
    display: block;
}

/* ── Slider ───────────────────────────────────────────────────────────── */

.survey-slider-wrap {
    padding: 0.5rem 0;
}

.survey-slider-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--survey-gray-500);
}

.survey-slider-value {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--survey-brand);
}

.survey-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--survey-gray-200);
    border-radius: 3px;
    outline: none;
}

.survey-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--survey-brand);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: var(--survey-shadow);
}

.survey-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--survey-brand);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: var(--survey-shadow);
}

/* Mobile slider buttons — hidden on desktop */
.survey-slider-mobile-buttons {
    display: none;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.survey-slider-btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--survey-gray-300);
    border-radius: var(--survey-radius);
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.survey-slider-btn:hover {
    border-color: var(--survey-brand);
}

.survey-slider-btn.is-selected {
    border-color: var(--survey-brand);
    background: var(--survey-brand);
    color: #fff;
}

/* ── Yes / No ─────────────────────────────────────────────────────────── */

.survey-yesno-group {
    display: flex;
    gap: 0.75rem;
}

.survey-yesno-btn {
    flex: 1;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    border: 2px solid var(--survey-gray-200);
    border-radius: var(--survey-radius);
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.survey-yesno-btn:hover {
    border-color: var(--survey-brand);
    background: var(--survey-gray-50);
}

.survey-yesno-btn.is-selected {
    border-color: var(--survey-brand);
    background: var(--survey-brand);
    color: #fff;
}

/* ── Long Text Counter ────────────────────────────────────────────────── */

.survey-long-text {
    resize: vertical;
    min-height: 100px;
}

.survey-char-counter {
    text-align: right;
    font-size: 0.8125rem;
    color: var(--survey-gray-500);
    margin-top: 0.25rem;
}

/* ── Gate ──────────────────────────────────────────────────────────────── */

.survey-gate {
    max-width: 500px;
    margin: 2rem auto;
}

.survey-gate-card {
    text-align: center;
    padding: 2rem 1.5rem;
    border: 1px solid var(--survey-gray-200);
    border-radius: var(--survey-radius);
    background: var(--survey-gray-50);
}

.survey-gate-message {
    margin-bottom: 1.5rem;
    font-size: 1rem;
    color: var(--survey-gray-700);
}

.survey-gate-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.survey-gate-buttons .survey-btn {
    min-width: 220px;
}

.survey-gate-thankyou-card {
    text-align: center;
    padding: 2rem;
    font-size: 1.125rem;
    color: var(--survey-gray-700);
}

/* ── Consent ──────────────────────────────────────────────────────────── */

.survey-consent-text {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* ── Redirect / Thank-you ─────────────────────────────────────────────── */

.survey-redirect {
    text-align: center;
    padding: 3rem 1rem;
}

.survey-redirect-card {
    max-width: 500px;
    margin: 0 auto;
}

.survey-redirect-icon {
    font-size: 3rem;
    color: var(--survey-success);
    margin-bottom: 1rem;
}

.survey-redirect-message {
    font-size: 1.125rem;
    color: var(--survey-gray-700);
    margin-bottom: 1.5rem;
}

.survey-redirect-link {
    margin-top: 1rem;
}

/* ── Soft Capture Toggle ──────────────────────────────────────────────── */

.survey-soft-toggle-wrap {
    margin-top: 0.75rem;
}

.survey-soft-toggle {
    font-size: 0.8125rem;
    color: var(--survey-brand);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0;
    text-decoration: underline;
}

.survey-soft-toggle:hover {
    color: var(--survey-brand-dark);
}

.survey-soft-capture {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--survey-gray-50);
    border-radius: var(--survey-radius);
}

/* ── Progress Bar ─────────────────────────────────────────────────────── */

.survey-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--survey-gray-200);
    z-index: 100;
}

.survey-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--survey-brand);
    transition: width 0.3s ease;
}

/* ── Save Indicator ───────────────────────────────────────────────────── */

.survey-save-indicator {
    position: fixed;
    top: 1rem;
    right: 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--survey-success);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

.survey-save-indicator.is-visible {
    opacity: 1;
}

/* ── Navigation Buttons ───────────────────────────────────────────────── */

.survey-nav-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--survey-gray-200);
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 767px) {
    .survey-container {
        padding: 1rem 0.75rem;
    }

    .survey-question-card {
        padding: 1rem;
    }

    .survey-radio-option,
    .survey-checkbox-option {
        padding: 0.75rem;
        min-height: 48px;
    }

    .survey-yesno-btn {
        padding: 1rem;
        font-size: 1.125rem;
    }

    .survey-slider-mobile-buttons {
        display: flex;
    }

    .survey-slider-wrap {
        display: none;
    }

    .survey-gate-buttons {
        flex-direction: column;
    }

    .survey-gate-buttons .survey-btn {
        width: 100%;
    }

    .survey-nav-buttons {
        flex-direction: column-reverse;
    }

    .survey-nav-buttons .survey-btn {
        width: 100%;
        text-align: center;
    }

    .survey-btn {
        padding: 0.75rem 1.5rem;
        min-height: 48px;
    }
}
