/* survey.css - Modern Mobile-First Design with Auto-Advance Animations */

/* Mobile-First Design */
.simple-survey {
    max-width: 100%;
    margin: 0;
    padding: 20px 16px;
    background: #fff;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
    padding-top: 70px; /* Space for fixed header */
    padding-bottom: 100px; /* Space for fixed navigation */
}

/* Progress Header FIXED at top with Flexbox side by side */
.survey-progress-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 12px;
    height: 50px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.progress-bar-container {
    flex: 1;
    min-width: 0;
}

.progress-bar-top {
    width: 100%;
    height: 4px;
    background-color: #f0f0f0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill-top {
    height: 100%;
    background: #4A90E2;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.progress-numbers-top {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    min-width: 45px;
    text-align: right;
    white-space: nowrap;
}

.progress-numbers-placeholder {
    min-width: 45px;
}

/* Auto-advance status indicator 
.auto-advance-status {
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.auto-advance-status {
    min-width: 24px;
}*/

/* Back Button in Header - Fixed Width to prevent layout shift */
.survey-back-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e1e8ed;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333;
    flex-shrink: 0;
    visibility: hidden;
    opacity: 0;
}

.survey-back-btn.visible {
    visibility: visible;
    opacity: 1;
}

.survey-back-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateX(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Questions */
.survey-question {
    margin-bottom: 40px;
    animation: fadeInUp 0.4s ease-out;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.question-title {
    color: #333;
    margin-bottom: 12px;
    font-size: 22px;
    line-height: 1.3;
    font-weight: 600;
}

.question-description {
    color: #666;
    margin-bottom: 24px;
    font-size: 16px;
    line-height: 1.5;
    font-weight: 400;
}

.required {
    color: #e74c3c;
    font-weight: bold;
}

/* Auto-Advance Animations */
.survey-question.auto-advancing {
    position: relative;
    transition: all 0.3s ease;
}

.survey-question.auto-advancing::before {
    content: "";
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    height: 3px;
    background: linear-gradient(90deg, #4A90E2 0%, #4A90E2 var(--progress, 0%), rgba(74, 144, 226, 0.2) var(--progress, 0%));
    border-radius: 2px;
    animation: autoAdvanceProgress var(--delay, 800ms) linear;
    z-index: 10;
}

@keyframes autoAdvanceProgress {
    0% { 
        background: linear-gradient(90deg, #4A90E2 0%, #4A90E2 0%, rgba(74, 144, 226, 0.2) 0%);
    }
    100% { 
        background: linear-gradient(90deg, #4A90E2 0%, #4A90E2 100%, rgba(74, 144, 226, 0.2) 100%);
    }
}

.auto-advance-indicator {
    font-size: 12px;
    color: #666;
    margin-top: 15px;
    text-align: center;
    opacity: 0.8;
    animation: fadeIn 0.3s ease;
    padding: 8px 12px;
    background: rgba(74, 144, 226, 0.05);
    border-radius: 4px;
    border-left: 3px solid #4A90E2;
}

/* Auto-advance info banner */
.survey-auto-advance-info {
    margin-top: 20px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    font-size: 13px;
    color: #495057;
    text-align: center;
    border: 1px solid #dee2e6;
    animation: slideInUp 0.5s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Input Fields */
.survey-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    background: #fff;
}

.survey-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Enhanced auto-advance visual feedback for radio buttons */
.survey-question.auto-advancing input[type="radio"]:checked + span {
    background: rgba(74, 144, 226, 0.1);
    border-radius: 4px;
    padding: 4px 8px;
    margin: -4px -8px;
    transition: all 0.3s ease;
}

/* Enhanced auto-advance visual feedback for star ratings */
.survey-question.auto-advancing .star-rating .star.star-filled {
    animation: starPulse 0.3s ease;
}

@keyframes starPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

textarea.survey-input {
    resize: vertical;
    min-height: 120px;
}

select.survey-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

/* Radio & Checkbox */
input[type="radio"].survey-input,
input[type="checkbox"].survey-input {
    width: auto;
    margin-right: 12px;
    transform: scale(1.2);
}

.survey-question label {
    cursor: pointer;
    padding: 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    display: block;
    border: 2px solid transparent;
}

.survey-question label:hover {
    background-color: #f8f9fa;
    border-color: #e1e8ed;
    transform: translateX(2px);
}

.survey-question input[type="radio"]:checked + span,
.survey-question input[type="checkbox"]:checked + span {
    font-weight: 500;
    color: #4A90E2;
}

/* Enhanced visual feedback for checked radio buttons in auto-advance mode */
.survey-question input[type="radio"]:checked + span {
    position: relative;
}

.survey-question.auto-advancing input[type="radio"]:checked + span::after {
    content: "✓";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #4A90E2;
    font-weight: bold;
    animation: checkMark 0.3s ease;
}

@keyframes checkMark {
    0% { 
        opacity: 0;
        transform: translateY(-50%) scale(0.5);
    }
    100% { 
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Range Slider */
input[type="range"].survey-input {
    -webkit-appearance: none;
    height: 8px;
    background: #e1e8ed;
    border-radius: 4px;
    outline: none;
    margin: 16px 0;
}

input[type="range"].survey-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: transform 0.2s ease;
}

input[type="range"].survey-input::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"].survey-input::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.slider-value {
    text-align: center;
    margin-top: 8px;
    font-weight: bold;
    color: #667eea;
    font-size: 16px;
}

/* Star Rating */
.star-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
}

.star-rating .star {
    font-size: 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #ddd;
    text-shadow: 0 1px 3px rgba(0,0,0,0.1);
    user-select: none;
}

.star-rating .star:hover {
    transform: scale(1.1);
}

.star-rating .star.star-filled {
    color: #ffc107;
    text-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

.star-rating .star.star-empty {
    color: #e9ecef;
}

/* Navigation - Fixed at bottom on mobile */
.survey-navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e1e8ed;
    padding: 16px;
    text-align: center;
    z-index: 999;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

#next-btn,
#submit-btn,
.survey-info-btn {
    width: 100%;
    max-width: 300px;
    padding: 16px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #4A90E2;
    color: white;
    position: relative;
    overflow: hidden;
}

#next-btn:hover:not(:disabled),
#submit-btn:hover:not(:disabled),
.survey-info-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

/* Disabled state for buttons */
#next-btn:disabled,
#submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: #9ca3af !important;
}

/* Skip button styling */
#skip-btn {
    background: #6c757d !important;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    margin-top: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#skip-btn:hover {
    background: #5a6268 !important;
    transform: translateY(-1px);
}

/* Info Pages */
.survey-info-page {
    text-align: center;
    padding: 40px 20px;
    max-width: 500px;
    margin: 0 auto;
}

/* Success Message */
.survey-success {
    text-align: center;
    padding: 60px 20px;
    max-width: 500px;
    margin: 0 auto;
    animation: successAnimation 0.6s ease;
}

@keyframes successAnimation {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.survey-success h3 {
    color: #27ae60;
    font-size: 24px;
    margin-bottom: 16px;
}

.survey-success p {
    color: #666;
    font-size: 16px;
}

/* Error Messages */
.question-error {
    background-color: #fee;
    color: #c53030;
    padding: 12px 16px;
    border-radius: 6px;
    border-left: 4px solid #e53e3e;
    font-size: 14px;
    margin-top: 12px;
    animation: errorSlideIn 0.3s ease;
}

@keyframes errorSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Info Messages */
.survey-info {
    background: #e7f3ff;
    border: 1px solid #b8d4f0;
    padding: 12px 16px;
    margin: 15px 0;
    border-radius: 6px;
    color: #2c5282;
    font-size: 14px;
    line-height: 1.4;
    animation: infoSlideDown 0.3s ease;
}

@keyframes infoSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Desktop Styles */
@media (min-width: 768px) {
    .simple-survey {
        max-width: 800px;
        margin: 0 auto;
        padding: 20px;
        padding-bottom: 40px;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.08);
        margin-top: 40px;
        min-height: auto;
        padding-top: 20px;
    }
    
    .survey-progress-header {
        position: relative;
        margin-bottom: 30px;
        border-bottom: none;
        padding: 16px 0;
        height: auto;
        box-shadow: none;
    }
    
    .progress-bar-top {
        height: 6px;
        border-radius: 3px;
    }
    
    .progress-fill-top {
        border-radius: 3px;
    }
    
    .progress-numbers-top {
        font-size: 14px;
    }
    
    
    .survey-back-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .question-title {
        font-size: 24px;
    }
    
    .question-description {
        font-size: 18px;
    }
    
    /* Desktop: Navigation not fixed */
    .survey-navigation {
        position: relative;
        margin-top: 40px;
        padding-top: 20px;
        text-align: center;
        border-top: none;
        box-shadow: none;
        background: transparent;
    }
    
    /* Desktop: Buttons side by side */
    .survey-navigation {
        display: flex;
        justify-content: center;
        gap: 16px;
    }
    
    #next-btn,
    #submit-btn,
    .survey-info-btn {
        width: auto;
        min-width: 150px;
        max-width: none;
    }
    
    #skip-btn {
        width: auto;
        min-width: 140px;
        max-width: none;
        margin-top: 0;
    }
    
    .star-rating {
        justify-content: flex-start;
    }
    
    /* Desktop auto-advance info positioning */
    .survey-auto-advance-info {
        position: fixed;
        bottom: 20px;
        right: 20px;
        max-width: 280px;
        margin: 0;
        z-index: 1001;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
}

@media (min-width: 1024px) {
    .simple-survey {
        padding: 40px;
    }
    
    .survey-question {
        margin-bottom: 50px;
        max-width: 600px;
    }
    
    .question-title {
        font-size: 26px;
        margin-bottom: 16px;
    }
    
    .question-description {
        font-size: 18px;
        margin-bottom: 28px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .survey-question,
    .survey-back-btn,
    #next-btn,
    #submit-btn,
    .survey-start-btn,
    .star-rating .star,
    .auto-advance-indicator,
    .survey-auto-advance-info,
    .survey-success {
        animation: none;
        transition: none;
    }
    
    .survey-question.auto-advancing::before {
        animation: none;
        background: #4A90E2;
    }
}

/* Focus States for Accessibility */
.survey-input:focus,
.survey-back-btn:focus,
#next-btn:focus,
#submit-btn:focus,
.survey-start-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .simple-survey {
        border: 2px solid #000;
    }
    
    .survey-input {
        border: 2px solid #000;
    }
    
    .question-error {
        border: 2px solid #000;
    }
    
    .auto-advance-indicator {
        border: 1px solid #000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .simple-survey {
        background: #1a1a1a;
        color: #e0e0e0;
    }
    
    .survey-progress-header {
        background: #1a1a1a;
        border-bottom-color: #333;
    }
    
    .survey-input {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .survey-input:focus {
        border-color: #667eea;
    }
    
    .survey-navigation {
        background: #1a1a1a;
        border-top-color: #333;
    }
    
    .question-title {
        color: #e0e0e0;
    }
    
    .question-description {
        color: #b0b0b0;
    }
    
    .auto-advance-indicator {
        background: rgba(74, 144, 226, 0.1);
        color: #b0b0b0;
    }
    
    .survey-auto-advance-info {
        background: #2a2a2a;
        color: #b0b0b0;
        border-color: #444;
    }
}