/* Comprehension Stage Styles - Modern Enhanced */
.comprehension-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

@media (min-width: 640px) {
    .comprehension-container {
        gap: 2rem;
    }
}

/* Smooth fade-in animation for question transitions */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-container:not(.hidden) {
    animation: fadeInUp 0.5s ease-out;
}

/* Content Container */
.space-y-8 {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 0.5rem;
}

@media (min-width: 640px) {
    .space-y-8 {
        padding: 0;
    }
}

/* AI Assessment Results Container */
.ai-assessment-results {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
    position: relative;
    width: 100%;
}

.ai-assessment-results.show {
    opacity: 1;
    visibility: visible;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    font-size: 0.875rem;
}

@media (min-width: 640px) {
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

.btn-primary {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    color: white !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
    border: none;
}

.btn-primary:hover:not(.cursor-not-allowed) {
    background: linear-gradient(90deg, var(--accent-hover), var(--accent-primary));
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    border: 1px solid var(--accent-light);
    color: var(--text-primary);
}

/* Navigation Controls */
.navigation-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .navigation-controls {
        gap: 1rem;
    }
}

/* Question Container Styles */
.question-container {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

.question-container.hidden {
    display: none;
}

.question-container.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

.question-container.fade-out {
    opacity: 0;
}

/* Question Card Styles - Glassmorphism Enhanced */
.question-card {
    position: relative;
    overflow: hidden;
}

.question-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a855f7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.question-card:hover::before {
    opacity: 1;
}

@media (min-width: 640px) {
    .question-card {
        padding: 2rem;
    }
}

.question-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

@media (min-width: 640px) {
    .question-header {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
}

/* Enhanced Question Text Styling */
.question-text {
    letter-spacing: 0.01em;
    line-height: 1.5;
    position: relative;
    padding-left: 0.75rem;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.question-text::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.25rem;
    bottom: 0.25rem;
    width: 3px;
    background: linear-gradient(to bottom, var(--primary), var(--accent-secondary));
    border-radius: 3px;
}

/* Enhances focus when hovering over the question card */
.bg-white:hover .question-text {
    transform: translateX(2px);
    color: var(--primary-dark);
}

/* Navigation Controls */
.navigation-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    gap: 1rem;
    padding: 1rem 0;
}

.nav-button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
}

.nav-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-button.submit-button {
    background-color: var(--success);
    color: white;
}

.nav-button.submit-button:hover:not(:disabled) {
    background-color: var(--success-dark);
    transform: translateY(-1px);
}

/* Progress Indicator */
.progress-indicator {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    min-width: 150px;
}

/* Answer Section - Enhanced */
.answer-section {
    margin-top: 1.5rem;
}

/* Enhanced textarea with modern styling */
.answer-section textarea {
    min-height: 140px;
    max-height: 400px;
    overflow: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
}

.answer-section textarea:focus {
    transform: translateY(-2px);
}

/* Subtle typing animation indicator */
.answer-section textarea:not(:placeholder-shown) {
    border-color: #6366f1;
}

.char-count {
    font-weight: 700;
    min-width: 28px;
    text-align: right;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 0.875rem;
}

.question-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.question-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(16,24,40,0.08);
}

.question-header {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(90deg, rgba(99,102,241,0.08), rgba(236,72,153,0.05));
    border-radius: 8px;
    color: var(--text-primary);
}

.hint {
    font-style: italic;
}

/* Modern animated accents */
.glow-gradient {
    background: linear-gradient(90deg, rgba(99,102,241,0.15), rgba(16,185,129,0.12));
    border-radius: 12px;
    padding: 0.25rem 0.5rem;
}

.score-circle {
    width: 78px;
    height: 78px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,250,255,0.8));
    box-shadow: 0 8px 20px rgba(2,6,23,0.06);
    border: 1px solid rgba(16,24,40,0.04);
}

.score-number {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Animated progress bar for overall average */
.overall-bar {
    height: 12px;
    background: linear-gradient(90deg, rgba(15,23,42,0.06), rgba(15,23,42,0.04));
    border-radius: 9999px;
    overflow: hidden;
}
.overall-bar > .fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent-secondary));
    transition: width 1.6s cubic-bezier(.22,.9,.32,1);
}

/* subtle highlight when panel becomes visible */
.ai-assessment-results.show {
    animation: panelPop 0.36s ease forwards;
}
@keyframes panelPop {
    0% { transform: translateY(8px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Animated number (fade+count) */
.animated-score { display: inline-block; }

/* small sparkle accent */
.sparkle {
    position: relative;
}
.sparkle::after {
    content: '';
    position: absolute;
    right: -6px;
    top: -6px;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle at 30% 30%, #fff, rgba(255,255,255,0));
    opacity: 0.9;
    transform: rotate(20deg);
}

/* Feedback Section */
.feedback-section {
    background-color: var(--accent-light);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
}

/* Enhanced Feedback Section */
.feedback-section {
    background-color: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-top: 1rem;
    border-left: 4px solid var(--accent-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.feedback-section:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Score Badge */
.score-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 0.875rem;
}

/* Score Badge Styling */
.score-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Error Message */
.error-message {
    background-color: var(--error-light);
    color: var(--error);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

.error-message.fade-out {
    opacity: 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Feedback text animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feedback-section p {
    animation: fadeInUp 0.5s ease forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

.feedback-section p:nth-child(2) {
    animation-delay: 0.4s;
}

/* Speaking Assessment Feedback */
.speaking-feedback {
    font-size: 1rem;
    line-height: 1.5;
}

.feedback-item {
    margin-bottom: 0.75rem;
}

.feedback-general {
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.score-label {
    font-weight: 500;
}

/* Make sure the feedback text is concise visually */
.feedback-text {
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}

/* Enhanced Feedback Styling */
.feedback-content {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.feedback-content:hover {
    transform: translateY(-2px);
}

/* Mobile-specific optimizations */
@media (max-width: 639px) {
    /* Reduce transforms on mobile for better performance */
    .feedback-content:hover {
        transform: none;
    }
    
    /* Optimize text for mobile reading */
    .feedback-text {
        max-width: 100%;
        font-size: 0.875rem;
        line-height: 1.6;
    }
    
    /* Better touch targets */
    .btn {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Improved spacing for small screens */
    .question-container {
        margin-bottom: 1rem;
    }
    
    /* Better typography scaling */
    .question-text {
        font-size: 0.875rem;
        line-height: 1.5;
    }
    
    /* Compact progress indicators */
    .progress-indicator {
        font-size: 0.75rem;
    }
}

/* Floating Next Button for small screens */
.floating-next {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 60;
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    box-shadow: 0 12px 30px rgba(2,6,23,0.12);
    display: none;
}

@media (max-width: 639px) {
    .floating-next { display: inline-flex; align-items: center; justify-content: center; }
}

/* Ensure primary navigation Next button is always visible */
.next-button,
.nav-button.next-button {
    opacity: 1;
    visibility: visible;
    display: inline-flex;
    pointer-events: auto;
}

/* Make sure Next button has higher visual priority on small screens */
@media (max-width: 639px) {
    .next-button, .nav-button.next-button {
        min-width: 64px;
        padding: 0.6rem 0.9rem;
        font-weight: 700;
        z-index: 70;
    }
}

/* Tablet and larger screens */
@media (min-width: 768px) {
    .feedback-content:hover {
        transform: translateY(-2px) scale(1.01);
    }
    
    .question-text {
        font-size: 1rem;
        line-height: 1.6;
    }
}

/* AI Assessment responsive grid and card styles */
.ai-assessment-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .ai-assessment-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.assessment-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.assessment-details {
    font-size: 0.95rem;
    background: linear-gradient(180deg, rgba(250,250,255,0.8), rgba(245,245,250,0.8));
}

.details-toggle {
    align-self: flex-start;
    padding: 0.45rem 0.8rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
}

.assessment-scores .score-circle {
    width: 64px;
    height: 64px;
}

@media (min-width: 640px) {
    .assessment-scores .score-circle {
        width: 78px;
        height: 78px;
    }
}

.assessment-scores .score-number {
    font-size: 1.1rem;
}

/* Make cards stack nicely inside AI Assessment panel */
.ai-assessment-results > .space-y-4, .ai-assessment-results .bg-white.rounded-xl {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ai-assessment-results .bg-white.rounded-xl:hover {
    transform: translateY(-3px);
}

/* Improve contrast and spacing for mobile */
@media (max-width: 639px) {
    .ai-assessment-results {
        padding: 0.75rem;
    }
    .ai-assessment-results .score-number { font-size: 1rem; }
}

    /* Polished AI Assessment UI */
    .ai-assessment-panel {
        border-radius: 14px;
        padding: 1rem;
        background: linear-gradient(180deg, #ffffff, #fbfdff);
        box-shadow: 0 8px 30px rgba(2,6,23,0.06);
        border: 1px solid rgba(16,24,40,0.04);
    }

    .ai-assessment-header {
        display: flex;
        gap: 1rem;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 0.25rem;
    }

    .ai-assessment-title {
        display: flex;
        gap: 0.75rem;
        align-items: center;
    }

    .ai-assessment-title .icon {
        width: 44px;
        height: 44px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(99,102,241,0.08));
        color: var(--primary);
        box-shadow: 0 6px 18px rgba(59,130,246,0.06);
        font-size: 18px;
    }

    .ai-overall-card {
        display: flex;
        gap: 1rem;
        align-items: center;
    }

    .ai-overall .score-circle {
        width: 96px;
        height: 96px;
        border-radius: 9999px;
        background: conic-gradient(var(--primary) 0deg, var(--accent-secondary) 140deg, rgba(0,0,0,0.04) 140deg 360deg);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: 700;
        box-shadow: 0 10px 30px rgba(16,24,40,0.06);
    }

    .ai-overall .score-number { color: #fff; font-size: 1.45rem; }

    /* Assessment details smooth transition */
    .assessment-details {
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                    opacity 0.3s ease;
    }


.feedback-content p {
    line-height: 1.7;
    margin-bottom: 0;
}

.feedback-content .font-bold, 
.feedback-content .highlight-text {
    font-size: 1.05rem;
    animation: highlight-fade 1.5s ease-in-out;
    display: inline-block;
    padding: 0 3px;
    border-radius: 3px;
}

@keyframes highlight-fade {
    0% { background-color: rgba(34, 197, 94, 0.2); }
    100% { background-color: transparent; }
}

/* Add subtle indication to the feedback sections */
.feedback-content::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(to bottom, var(--accent-primary), transparent);
    opacity: 0.6;
}

.feedback-content:nth-child(2)::before {
    background: linear-gradient(to bottom, var(--accent-secondary), transparent);
}

.feedback-content p {
    line-height: 1.6;
}

.feedback-content .font-bold {
    font-size: 1.05rem;
    animation: highlight-fade 1s ease-in-out;
}

@keyframes highlight-fade {
    0% { background-color: rgba(34, 197, 94, 0.2); }
    100% { background-color: transparent; }
}
