/**
 * AI Solution Checker Styles
 * Floating window interface for AI teacher solution checking
 */

/* Main floating window */
.ai-solution-checker-window {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 2px solid #e1e5e9;
    z-index: 10000;
    display: none;
    font-family: 'Roboto', sans-serif;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ai-solution-checker-window:hover {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
}

/* Header */
.checker-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.checker-header:active {
    cursor: grabbing;
}

.checker-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.checker-title i {
    font-size: 18px;
    color: #ffd700;
}

.checker-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Body */
.checker-body {
    padding: 20px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Enable momentum scrolling on iOS */
    touch-action: pan-y; /* Allow vertical touch scrolling */
}

/* Enhanced scrollbar styles for better touch interaction */
.checker-body::-webkit-scrollbar {
    width: 12px;
}

.checker-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.checker-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
    border: 2px solid #f1f1f1;
    min-height: 40px;
}

.checker-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.checker-body::-webkit-scrollbar-thumb:active {
    background: #888;
}

/* Responsive scrollbar adjustments */
@media (max-width: 768px) {
    .checker-body::-webkit-scrollbar {
        width: 14px; /* Wider on mobile for easier touch */
    }
    
    .checker-body::-webkit-scrollbar-thumb {
        min-height: 50px; /* Larger touch target */
    }
}

@media (max-width: 480px) {
    .checker-body::-webkit-scrollbar {
        width: 16px; /* Even wider on small mobile */
    }
    
    .checker-body::-webkit-scrollbar-thumb {
        min-height: 60px; /* Even larger touch target */
    }
}

/* Analysis Controls */
.analysis-controls {
    margin-bottom: 20px;
}

/* Settings Toggle */
.settings-toggle {
    margin-bottom: 15px;
}

.toggle-btn {
    width: 100%;
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    background: linear-gradient(135deg, #5a6268, #495057);
    transform: translateY(-1px);
}

.toggle-btn span {
    flex: 1;
    text-align: left;
    margin-left: 8px;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.settings-content {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.control-group {
    margin-bottom: 15px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.subject-select,
.grade-select,
.strictness-select,
.language-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

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

/* One-click mode checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}

.one-click-checkbox {
    display: none;
}

.checkmark {
    position: relative;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border: 2px solid #e1e5e9;
    border-radius: 4px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.one-click-checkbox:checked + .checkmark {
    background: #667eea;
    border-color: #667eea;
}

.one-click-checkbox:checked + .checkmark::after {
    opacity: 1;
}

.checkbox-text {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.setting-description {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-top: 4px;
    margin-left: 32px;
    line-height: 1.4;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.analyze-btn,
.clear-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.analyze-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.analyze-btn:hover {
    background: linear-gradient(135deg, #218838, #1ca085);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

.clear-btn {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
}

.clear-btn:hover {
    background: linear-gradient(135deg, #5a6268, #495057);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.3);
}

/* Analysis Status */
.analysis-status {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Enhanced scrollbar for analysis status */
.analysis-status::-webkit-scrollbar {
    width: 10px;
}

.analysis-status::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 5px;
}

.analysis-status::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    min-height: 30px;
}

.analysis-status::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

.analysis-status.loading {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1976d2;
}

.analysis-status.success {
    background: #e8f5e8;
    border-color: #28a745;
    color: #155724;
}

.analysis-status.error {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.analysis-status.warning {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.status-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
}

.status-content i {
    font-size: 16px;
}

/* Feedback Summary */
.feedback-summary {
    background: #f8f9fa;
    border-radius: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 2px solid #e9ecef;
    max-height: 300px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Enhanced scrollbar for feedback summary */
.feedback-summary::-webkit-scrollbar {
    width: 10px;
}

.feedback-summary::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 5px;
}

.feedback-summary::-webkit-scrollbar-thumb {
    background: #17a2b8;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    min-height: 30px;
}

.feedback-summary::-webkit-scrollbar-thumb:hover {
    background: #138496;
}

.summary-header {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    padding: 12px 15px;
}

.summary-header h4 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-content {
    padding: 15px;
}

.summary-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.stat-label {
    font-weight: 500;
    color: #495057;
    font-size: 13px;
}

.stat-value {
    font-weight: 700;
    font-size: 16px;
}

.stat-value.correct {
    color: #28a745;
}

.stat-value.incorrect {
    color: #dc3545;
}

.stat-value.grade {
    color: #667eea;
    font-size: 18px;
}

.general-feedback {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Enhanced scrollbar for general feedback */
.general-feedback::-webkit-scrollbar {
    width: 8px;
}

.general-feedback::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.general-feedback::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
    border: 1px solid #f8f9fa;
    min-height: 20px;
}

.general-feedback::-webkit-scrollbar-thumb:hover {
    background: #5a67d8;
}

.feedback-text h5 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 14px;
}

.feedback-text p {
    margin: 0 0 10px 0;
    line-height: 1.5;
    color: #555;
    font-size: 14px;
}

/* Detailed Feedback */
.detailed-feedback {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Enhanced scrollbar for detailed feedback */
.detailed-feedback::-webkit-scrollbar {
    width: 10px;
}

.detailed-feedback::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 5px;
}

.detailed-feedback::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    min-height: 30px;
}

.detailed-feedback::-webkit-scrollbar-thumb:hover {
    background: #5a67d8;
}

.feedback-header {
    margin-bottom: 15px;
}

.feedback-header h4 {
    margin: 0;
    color: #333;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.solution-feedback {
    background: white;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 2px solid #e9ecef;
    transition: all 0.2s ease;
    max-height: 300px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    position: relative;
}

.solution-feedback:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

/* Ensure solution containers are touch scrollable */
.solution-feedback * {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Enhanced scrollbar for solution feedback containers */
.solution-feedback::-webkit-scrollbar {
    width: 10px;
}

.solution-feedback::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 5px;
}

.solution-feedback::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    min-height: 30px;
}

.solution-feedback::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

.solution-feedback.correct::-webkit-scrollbar-thumb {
    background: #28a745;
}

.solution-feedback.correct::-webkit-scrollbar-thumb:hover {
    background: #1e7e34;
}

.solution-feedback.incorrect::-webkit-scrollbar-thumb {
    background: #dc3545;
}

.solution-feedback.incorrect::-webkit-scrollbar-thumb:hover {
    background: #c82333;
}

.solution-feedback.correct {
    border-left: 4px solid #28a745;
}

.solution-feedback.incorrect {
    border-left: 4px solid #dc3545;
}

.solution-header {
    background: #f8f9fa;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #e9ecef;
}

.solution-status {
    font-size: 18px;
}

.solution-title {
    flex: 1;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.solution-grade {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.work-shown {
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    color: #495057;
    font-size: 13px;
    line-height: 1.5;
    max-height: 150px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Enhanced scrollbar for work shown */
.work-shown::-webkit-scrollbar {
    width: 8px;
}

.work-shown::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 4px;
}

.work-shown::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    min-height: 20px;
}

.work-shown::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

.solution-feedback-text {
    padding: 15px;
    line-height: 1.6;
    color: #555;
    font-size: 14px;
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Enhanced scrollbar for solution feedback text */
.solution-feedback-text::-webkit-scrollbar {
    width: 8px;
}

.solution-feedback-text::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.solution-feedback-text::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 4px;
    border: 1px solid #f8f9fa;
    min-height: 20px;
}

.solution-feedback-text::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

/* Dark theme support */
:root.dark-theme .ai-solution-checker-window {
    background: #2c3e50;
    border-color: #34495e;
}

:root.dark-theme .checker-body {
    color: #ffffff;
}

:root.dark-theme .settings-content {
    background: #34495e;
    border-color: #4a6741;
}

:root.dark-theme .control-group label {
    color: #ffffff;
}

:root.dark-theme .grade-select,
:root.dark-theme .strictness-select,
:root.dark-theme .language-select {
    background: #34495e;
    border-color: #4a6741;
    color: #ffffff;
}

:root.dark-theme .checkmark {
    background: #34495e;
    border-color: #4a6741;
}

:root.dark-theme .one-click-checkbox:checked + .checkmark {
    background: #667eea;
    border-color: #667eea;
}

:root.dark-theme .checkbox-text {
    color: #ffffff;
}

:root.dark-theme .setting-description {
    color: #bdc3c7;
}

:root.dark-theme .analysis-status {
    background: #34495e;
    border-color: #4a6741;
    color: #ffffff;
}

:root.dark-theme .analysis-status.loading {
    background: #34495e;
    border-color: #3498db;
    color: #ffffff;
}

:root.dark-theme .analysis-status.success {
    background: #27ae60;
    border-color: #2ecc71;
    color: #ffffff;
}

:root.dark-theme .analysis-status.error {
    background: #e74c3c;
    border-color: #c0392b;
    color: #ffffff;
}

:root.dark-theme .feedback-summary {
    background: #34495e;
    border-color: #4a6741;
}

:root.dark-theme .summary-content {
    color: #ffffff;
}

:root.dark-theme .stat-item {
    background: #2c3e50;
    border-color: #4a6741;
    color: #ffffff;
}

:root.dark-theme .stat-label {
    color: #bdc3c7;
}

:root.dark-theme .general-feedback {
    background: #2c3e50;
    color: #ffffff;
}

:root.dark-theme .feedback-text h5 {
    color: #ffffff;
}

:root.dark-theme .feedback-text p {
    color: #ecf0f1;
}

:root.dark-theme .solution-feedback {
    background: #2c3e50;
    border-color: #4a6741;
}

:root.dark-theme .solution-header {
    background: #34495e;
    border-color: #4a6741;
}

:root.dark-theme .solution-title {
    color: #ffffff;
}

:root.dark-theme .work-shown {
    background: #34495e;
    border-color: #4a6741;
    color: #ecf0f1;
}

:root.dark-theme .solution-feedback-text {
    color: #ffffff;
}

/* Dark theme scrollbar styles */
:root.dark-theme .checker-body::-webkit-scrollbar-track {
    background: #34495e;
}

:root.dark-theme .checker-body::-webkit-scrollbar-thumb {
    background: #5a6c7d;
    border-color: #34495e;
}

:root.dark-theme .checker-body::-webkit-scrollbar-thumb:hover {
    background: #4a5c6d;
}

:root.dark-theme .analysis-status::-webkit-scrollbar-track {
    background: #34495e;
}

:root.dark-theme .analysis-status::-webkit-scrollbar-thumb {
    background: #5a6c7d;
    border-color: #34495e;
}

:root.dark-theme .feedback-summary::-webkit-scrollbar-track {
    background: #34495e;
}

:root.dark-theme .feedback-summary::-webkit-scrollbar-thumb {
    background: #17a2b8;
    border-color: #34495e;
}

:root.dark-theme .detailed-feedback::-webkit-scrollbar-track {
    background: #34495e;
}

:root.dark-theme .detailed-feedback::-webkit-scrollbar-thumb {
    background: #667eea;
    border-color: #34495e;
}

:root.dark-theme .solution-feedback::-webkit-scrollbar-track {
    background: #34495e;
}

:root.dark-theme .solution-feedback::-webkit-scrollbar-thumb {
    background: #5a6c7d;
    border-color: #34495e;
}

:root.dark-theme .solution-feedback.correct::-webkit-scrollbar-thumb {
    background: #28a745;
}

:root.dark-theme .solution-feedback.incorrect::-webkit-scrollbar-thumb {
    background: #dc3545;
}

:root.dark-theme .solution-feedback-text::-webkit-scrollbar-track {
    background: #34495e;
}

:root.dark-theme .solution-feedback-text::-webkit-scrollbar-thumb {
    background: #5a6c7d;
    border-color: #34495e;
}

:root.dark-theme .work-shown::-webkit-scrollbar-track {
    background: #34495e;
}

:root.dark-theme .work-shown::-webkit-scrollbar-thumb {
    background: #5a6c7d;
    border-color: #34495e;
}

:root.dark-theme .general-feedback::-webkit-scrollbar-track {
    background: #34495e;
}

:root.dark-theme .general-feedback::-webkit-scrollbar-thumb {
    background: #667eea;
    border-color: #34495e;
}

/* Solution action buttons */
.solution-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.action-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
}

.action-btn:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.action-btn:active {
    transform: scale(0.95);
}

.copy-btn {
    background: #28a745;
}

.copy-btn:hover {
    background: #1e7e34;
}

.add-to-canvas-btn {
    background: #17a2b8;
}

.add-to-canvas-btn:hover {
    background: #138496;
}

.action-btn i {
    font-size: 11px;
}

/* Dark theme for action buttons */
:root.dark-theme .action-btn {
    color: #ffffff;
}

:root.dark-theme .copy-btn {
    background: #28a745;
}

:root.dark-theme .copy-btn:hover {
    background: #1e7e34;
}

:root.dark-theme .add-to-canvas-btn {
    background: #17a2b8;
}

:root.dark-theme .add-to-canvas-btn:hover {
    background: #138496;
}

/* Teacher comments header and actions */
.teacher-comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.teacher-comments-header h5 {
    margin: 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.teacher-comments-actions {
    display: flex;
    gap: 8px;
}

/* Dark theme for teacher comments */
:root.dark-theme .teacher-comments-header h5 {
    color: #ffffff;
}

/* Responsive design */
@media (max-width: 768px) {
    .ai-solution-checker-window {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
        top: 10px;
        max-height: calc(100vh - 20px);
    }
    
    .checker-body {
        padding: 15px;
        max-height: calc(100vh - 120px);
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    /* Adjust feedback text areas for mobile */
    .solution-feedback-text {
        max-height: 150px;
        font-size: 13px;
    }
    
    .work-shown {
        max-height: 120px;
        font-size: 12px;
    }
    
    .general-feedback {
        max-height: 150px;
    }
    
    /* Adjust main containers for mobile */
    .feedback-summary {
        max-height: 250px;
    }
    
    .detailed-feedback {
        max-height: 300px;
    }
    
    .analysis-status {
        max-height: 150px;
    }
    
    .solution-feedback {
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .ai-solution-checker-window {
        width: calc(100vw - 10px);
        right: 5px;
        left: 5px;
        top: 5px;
        max-height: calc(100vh - 10px);
    }
    
    .checker-body {
        padding: 10px;
        max-height: calc(100vh - 100px);
    }
    
    .checker-header {
        padding: 10px 15px;
    }
    
    .checker-title {
        font-size: 14px;
    }
    
    /* Further adjust feedback text areas for small mobile screens */
    .solution-feedback-text {
        max-height: 120px;
        font-size: 12px;
        padding: 12px;
    }
    
    .work-shown {
        max-height: 100px;
        font-size: 11px;
        padding: 10px 12px;
    }
    
    .general-feedback {
        max-height: 120px;
        padding: 12px;
    }
    
    /* Further adjust main containers for small mobile screens */
    .feedback-summary {
        max-height: 200px;
    }
    
    .detailed-feedback {
        max-height: 250px;
    }
    
    .analysis-status {
        max-height: 120px;
    }
    
    .solution-feedback {
        max-height: 200px;
    }
    
    /* Responsive scrollbars for small mobile */
    .feedback-summary::-webkit-scrollbar,
    .detailed-feedback::-webkit-scrollbar,
    .analysis-status::-webkit-scrollbar,
    .solution-feedback::-webkit-scrollbar {
        width: 12px;
    }
    
    .feedback-summary::-webkit-scrollbar-thumb,
    .detailed-feedback::-webkit-scrollbar-thumb,
    .analysis-status::-webkit-scrollbar-thumb,
    .solution-feedback::-webkit-scrollbar-thumb {
        min-height: 40px;
    }
}

@media (max-height: 600px) {
    .ai-solution-checker-window {
        top: 5px;
        max-height: calc(100vh - 10px);
    }
    
    .checker-body {
        padding: 15px;
        max-height: calc(100vh - 80px);
    }
}

/* Animation for checkmarks on canvas */
@keyframes checkmarkAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* RTL Language Support */
.ai-solution-checker-window.rtl-language {
    direction: rtl;
    text-align: right;
}

.ai-solution-checker-window.rtl-language .checker-title {
    flex-direction: row-reverse;
}

.ai-solution-checker-window.rtl-language .checker-controls {
    flex-direction: row-reverse;
}

.ai-solution-checker-window.rtl-language .control-group {
    text-align: right;
}

.ai-solution-checker-window.rtl-language .control-group label {
    text-align: right;
    display: block;
    margin-bottom: 5px;
}

.ai-solution-checker-window.rtl-language .subject-select,
.ai-solution-checker-window.rtl-language .grade-select,
.ai-solution-checker-window.rtl-language .strictness-select,
.ai-solution-checker-window.rtl-language .language-select {
    text-align: right;
    direction: rtl;
}

.ai-solution-checker-window.rtl-language .checkbox-label {
    flex-direction: row-reverse;
    text-align: right;
}

.ai-solution-checker-window.rtl-language .setting-description {
    text-align: right;
    direction: rtl;
}

.ai-solution-checker-window.rtl-language .action-buttons {
    flex-direction: row-reverse;
}

.ai-solution-checker-window.rtl-language .analyze-btn,
.ai-solution-checker-window.rtl-language .clear-btn {
    flex-direction: row-reverse;
}

.ai-solution-checker-window.rtl-language .status-content {
    flex-direction: row-reverse;
    text-align: right;
}

.ai-solution-checker-window.rtl-language .summary-header h4 {
    text-align: right;
}

.ai-solution-checker-window.rtl-language .summary-stats {
    text-align: right;
}

.ai-solution-checker-window.rtl-language .stat-item {
    flex-direction: row-reverse;
    text-align: right;
}

.ai-solution-checker-window.rtl-language .teacher-comments-header {
    flex-direction: row-reverse;
}

.ai-solution-checker-window.rtl-language .teacher-comments-actions {
    flex-direction: row-reverse;
}

.ai-solution-checker-window.rtl-language .solution-header {
    flex-direction: row-reverse;
}

.ai-solution-checker-window.rtl-language .solution-actions {
    flex-direction: row-reverse;
}

.ai-solution-checker-window.rtl-language .feedback-header h4 {
    text-align: right;
}

.ai-solution-checker-window.rtl-language .solution-feedback-text {
    text-align: right;
    direction: rtl;
}

.ai-solution-checker-window.rtl-language .work-shown {
    text-align: right;
    direction: rtl;
}

/* Dark theme RTL support */
:root.dark-theme .ai-solution-checker-window.rtl-language {
    background: #2c3e50;
    border-color: #34495e;
    color: #ecf0f1;
}

/* Minimal Results RTL Support */
.ai-minimal-results.rtl-language {
    direction: rtl;
    text-align: right;
}

.ai-minimal-results.rtl-language .minimal-header {
    flex-direction: row-reverse;
}

.ai-minimal-results.rtl-language .minimal-actions {
    flex-direction: row-reverse;
}

.ai-minimal-results.rtl-language .minimal-btn {
    flex-direction: row-reverse;
}

.ai-minimal-results.rtl-language .stat-row {
    flex-direction: row-reverse;
    text-align: right;
}

.ai-minimal-results.rtl-language .minimal-message {
    text-align: right;
    direction: rtl;
}

/* Dark theme minimal results RTL support */
:root.dark-theme .ai-minimal-results.rtl-language {
    background: rgba(44, 62, 80, 0.95);
    border-color: rgba(102, 126, 234, 0.4);
}

/* Toolbar button analyzing state */
#aiSolutionChecker.analyzing {
    background: linear-gradient(135deg, #dc3545, #c82333) !important;
    color: white !important;
    animation: analyzingPulse 1.5s ease-in-out infinite;
    border: 2px solid #dc3545 !important;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.5) !important;
}

#aiSolutionChecker.analyzing:hover {
    background: linear-gradient(135deg, #c82333, #a71e2a) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.7) !important;
}

#aiSolutionChecker.analyzing i {
    animation: stopIconPulse 1s ease-in-out infinite;
}

@keyframes analyzingPulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(220, 53, 69, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 25px rgba(220, 53, 69, 0.8);
        transform: scale(1.02);
    }
}

@keyframes stopIconPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* Dark theme analyzing state */
:root.dark-theme #aiSolutionChecker.analyzing {
    background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
    border-color: #e74c3c !important;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.5) !important;
}

:root.dark-theme #aiSolutionChecker.analyzing:hover {
    background: linear-gradient(135deg, #c0392b, #a93226) !important;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.7) !important;
}
