/**
 * Questionnaire Base Styles
 * Mobile-first responsive design for multi-questionnaire system
 * Theme-agnostic core layout and components
 */

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* ==================== ANIMATED BACKGROUND (ORBS) ==================== */
.orbs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.orbs::before,
.orbs::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    animation: float 20s infinite ease-in-out;
}

.orbs::before {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--primary-color, #667eea) 0%, transparent 70%);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.orbs::after {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--gradient-end, #764ba2) 0%, transparent 70%);
    bottom: -50px;
    right: -50px;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(50px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-30px, 30px) scale(0.9);
    }
}

/* ==================== CONTAINER ==================== */
.container {
    max-width: 700px;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* ==================== LOGO ==================== */
.questionnaire-logo {
    position: absolute;
    bottom: -8px;
    right: 20px;
    z-index: 10;
    margin: 0;
}

.logo-image {
    max-width: 80px;
    height: auto;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    transition: transform 0.3s ease, filter 0.3s ease;
    cursor: default;
    pointer-events: none;
}

.questionnaire-logo:hover .logo-image {
    transform: scale(2);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
}


/* ==================== PROGRESS BAR ==================== */
.progress-bar {
    background: rgba(226, 232, 240, 0.9);
    height: 8px;
    border-radius: 20px;
    overflow: hidden;
    margin-top: 0;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gradient-start, #667eea), var(--gradient-end, #764ba2));
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 20px;
}

.progress-text {
    text-align: center;
    color: #2d3748;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 30px;
    text-shadow: none;
}

/* ==================== QUESTION CARD ==================== */
.card {
    background: var(--bg-card, rgba(255, 255, 255, 0.95));
    border-radius: 20px;
    padding: 50px 40px;
    padding-bottom: 110px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
    position: relative;
    overflow: visible;
}

.card h1 {
    font-size: 2.2rem;
    color: var(--text-color, #2d3748);
    margin-bottom: 16px;
    line-height: 1.3;
    text-align: center;
}

.help-text {
    font-size: 1rem;
    color: #718096;
    margin-bottom: 32px;
    line-height: 1.6;
    text-align: center;
}

/* ==================== ANSWER AREA ==================== */
#answerArea {
    margin-bottom: 32px;
}

/* Radio buttons (vertical stack) */
.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Nested radio/checkbox options generated by engine */
.radio-option,
.checkbox-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.radio-option:hover,
.checkbox-option:hover {
    border-color: var(--primary-color, #667eea);
    background: #f7fafc;
}

.radio-option input,
.checkbox-option input {
    margin-right: 12px;
    cursor: pointer;
}

.radio-option span,
.checkbox-option span {
    flex: 1;
    font-size: 1rem;
    color: var(--text-color, #2d3748);
}

.radio-option input:checked ~ span,
.checkbox-option input:checked ~ span {
    font-weight: 600;
    color: var(--primary-color, #667eea);
}

.radio-option input:checked,
.checkbox-option input:checked {
    accent-color: var(--primary-color, #667eea);
}

/* Visual feedback for checked options - multiple selectors for compatibility */
.radio-option:has(input:checked),
.checkbox-option:has(input:checked),
.radio-option.checked,
.checkbox-option.checked,
.radio-option input:checked + span,
.checkbox-option input:checked + span {
    /* Styles applied to parent label */
}

.radio-option.checked,
.checkbox-option.checked {
    border-color: var(--primary-color, #667eea) !important;
    background: #f7fafc !important;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1) !important;
}

/* Fallback for browsers that don't support :has() */
.radio-option:has(input:checked),
.checkbox-option:has(input:checked) {
    border-color: var(--primary-color, #667eea);
    background: #f7fafc;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.option-btn {
    padding: 18px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    border: 3px solid var(--primary-color, #667eea);
    background: white;
    color: var(--primary-color, #667eea);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
}

.option-btn:hover {
    background: var(--primary-color, #667eea);
    color: white;
    transform: var(--btn-hover-transform, translateY(-2px));
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.option-btn.selected {
    background: var(--primary-color, #667eea);
    color: white;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.option-btn.selected::before {
    content: '✓';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    font-weight: bold;
}

/* Text inputs */
.input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
    height: 50px;
}

.textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
    min-height: 120px;
    resize: vertical;
}

.input:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary-color, #667eea);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Scale slider */
.scale-group {
    padding: 20px 0;
}

.scale-input {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 12px;
}

.scale-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color, #667eea);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.scale-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.scale-input::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color, #667eea);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    color: #718096;
    font-size: 0.9rem;
    font-weight: 600;
}

.scale-value {
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color, #667eea);
    margin-top: 12px;
}

/* Dropdown select */
.select {
    width: 100%;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.select:focus {
    outline: none;
    border-color: var(--primary-color, #667eea);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Yes/No buttons */
.yesno-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.yesno-btn {
    padding: 20px;
    font-size: 1.3rem;
    font-weight: 700;
    border: 3px solid var(--primary-color, #667eea);
    background: white;
    color: var(--primary-color, #667eea);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.yesno-btn:hover {
    background: var(--primary-color, #667eea);
    color: white;
    transform: translateY(-2px);
}

.yesno-btn.selected {
    background: var(--primary-color, #667eea);
    color: white;
}

/* ==================== NAVIGATION BUTTONS ==================== */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 32px;
}

.btn-secondary,
.btn-primary {
    padding: 15px 32px;
    font-size: 1.05rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
}

.btn-secondary {
    background: white;
    color: var(--primary-color, #667eea);
    border: 2px solid var(--primary-color, #667eea);
}

.btn-secondary:hover:not(:disabled) {
    background: #f7fafc;
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary-color, #667eea);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-color-dark, #5568d3);
    transform: var(--btn-hover-transform, translateY(-2px));
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.btn-secondary:disabled,
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== RESULTS CARD ==================== */
.results-card {
    background: var(--bg-card, rgba(255, 255, 255, 0.95));
    border-radius: 20px;
    padding: 50px 40px;
    padding-bottom: 110px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    text-align: center;
    position: relative;
    overflow: visible;
}

.results-card h2 {
    font-size: 2rem;
    color: var(--text-color, #2d3748);
    margin-bottom: 24px;
}

.results-content {
    margin-bottom: 32px;
    color: #4a5568;
    font-size: 1.1rem;
    line-height: 1.7;
}

.result-bar {
    margin: 16px 0;
    text-align: left;
}

.result-label {
    font-weight: 600;
    color: var(--text-color, #2d3748);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.bar-container {
    background: #e2e8f0;
    height: 32px;
    border-radius: 16px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gradient-start, #667eea), var(--gradient-end, #764ba2));
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.cta-btn {
    display: inline-block;
    padding: 18px 48px;
    background: linear-gradient(135deg, var(--gradient-start, #667eea), var(--gradient-end, #764ba2));
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.15rem;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.cta-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

/* ==================== LOADING STATE ==================== */
.loading {
    text-align: center;
    padding: 60px 40px;
    color: white;
    font-size: 1.1rem;
    position: relative;
    z-index: 100;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.loading p {
    margin-top: 20px;
    font-weight: 600;
    animation: pulse 1.5s ease-in-out infinite;
}

.spinner {
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top: 5px solid var(--gradient-start, #667eea);
    border-right: 5px solid var(--gradient-end, #764ba2);
    width: 60px;
    height: 60px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

/* Pulsing dots for loading text */
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== ERROR STATE ==================== */
.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #fc8181;
    font-weight: 500;
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Tablet (768px and below) */
@media (max-width: 768px) {
    body {
        padding: 1px;
    }

    .questionnaire-logo {
        bottom: -5px;
        right: 15px;
    }

    .logo-image {
        max-width: 70px;
    }

    .card,
    .results-card {
        padding-bottom: 95px;
    }

    .card,
    .results-card {
        padding: 40px 28px;
    }

    .card h1 {
        font-size: 1.8rem;
    }

    .help-text {
        font-size: 0.95rem;
    }

    .option-btn {
        padding: 16px 20px;
        font-size: 1rem;
    }

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

    .btn-secondary,
    .btn-primary {
        width: 100%;
    }

    .progress-text {
        font-size: 0.85rem;
    }

    .cta-btn {
        padding: 16px 36px;
        font-size: 1.05rem;
    }

    .yesno-group {
        grid-template-columns: 1fr;
    }
}

/* Mobile (640px and below) */
@media (max-width: 640px) {
    .questionnaire-logo {
        bottom: -4px;
        right: 10px;
    }

    .logo-image {
        max-width: 60px;
    }

    .card,
    .results-card {
        padding-bottom: 85px;
    }

    .card,
    .results-card {
        padding: 32px 20px;
        border-radius: 16px;
    }

    .card h1 {
        font-size: 1.6rem;
    }

    .help-text {
        font-size: 0.9rem;
        margin-bottom: 24px;
    }

    .option-btn {
        padding: 14px 16px;
        font-size: 0.95rem;
    }

    .btn-secondary,
    .btn-primary {
        padding: 14px 24px;
        font-size: 1rem;
    }

    .cta-btn {
        padding: 14px 32px;
        font-size: 1rem;
    }

    .scale-value {
        font-size: 1.6rem;
    }

    .orbs::before {
        width: 250px;
        height: 250px;
    }

    .orbs::after {
        width: 200px;
        height: 200px;
    }
}

/* Large desktop (1280px and above) */
@media (min-width: 1280px) {
    .container {
        max-width: 800px;
    }

    .card,
    .results-card {
        padding: 60px 50px;
    }

    .card h1 {
        font-size: 2.5rem;
    }
}

/* ==================== ACCESSIBILITY ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
.option-btn:focus-visible,
.btn-secondary:focus-visible,
.btn-primary:focus-visible,
.cta-btn:focus-visible {
    outline: 3px solid var(--primary-color, #667eea);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .orbs::before,
    .orbs::after {
        animation: none;
    }
}
