/**
 * This file is part of Moodle - https://moodle.org/
 *
 * Moodle is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Moodle is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Moodle.  If not, see <https://www.gnu.org/licenses/>.
 */

/**
 * Styles for AI ChatBot Block
 *
 * @package    block_ai_chatbot
 * @copyright  2025 Esteban Piazza <esteban@codeki.org>
 * @copyright  2026 Remy Emmanuel (modifications)
 * @license    https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

/* ChatBot Block Styles */
.chatbot-container {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    overflow: hidden;
    box-sizing: border-box;
}

.chatbot-header {
    font-weight: bold;
    font-size: 16px;
    color: #495057;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

.chatbot-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.chatbot-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.chatbot-button {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-width: 100px;
}

.chatbot-button-icon {
    min-width: auto;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-button-icon svg {
    display: block;
}

.chatbot-button:hover {
    background: #0056b3;
}

.chatbot-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.chatbot-response:empty {
    display: none;
}

.chatbot-question {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-weight: 500;
    color: #1565c0;
}

.chatbot-answer {
    background: #f1f8e9;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    margin-top: 10px;
}

.chatbot-answer-header {
    background: #4caf50;
    color: white;
    padding: 8px 12px;
    border-radius: 6px 6px 0 0;
    font-weight: bold;
    font-size: 14px;
}

.chatbot-answer-content {
    padding: 12px;
    color: #2e7d32;
    line-height: 1.5;
}

.chatbot-token-footer {
    padding: 4px 12px;
    text-align: right;
    color: #888;
    font-size: 11px;
    border-top: 1px solid #e0e0e0;
}

.chatbot-error {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ef9a9a;
    margin-top: 10px;
}

.chatbot-form {
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.chatbot-loading {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    margin: 10px 0;
}

.chatbot-dots {
    display: inline-block;
    animation: chatbot-blink 1.4s infinite both;
}

.chatbot-dots:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-dots:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatbot-blink {
    0%, 80%, 100% {
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
}

/* Info button */
.chatbot-info-button {
    background: #6c757d;
}

.chatbot-info-button:hover {
    background: #5a6268;
}

/* Modal styles */
.chatbot-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatbot-modal-fade-in 0.2s ease-out;
}

@keyframes chatbot-modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.chatbot-modal {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: chatbot-modal-slide-in 0.2s ease-out;
}

@keyframes chatbot-modal-slide-in {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chatbot-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.chatbot-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #495057;
}

.chatbot-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    line-height: 1;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.chatbot-modal-close:hover {
    background: #e9ecef;
    color: #495057;
}

.chatbot-modal-content {
    padding: 20px;
    overflow-y: auto;
    line-height: 1.6;
    color: #495057;
}

.chatbot-modal-content p {
    margin: 0 0 12px 0;
}

.chatbot-modal-content p:last-child {
    margin-bottom: 0;
}

.chatbot-modal-content strong {
    color: #212529;
}

/* ================================================
   Alert System Styles - Report Table
   ================================================ */

/* Row highlighting for alerts that exceed threshold */
.block_ai_chatbot_report tr.alert-exceeded {
    background-color: #f8d7da !important;
}

.block_ai_chatbot_report tr.alert-exceeded:hover {
    background-color: #f5c6cb !important;
}

/* Alert level badges */
.block_ai_chatbot_report .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    font-weight: 500;
}

/* Orange color for level 3 (not in Bootstrap by default) */
.block_ai_chatbot_report .bg-orange {
    background-color: #fd7e14 !important;
}

/* Alert level badge colors based on severity */
.alert-level-badge-1,
.alert-level-badge-2 {
    background-color: #ffc107 !important;
    color: #212529 !important;
}

.alert-level-badge-3 {
    background-color: #fd7e14 !important;
    color: #fff !important;
}

.alert-level-badge-4,
.alert-level-badge-5 {
    background-color: #dc3545 !important;
    color: #fff !important;
}

/* Alert indicator icon in response area */
.chatbot-alert-indicator {
    display: inline-block;
    padding: 2px 8px;
    margin-left: 8px;
    font-size: 12px;
    border-radius: 4px;
    background-color: #dc3545;
    color: #fff;
}

/* Report table responsive improvements */
.block_ai_chatbot_report {
    font-size: 0.9rem;
}

.block_ai_chatbot_report td {
    vertical-align: middle;
}

/* Alert statistics cards */
.alert-stats-card {
    border-left: 4px solid #dc3545;
    background: #fff;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.alert-stats-card.level-warning {
    border-left-color: #ffc107;
}

.alert-stats-card.level-danger {
    border-left-color: #dc3545;
}

/* ========================================
   COACHING MODE BUTTONS
   ======================================== */
.chatbot-coaching-modes {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    flex-wrap: wrap;
}

.chatbot-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    background: #fff;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chatbot-mode-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #212529;
}

.chatbot-mode-btn:active {
    background: #dee2e6;
}

/* ========================================
   QUIZ WIDGETS
   ======================================== */
.chatbot-quiz-container {
    padding: 5px 0;
}

.chatbot-quiz-question {
    margin-bottom: 15px;
    padding: 10px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.chatbot-quiz-title {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.chatbot-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chatbot-quiz-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #f8f9fa;
    color: #495057;
    cursor: pointer;
    font-size: 0.85rem;
    text-align: left;
    transition: all 0.15s ease;
}

.chatbot-quiz-option:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

.chatbot-quiz-option:disabled {
    cursor: default;
    opacity: 0.8;
}

.chatbot-quiz-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #dee2e6;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.chatbot-quiz-option.chatbot-quiz-correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.chatbot-quiz-option.chatbot-quiz-correct .chatbot-quiz-letter {
    background: #28a745;
    color: #fff;
}

.chatbot-quiz-option.chatbot-quiz-wrong {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.chatbot-quiz-option.chatbot-quiz-wrong .chatbot-quiz-letter {
    background: #dc3545;
    color: #fff;
}

.chatbot-quiz-explanation {
    margin-top: 8px;
    padding: 8px 12px;
    background: #e8f4f8;
    border-radius: 6px;
    font-size: 0.83rem;
    color: #0c5460;
    border-left: 3px solid #17a2b8;
}

/* ========================================
   QUIZ FEEDBACK PANEL
   ======================================== */
.chatbot-quiz-feedback {
    margin-top: 15px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    background: #f8f9fa;
}

.chatbot-quiz-feedback-score {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.chatbot-quiz-feedback-icon {
    font-size: 1.3rem;
}

.chatbot-quiz-feedback-label {
    color: #6c757d;
    font-weight: 500;
}

.chatbot-quiz-feedback-value {
    font-size: 1.2rem;
}

.chatbot-quiz-feedback-pct {
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 400;
}

/* Progress bar */
.chatbot-quiz-feedback-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.chatbot-quiz-feedback-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

/* Score-level color theming */
.chatbot-quiz-score-excellent .chatbot-quiz-feedback-value {
    color: #28a745;
}
.chatbot-quiz-score-excellent .chatbot-quiz-feedback-bar-fill {
    background: #28a745;
}

.chatbot-quiz-score-good .chatbot-quiz-feedback-value {
    color: #17a2b8;
}
.chatbot-quiz-score-good .chatbot-quiz-feedback-bar-fill {
    background: #17a2b8;
}

.chatbot-quiz-score-decent .chatbot-quiz-feedback-value {
    color: #ffc107;
}
.chatbot-quiz-score-decent .chatbot-quiz-feedback-bar-fill {
    background: #ffc107;
}

.chatbot-quiz-score-weak .chatbot-quiz-feedback-value {
    color: #dc3545;
}
.chatbot-quiz-score-weak .chatbot-quiz-feedback-bar-fill {
    background: #dc3545;
}

/* Advice text */
.chatbot-quiz-feedback-advice {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #495057;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 6px;
    border-left: 3px solid #6c757d;
}

.chatbot-quiz-score-excellent .chatbot-quiz-feedback-advice {
    border-left-color: #28a745;
    background: #f0faf0;
}

.chatbot-quiz-score-good .chatbot-quiz-feedback-advice {
    border-left-color: #17a2b8;
    background: #f0f9fb;
}

.chatbot-quiz-score-decent .chatbot-quiz-feedback-advice {
    border-left-color: #ffc107;
    background: #fffdf0;
}

.chatbot-quiz-score-weak .chatbot-quiz-feedback-advice {
    border-left-color: #dc3545;
    background: #fdf0f0;
}

/* Resources section */
.chatbot-quiz-feedback-resources {
    margin-top: 8px;
}

.chatbot-quiz-feedback-resources-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #212529;
    margin-bottom: 4px;
}

.chatbot-quiz-feedback-resources-intro {
    font-size: 0.83rem;
    color: #6c757d;
    margin: 0 0 6px 0;
}

.chatbot-quiz-feedback-resources-list {
    padding-left: 20px;
    margin: 0;
}

.chatbot-quiz-feedback-resources-list li {
    font-size: 0.85rem;
    color: #495057;
    margin-bottom: 3px;
    padding: 2px 0;
}

/* Perfect score message */
.chatbot-quiz-feedback-perfect {
    font-size: 0.9rem;
    color: #28a745;
    font-weight: 500;
    text-align: center;
    padding: 6px 0;
}

/* Modal overrides */
.chatbot-content-modal-body .chatbot-quiz-feedback {
    margin-top: 20px;
}

/* ========================================
   RESTART BUTTON (Quiz & Flashcard)
   ======================================== */
.chatbot-coaching-restart-wrapper {
    text-align: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
}

.chatbot-coaching-restart-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 2px solid #007bff;
    border-radius: 24px;
    background: #fff;
    color: #007bff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-coaching-restart-btn:hover {
    background: #007bff;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.chatbot-coaching-restart-btn:active {
    background: #0056b3;
    border-color: #0056b3;
    color: #fff;
}

/* Modal overrides for restart */
.chatbot-content-modal-body .chatbot-coaching-restart-wrapper {
    margin-top: 20px;
    padding-top: 16px;
}

/* RESOURCE LINKS (Quiz Feedback) */
.chatbot-resource-link {
    color: #007bff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}
.chatbot-resource-link:hover {
    color: #0056b3;
    text-decoration: underline;
}
.chatbot-resource-link svg {
    opacity: 0.6;
    flex-shrink: 0;
}
.chatbot-resource-link:hover svg {
    opacity: 1;
}

/* SOURCE LINKS (Inline citations in all RAG responses) */
.chatbot-source-link {
    color: #0066cc;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dotted #0066cc;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.chatbot-source-link:hover {
    color: #004499;
    text-decoration: none;
    border-bottom-style: solid;
}

/* ========================================
   FLASHCARD WIDGETS
   ======================================== */
.chatbot-flashcard-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 5px 0;
}

.chatbot-flashcard {
    width: calc(50% - 5px);
    min-height: 120px;
    perspective: 600px;
    cursor: pointer;
}

.chatbot-flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 120px;
    transition: transform 0.4s ease;
    transform-style: preserve-3d;
}

.chatbot-flashcard.flipped .chatbot-flashcard-inner {
    transform: rotateY(180deg);
}

.chatbot-flashcard-front,
.chatbot-flashcard-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 120px;
    backface-visibility: hidden;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
}

.chatbot-flashcard-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}

.chatbot-flashcard-back {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    transform: rotateY(180deg);
    border: 1px solid rgba(255,255,255,0.2);
}

.chatbot-flashcard-num {
    font-size: 0.7rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chatbot-flashcard-front p,
.chatbot-flashcard-back p {
    margin: 6px 0;
    font-size: 0.85rem;
    line-height: 1.3;
}

.chatbot-flashcard-hint {
    font-size: 0.65rem;
    opacity: 0.6;
    text-align: center;
    margin-top: auto;
}

/* ========================================
   TOPIC SELECTOR
   ======================================== */
.chatbot-topic-selector {
    padding: 10px;
}

.chatbot-topic-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #dee2e6;
}

.chatbot-topic-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chatbot-topic-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 0.85rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chatbot-topic-btn:hover {
    background: #e3f2fd;
    border-color: #90caf9;
    color: #1565c0;
}

.chatbot-topic-btn.chatbot-topic-all {
    background: #e8f5e9;
    border-color: #c8e6c9;
    color: #2e7d32;
    font-weight: 500;
}

.chatbot-topic-btn.chatbot-topic-all:hover {
    background: #c8e6c9;
    border-color: #a5d6a7;
}

.chatbot-topic-course-label {
    width: 100%;
    font-weight: bold;
    font-size: 0.85em;
    color: #555;
    padding: 8px 0 4px 0;
    border-top: 1px solid #e0e0e0;
    margin-top: 4px;
}

.chatbot-topic-course-label:first-child {
    border-top: none;
    margin-top: 0;
}

/* ========================================
   CONTENT MODAL (Quiz, Flashcard, Summary, Plan)
   ======================================== */
.chatbot-content-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatbot-modal-fade-in 0.2s ease-out;
}

.chatbot-content-modal {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    max-width: 750px;
    width: 95%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: chatbot-modal-slide-in 0.25s ease-out;
}

.chatbot-content-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}

.chatbot-content-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-content-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    line-height: 1.6;
    color: #495057;
}

/* Override quiz/flashcard sizing inside content modal */
.chatbot-content-modal-body .chatbot-quiz-container {
    padding: 0;
}

.chatbot-content-modal-body .chatbot-quiz-question {
    padding: 15px;
}

.chatbot-content-modal-body .chatbot-quiz-title {
    font-size: 1rem;
}

.chatbot-content-modal-body .chatbot-quiz-option {
    padding: 10px 15px;
    font-size: 0.9rem;
}

.chatbot-content-modal-body .chatbot-flashcard-container {
    gap: 12px;
    padding: 0;
}

.chatbot-content-modal-body .chatbot-flashcard {
    width: calc(50% - 6px);
    min-height: 150px;
}

.chatbot-content-modal-body .chatbot-flashcard-inner {
    min-height: 150px;
}

.chatbot-content-modal-body .chatbot-flashcard-front,
.chatbot-content-modal-body .chatbot-flashcard-back {
    min-height: 150px;
    padding: 16px;
}

.chatbot-content-modal-body .chatbot-flashcard-front p,
.chatbot-content-modal-body .chatbot-flashcard-back p {
    font-size: 0.95rem;
}

/* Summary/Plan formatted text inside modal */
.chatbot-coaching-formatted h4 {
    color: #212529;
    font-size: 1rem;
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #e9ecef;
}

.chatbot-coaching-formatted h4:first-child {
    margin-top: 0;
}

.chatbot-coaching-formatted ul,
.chatbot-coaching-formatted ol {
    padding-left: 20px;
    margin-bottom: 12px;
}

.chatbot-coaching-formatted li {
    margin-bottom: 4px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.chatbot-coaching-formatted p {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Chat inline notification (replaces the full response) */
.chatbot-coaching-notification {
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}

.chatbot-coaching-notification-text {
    font-size: 0.85rem;
    color: #2e7d32;
    font-weight: 500;
}

.chatbot-coaching-notification-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 0.8rem;
    border: 1px solid #4caf50;
    border-radius: 16px;
    background: #fff;
    color: #4caf50;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chatbot-coaching-notification-btn:hover {
    background: #4caf50;
    color: #fff;
}

/* Responsive: content modal full screen on mobile */
@media (max-width: 600px) {
    .chatbot-content-modal {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .chatbot-content-modal-header {
        border-radius: 0;
    }

    .chatbot-content-modal-body .chatbot-flashcard {
        width: 100%;
    }
}

/* ========================================
   PROGRESSIVE QUIZ / FLASHCARD
   ======================================== */

/* Feedback banner at top of modal */
.chatbot-progressive-feedback {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: chatbot-feedback-slide-in 0.3s ease-out;
}

@keyframes chatbot-feedback-slide-in {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.chatbot-progressive-feedback.correct {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.chatbot-progressive-feedback.wrong {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.chatbot-progressive-feedback-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.chatbot-progressive-feedback-text {
    flex: 1;
    font-size: 0.88rem;
    line-height: 1.5;
}

.chatbot-progressive-feedback-text strong {
    display: block;
    margin-bottom: 2px;
    font-size: 0.92rem;
}

.chatbot-progressive-feedback-text .chatbot-resource-link {
    color: #0056b3;
    font-weight: 500;
}

.chatbot-progressive-feedback-text .chatbot-resource-link:hover {
    color: #003d80;
}

/* Question area with slide transition */
.chatbot-progressive-question {
    animation: chatbot-question-slide-in 0.4s ease-out;
}

@keyframes chatbot-question-slide-in {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.chatbot-progressive-question.exiting {
    animation: chatbot-question-slide-out 0.3s ease-in forwards;
}

@keyframes chatbot-question-slide-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-30px); }
}

/* Timer display */
.chatbot-progressive-timer {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.75rem;
    color: #6c757d;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 8px;
    border-radius: 10px;
    font-variant-numeric: tabular-nums;
}

/* Question wrapper (relative for timer) */
.chatbot-progressive-question-wrapper {
    position: relative;
    padding: 10px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fff;
    margin-bottom: 10px;
}

/* Quiz options within progressive mode */
.chatbot-progressive-question-wrapper .chatbot-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.88rem;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option:hover {
    border-color: #007bff;
    background: #f0f7ff;
    color: #212529;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option.selected-correct {
    border-color: #28a745;
    background: #d4edda;
    color: #155724;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option.selected-wrong {
    border-color: #dc3545;
    background: #f8d7da;
    color: #721c24;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option.reveal-correct {
    border-color: #28a745;
    background: #d4edda;
    color: #155724;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #dee2e6;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option.selected-correct .chatbot-quiz-letter {
    background: #28a745;
    color: #fff;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option.selected-wrong .chatbot-quiz-letter {
    background: #dc3545;
    color: #fff;
}

.chatbot-progressive-question-wrapper .chatbot-quiz-option.reveal-correct .chatbot-quiz-letter {
    background: #28a745;
    color: #fff;
}

/* Progressive flashcard (single card, centered) */
.chatbot-progressive-flashcard {
    display: flex;
    justify-content: center;
    margin: 8px 0;
}

.chatbot-progressive-flashcard .chatbot-flashcard {
    width: 100%;
    max-width: 500px;
    min-height: 280px;
    perspective: 600px;
    cursor: pointer;
}

.chatbot-progressive-flashcard .chatbot-flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 280px;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

.chatbot-progressive-flashcard .chatbot-flashcard.flipped .chatbot-flashcard-inner {
    transform: rotateY(180deg);
}

.chatbot-progressive-flashcard .chatbot-flashcard-front,
.chatbot-progressive-flashcard .chatbot-flashcard-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 280px;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border-radius: 12px;
    color: #fff;
    text-align: center;
}

.chatbot-progressive-flashcard .chatbot-flashcard-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.chatbot-progressive-flashcard .chatbot-flashcard-back {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    transform: rotateY(180deg);
}

.chatbot-progressive-flashcard .chatbot-flashcard-front p,
.chatbot-progressive-flashcard .chatbot-flashcard-back p {
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.6;
}

.chatbot-progressive-flashcard .chatbot-flashcard-hint {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 8px;
}

/* Flashcard rating buttons */
.chatbot-flashcard-rating {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 10px;
}

.chatbot-flashcard-rating-btn {
    padding: 7px 20px;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 22px;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chatbot-flashcard-rating-btn.known {
    border-color: #28a745;
    color: #28a745;
    background: #fff;
}

.chatbot-flashcard-rating-btn.known:hover {
    background: #28a745;
    color: #fff;
}

.chatbot-flashcard-rating-btn.review {
    border-color: #ffc107;
    color: #856404;
    background: #fff;
}

.chatbot-flashcard-rating-btn.review:hover {
    background: #ffc107;
    color: #212529;
}

/* Streak indicator */
.chatbot-progressive-streak {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #ff6b35;
    animation: chatbot-streak-pop 0.4s ease-out;
}

@keyframes chatbot-streak-pop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.chatbot-progressive-streak-flame {
    font-size: 1rem;
    animation: chatbot-flame-flicker 0.6s ease-in-out infinite alternate;
}

@keyframes chatbot-flame-flicker {
    from { transform: scale(1) rotate(-3deg); }
    to { transform: scale(1.1) rotate(3deg); }
}

/* Score bounce animation */
.chatbot-progressive-score.bounce {
    animation: chatbot-score-bounce 0.4s ease-out;
}

@keyframes chatbot-score-bounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* ========================================
   STICKY FOOTER
   ======================================== */

.chatbot-progressive-footer {
    position: sticky;
    bottom: 0;
    background: #f8f9fa;
    border-top: 2px solid #e9ecef;
    padding: 10px 16px;
    margin: 0 -20px -20px;
    border-radius: 0 0 10px 10px;
    z-index: 10;
}

.chatbot-progressive-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    margin-bottom: 8px;
    overflow: hidden;
}

.chatbot-progressive-bar-fill {
    height: 100%;
    background: #007bff;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.chatbot-progressive-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.chatbot-progressive-progress {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
}

.chatbot-progressive-score {
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s ease;
}

.chatbot-progressive-score.good { color: #28a745; }
.chatbot-progressive-score.medium { color: #ffc107; }
.chatbot-progressive-score.poor { color: #dc3545; }

.chatbot-progressive-end-btn {
    padding: 4px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid #6c757d;
    border-radius: 14px;
    background: #fff;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chatbot-progressive-end-btn:hover {
    background: #6c757d;
    color: #fff;
}

/* Revision basket */
.chatbot-revision-basket {
    width: 100%;
    margin-top: 6px;
    border-top: 1px solid #e9ecef;
    padding-top: 6px;
}

.chatbot-revision-basket-toggle {
    background: none;
    border: none;
    color: #007bff;
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chatbot-revision-basket-toggle:hover {
    text-decoration: underline;
}

.chatbot-revision-basket-arrow {
    transition: transform 0.2s ease;
    font-size: 0.65rem;
}

.chatbot-revision-basket-arrow.expanded {
    transform: rotate(180deg);
}

.chatbot-revision-basket-list {
    padding: 6px 0 0 18px;
    margin: 0;
    font-size: 0.78rem;
    max-height: 100px;
    overflow-y: auto;
    list-style: disc;
}

.chatbot-revision-basket-list li {
    margin-bottom: 3px;
    color: #495057;
}

.chatbot-revision-basket-list li a {
    color: #007bff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.chatbot-revision-basket-list li a:hover {
    text-decoration: underline;
    color: #0056b3;
}

.chatbot-revision-basket-list li a::after {
    content: "\2197";
    font-size: 0.7rem;
    opacity: 0.6;
}

.chatbot-revision-basket-list li a:hover::after {
    opacity: 1;
}

.chatbot-revision-basket-list li.removing {
    animation: chatbot-basket-remove 0.3s ease-out forwards;
}

@keyframes chatbot-basket-remove {
    from { opacity: 1; max-height: 30px; }
    to { opacity: 0; max-height: 0; padding: 0; margin: 0; }
}

.chatbot-revision-basket-list li.adding {
    animation: chatbot-basket-add 0.3s ease-out;
}

@keyframes chatbot-basket-add {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Progressive loading state */
.chatbot-progressive-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    gap: 12px;
    color: #6c757d;
}

.chatbot-progressive-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e9ecef;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: chatbot-spin 0.8s linear infinite;
}

@keyframes chatbot-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.chatbot-progressive-loading-text {
    font-size: 0.85rem;
}

/* Summary panel at end of session */
.chatbot-progressive-summary {
    padding: 10px;
}

.chatbot-progressive-summary-score {
    text-align: center;
    padding: 20px 0;
}

.chatbot-progressive-summary-pct {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.chatbot-progressive-summary-pct.excellent { color: #28a745; }
.chatbot-progressive-summary-pct.good { color: #17a2b8; }
.chatbot-progressive-summary-pct.decent { color: #ffc107; }
.chatbot-progressive-summary-pct.weak { color: #dc3545; }

.chatbot-progressive-summary-label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 4px;
}

.chatbot-progressive-summary-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 16px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.82rem;
}

.chatbot-progressive-summary-stat {
    text-align: center;
}

.chatbot-progressive-summary-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    display: block;
}

.chatbot-progressive-summary-stat-label {
    color: #6c757d;
    font-size: 0.75rem;
}

.chatbot-progressive-summary-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    margin: 12px 0;
    overflow: hidden;
}

.chatbot-progressive-summary-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease;
}

.chatbot-progressive-summary-advice {
    padding: 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin: 12px 0;
    border-left: 4px solid;
}

.chatbot-progressive-summary-advice.excellent {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.chatbot-progressive-summary-advice.good {
    background: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

.chatbot-progressive-summary-advice.decent {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.chatbot-progressive-summary-advice.weak {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

/* Responsive for progressive mode */
@media (max-width: 600px) {
    .chatbot-progressive-footer {
        margin: 0 -15px -15px;
        padding: 8px 12px;
    }

    .chatbot-progressive-footer-row {
        font-size: 0.75rem;
    }

    .chatbot-progressive-flashcard .chatbot-flashcard {
        max-width: 100%;
        min-height: 220px;
    }

    .chatbot-progressive-flashcard .chatbot-flashcard-inner {
        min-height: 220px;
    }

    .chatbot-progressive-flashcard .chatbot-flashcard-front,
    .chatbot-progressive-flashcard .chatbot-flashcard-back {
        min-height: 220px;
        padding: 20px;
    }

    .chatbot-flashcard-rating {
        gap: 8px;
    }

    .chatbot-flashcard-rating-btn {
        padding: 6px 16px;
        font-size: 0.78rem;
    }

    .chatbot-progressive-summary-stats {
        flex-direction: column;
        gap: 10px;
    }
}