/* === Chat Container Styles for my.yodo.im === */


.iframe-container.chat-active .typebot-iframe {
    display: none !important;
}

.iframe-container.chat-active .placeholder {
    display: none !important;
}

.lesson-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
}

/* --- Контейнер сообщений --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* --- Сообщение --- */
.chat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.chat-message.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Учитель - слева */
.chat-teacher {
    align-self: flex-start;
}

/* Ученик - справа */
.chat-student {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* --- Аватар --- */
.message-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    background: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.message-avatar .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-teacher .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.chat-student .message-avatar {
    background: linear-gradient(135deg, #38b2ac 0%, #4fd1c5 100%);
}

/* --- Контент сообщения --- */
.message-content {
    background: #ffffff;
    border-radius: 16px;
    padding: 14px 18px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    max-width: 100%;
}

.chat-teacher .message-content {
    border-bottom-left-radius: 4px;
    border-left: 3px solid #667eea;
}

.chat-student .message-content {
    border-bottom-right-radius: 4px;
    border-right: 3px solid #38b2ac;
    background: #e6fffa;
}

/* --- Кликабельное сообщение ученика (синяя кнопка) --- */
.chat-student-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-student-clickable .message-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-student-clickable .message-role {
    color: #319795;
    margin-bottom: 4px;
}

.chat-student-clickable .message-content {
    background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    padding: 12px 18px;
}

.chat-student-clickable .message-text {
    color: #ffffff;
    font-weight: 500;
}

.chat-student-clickable:hover {
    transform: translateY(-2px);
}

.chat-student-clickable:hover .message-content {
    background: linear-gradient(135deg, #5a67d8 0%, #4c51bf 100%);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.chat-student-clickable:active {
    transform: translateY(0);
}

.chat-student-clickable:active .message-content {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.chat-student-clickable.clicked .message-wrapper {
    display: contents;
}

.chat-student-clickable.clicked .message-content {
    background: #e6fffa;
    border-right: 3px solid #38b2ac;
    box-shadow: none;
    padding: 14px 18px;
}

.chat-student-clickable.clicked .message-role {
    color: #319795;
}

.chat-student-clickable.clicked .message-text {
    color: #2d3748;
    font-weight: normal;
}

/* --- Роль --- */
.message-role {
    font-size: 11px;
    font-weight: 700;
    color: #718096;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-teacher .message-role {
    color: #667eea;
}

.chat-student .message-role {
    color: #319795;
}

/* --- Текст сообщения --- */
.message-text {
    font-size: 15px;
    line-height: 1.7;
    color: #2d3748;
    word-wrap: break-word;
}

.message-text p {
    margin: 0 0 12px 0;
}

.message-text p:last-child {
    margin-bottom: 0;
}

/* --- Блоки кода --- */
.chat-code-wrapper {
    position: relative;
    margin: 14px 0;
}

.code-lang {
    position: absolute;
    top: 8px;
    right: 50px;
    font-size: 10px;
    color: #6c7086;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.chat-code {
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

.chat-code code {
    display: block;
    white-space: pre;
    font-family: inherit;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.code-copy-btn.copied {
    background: #38a169;
    color: white;
}

/* --- Inline code --- */
.inline-code,
code.inline-code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
    color: #d63384;
    white-space: nowrap;
}

/* Dark theme inline code */
.chat-teacher .inline-code,
.chat-teacher code.inline-code {
    background: #2a2a4a;
    color: #f8c8dc;
}

/* --- Blockquotes --- */
.message-text blockquote {
    margin: 10px 0;
    padding: 10px 15px;
    border-left: 4px solid #667eea;
    background: #f1f5f9;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #475569;
}

.message-text blockquote + blockquote {
    margin-top: -5px;
    border-top-right-radius: 0;
}

/* --- Ссылки --- */
.chat-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dashed #667eea;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chat-link:hover {
    color: #764ba2;
    border-bottom-style: solid;
}

.chat-link .link-icon {
    font-size: 12px;
    opacity: 0.7;
}

/* --- Изображения --- */
.chat-image {
    max-width: 100%;
    border-radius: 10px;
    margin: 14px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-image-zoomable {
    cursor: zoom-in;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-image-zoomable:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* --- YouTube видео --- */
.chat-video-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 20px 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9;
}

.chat-video-wrapper.vertical {
    aspect-ratio: 9 / 16;
    max-width: 400px;
    max-height: 80vh;
}

.chat-youtube {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
}

/* Larger video in full-width lesson mode */
.full-width-lesson .chat-video-wrapper {
    max-width: 100%;
}

/* Expand message width when it contains video */
.full-width-lesson .chat-message:has(.chat-video-wrapper) {
    max-width: 100%;
}

/* Fallback for browsers without :has() support - video breaks out of container */
.full-width-lesson .chat-video-wrapper {
    width: calc(100vw - 120px);
    max-width: 1200px;
    margin-left: -20px;
}

.full-width-lesson .chat-video-wrapper.vertical {
    width: auto;
    max-width: 450px;
    margin-left: 0;
}

/* Mobile video styles */
@media (max-width: 768px) {
    .chat-video-wrapper {
        max-width: 100%;
        margin: 15px 0;
        border-radius: 8px;
        min-height: 200px;
    }

    .chat-video-wrapper.vertical {
        max-width: 100%;
        max-height: 70vh;
        min-height: 350px;
    }

    .chat-youtube {
        border-radius: 8px;
    }
}

/* --- Модальное окно для изображений --- */
.chat-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chat-image-modal.visible {
    opacity: 1;
    visibility: visible;
}

.chat-image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.chat-image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.chat-image-modal.visible .chat-image-modal-content {
    transform: scale(1);
}

.chat-image-modal-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.chat-image-modal-caption {
    margin-top: 16px;
    color: #ffffff;
    font-size: 14px;
    text-align: center;
    max-width: 80%;
}

.chat-image-modal-close {
    position: absolute;
    top: -40px;
    right: -10px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Панель управления --- */
.chat-controls {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-interactive-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- Сообщение о завершении урока --- */
.chat-complete-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #38a169 0%, #48bb78 100%);
    color: white;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    animation: completePop 0.4s ease;
}

.chat-complete-message .complete-icon {
    font-size: 24px;
}

@keyframes completePop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* --- Рейтинг урока --- */
.chat-rating-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
    margin-top: 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 16px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
}

.chat-rating-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.rating-title {
    font-size: 18px;
    font-weight: 600;
    color: #92400e;
}

.rating-stars {
    display: flex;
    gap: 8px;
}

.rating-star {
    font-size: 36px;
    color: #d1d5db;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.rating-star:hover {
    transform: scale(1.2);
}

.rating-star.active {
    color: #f59e0b;
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.rating-comment-section {
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.rating-comment {
    width: 100%;
    min-height: 80px;
    padding: 12px 16px;
    border: 2px solid #fcd34d;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    background: #fffbeb;
    transition: border-color 0.2s ease;
}

.rating-comment:focus {
    outline: none;
    border-color: #f59e0b;
}

.rating-comment::placeholder {
    color: #b45309;
    opacity: 0.7;
}

.rating-submit-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

.rating-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.rating-submit-btn:active {
    transform: translateY(0);
}

.rating-thanks {
    font-size: 18px;
    font-weight: 600;
    color: #15803d;
    animation: completePop 0.4s ease;
}

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

/* --- Интерактивные элементы --- */
.chat-interactive {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-interactive.visible {
    opacity: 1;
}

/* --- Кнопки выбора --- */
.chat-option-btn {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    padding: 12px 22px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.25s ease;
}

.chat-option-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.chat-option-btn:active {
    transform: translateY(-1px);
}

/* --- Поле ввода --- */
.chat-input-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 15px;
    transition: all 0.2s ease;
    background: #fff;
}

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

.chat-input.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.chat-submit-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-submit-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* --- Скроллбар чата --- */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* --- Адаптивность для чата --- */
@media (max-width: 768px) {
    .chat-message {
        max-width: 95%;
    }

    .message-avatar {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .chat-messages {
        padding: 14px;
        gap: 12px;
    }

    .message-content {
        padding: 12px 14px;
    }

    .message-text {
        font-size: 14px;
    }

    .chat-code {
        font-size: 12px;
        padding: 12px;
    }

    .chat-option-btn {
        padding: 10px 18px;
        font-size: 13px;
    }

    .chat-controls {
        padding: 12px 14px;
    }

    .chat-next-btn {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        justify-content: center;
    }

    .chat-input {
        padding: 12px 14px;
        font-size: 14px;
    }

    .chat-submit-btn {
        width: 44px;
        height: 44px;
    }

    /* Адаптивные кнопки редактора */
    .panel-header {
        padding: 6px 10px;
    }

    .panel-header > span {
        font-size: 11px;
    }

    .editor-controls {
        gap: 3px;
    }

    .run-button,
    .layout-btn {
        padding: 4px 6px;
        font-size: 11px;
    }

    /* Скрываем текст на кнопках, оставляем только иконки */
    .run-button {
        font-size: 0;
    }

    .run-button::before {
        font-size: 14px;
    }

    #saveButton::before { content: '💾'; }
    #downloadButton::before { content: '📥'; }
    #runButton::before { content: '▶'; }
}

/* --- Контейнер чата в iframe-container --- */
#lessonChatContainer,
#projectChatContainer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: none;
    overflow: hidden;
    background: #f8fafc;
    border-radius: 10px;
}

#lessonChatContainer.active,
#projectChatContainer.active {
    display: flex !important;
    flex-direction: column;
}

/* Hide iframe when chat is active */
.iframe-container.chat-active .typebot-iframe,
.iframe-container.chat-active .placeholder {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    position: absolute !important;
    top: -9999px !important;
}

/* Ensure lesson-chat fills the container */
#lessonChatContainer .lesson-chat,
#projectChatContainer .project-chat {
    flex: 1;
    min-height: 0;
}

/* Ensure inner containers fill the space */
#projectChatContainer .project-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* --- Mobile styles for lesson chat --- */
@media (max-width: 1200px) {
    /* На мобильных контейнер остаётся absolute, заполняя родителя */
    #lessonChatContainer,
    #projectChatContainer {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100%;
        z-index: 20;
    }

    #lessonChatContainer.active,
    #projectChatContainer.active {
        display: flex !important;
        flex-direction: column;
    }

    .lesson-chat,
    .project-chat {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .chat-controls {
        flex-shrink: 0;
    }
}

/* --- Small mobile devices --- */
@media (max-width: 768px) {
    .chat-messages {
        padding: 10px 12px;
        gap: 10px;
    }

    .message-content {
        padding: 10px 12px;
    }

    .message-text {
        font-size: 14px;
        line-height: 1.5;
    }

    .message-text p {
        margin: 0 0 8px 0;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .chat-message {
        gap: 8px;
    }
}


/* ============================================
   FULL-WIDTH LESSON MODE (без редактора кода)
   ============================================ */

.main-layout.full-width-lesson {
    display: block;
}

.main-layout.full-width-lesson .lesson-full-width {
    max-width: 1080px;
    margin: 0 auto;
    width: 100%;
}

.main-layout.full-width-lesson .iframe-container {
    min-height: 80vh;
}

/* Мобильные табы без редактора */
.mobile-tabs.no-editor {
    justify-content: center;
}

.mobile-tabs.no-editor .mobile-tab-btn {
    flex: 0 0 auto;
    min-width: 200px;
}

/* ============================================
   AI HINTS STYLES - подсказки для новичков
   ============================================ */

/* --- AI Dropdown кнопка --- */
.ai-hints-dropdown {
    position: relative;
    display: inline-block;
}

.ai-hints-trigger {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    font-weight: 600;
}

.ai-hints-trigger:hover {
    background: linear-gradient(135deg, #7b8eec 0%, #8b5cb5 100%) !important;
    transform: scale(1.05);
}

.ai-hints-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 8px;
    min-width: 180px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.ai-hints-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(5px);
}

.ai-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.ai-menu-item:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.ai-menu-icon {
    font-size: 18px;
}

.ai-menu-text {
    font-size: 14px;
    font-weight: 500;
    color: #2d3748;
}

/* --- AI Hints Panel --- */
.ai-hints-panel {
    position: fixed;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    width: 380px;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.ai-hints-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* --- AI Panel Header --- */
.ai-hints-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.ai-hints-icon {
    font-size: 24px;
}

.ai-hints-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
}

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

.ai-hints-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- AI Panel Content --- */
.ai-hints-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.ai-hints-placeholder {
    text-align: center;
    color: #718096;
    font-size: 14px;
    line-height: 1.6;
    padding: 20px;
}

/* --- Loading State --- */
.ai-hints-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 30px 20px;
}

.ai-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: ai-spin 1s linear infinite;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

.ai-loading-text {
    color: #667eea;
    font-size: 14px;
    font-weight: 500;
}

/* --- Result State --- */
.ai-hints-result {
    animation: ai-fade-in 0.3s ease;
}

@keyframes ai-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-hints-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 14px;
}

.ai-hints-result.help .ai-hints-type-badge {
    background: linear-gradient(135deg, rgba(246, 173, 85, 0.2) 0%, rgba(237, 137, 54, 0.2) 100%);
    color: #c05621;
}

.ai-hints-result.check .ai-hints-type-badge {
    background: linear-gradient(135deg, rgba(72, 187, 120, 0.2) 0%, rgba(56, 161, 105, 0.2) 100%);
    color: #276749;
}

.ai-hints-result.explain .ai-hints-type-badge {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    color: #553c9a;
}

.ai-hints-text {
    font-size: 14px;
    line-height: 1.8;
    color: #2d3748;
}

.ai-hints-text code {
    background: #f7fafc;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    color: #e53e3e;
}

.ai-hints-text pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
}

.ai-hints-text pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.ai-hints-text strong {
    color: #1a202c;
}

.ai-hints-text em {
    color: #667eea;
}

/* --- Error State --- */
.ai-hints-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 30px 20px;
    text-align: center;
}

.ai-error-icon {
    font-size: 40px;
}

.ai-error-text {
    color: #c53030;
    font-size: 14px;
    line-height: 1.6;
}

/* --- Mobile Responsive --- */
@media (max-width: 1200px) {
    .ai-hints-panel {
        position: fixed;
        bottom: 60px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
    }

    .ai-hints-menu {
        right: auto;
        left: 0;
    }

    /* На мобильных скрываем текст AI, оставляем только иконку */
    .ai-hints-trigger {
        font-size: 0;
        padding: 4px 8px !important;
    }

    .ai-hints-trigger::before {
        content: '🤖';
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .ai-menu-item {
        padding: 10px 12px;
    }

    .ai-menu-text {
        font-size: 13px;
    }

    .ai-hints-content {
        padding: 16px;
    }

    .ai-hints-text {
        font-size: 13px;
    }
}

/* === PROJECT CHAT VIEWER FULL STYLES === */
#projectChatContainer {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
    z-index: 10;
    overflow: hidden;
}

#projectChatContainer.active {
    display: flex;
}

.project-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.project-chat .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
    min-height: 0;
}

.project-chat .chat-input-area {
    flex-shrink: 0;
    padding: 15px 20px;
    background: #16213e;
    border-top: 1px solid #2a2a4a;
}

.project-chat .chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.project-chat .chat-textarea {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #3a3a5a;
    border-radius: 12px;
    background: #1a1a2e;
    color: #fff;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    min-height: 48px;
    max-height: 150px;
    line-height: 1.5;
}

.project-chat .chat-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.project-chat .chat-textarea::placeholder {
    color: #666;
}

.project-chat .chat-send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.project-chat .chat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
}

.project-chat .chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.project-chat .chat-hints {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.project-chat .hint-btn {
    padding: 10px 20px;
    border: 1px solid #3a3a5a;
    border-radius: 20px;
    background: transparent;
    color: #aaa;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.project-chat .hint-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* Project Chat Messages */
.project-chat .chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    max-width: 90%;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
}

.project-chat .chat-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.project-chat .chat-teacher {
    flex-direction: row;
    align-self: flex-start;
}

.project-chat .chat-student {
    flex-direction: row-reverse;
    align-self: flex-end;
    margin-left: auto;
}

.project-chat .message-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.project-chat .message-avatar .avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.project-chat .chat-student .message-avatar {
    background: linear-gradient(135deg, #38b2ac 0%, #4fd1c5 100%);
}

.project-chat .message-content {
    background: #16213e;
    border-radius: 16px;
    padding: 14px 18px;
    color: #e0e0e0;
    line-height: 1.6;
    font-size: 15px;
}

.project-chat .chat-student .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.project-chat .message-role {
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.project-chat .message-text {
    word-wrap: break-word;
}

.project-chat .message-text p {
    margin: 0 0 10px 0;
}

.project-chat .message-text p:last-child {
    margin-bottom: 0;
}

.project-chat .message-text pre {
    background: #0d1117;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.project-chat .message-text code {
    font-family: 'Fira Code', monospace;
    font-size: 13px;
}

/* Secret Box */
.chat-secret {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.secret-box {
    background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
    padding: 24px 36px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(245, 175, 25, 0.3);
    animation: secretPop 0.5s ease-out;
}

@keyframes secretPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.secret-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.secret-label {
    color: rgba(255,255,255,0.9);
    font-size: 14px;
    margin-bottom: 8px;
}

.secret-code {
    font-size: 32px;
    font-weight: bold;
    color: white;
    letter-spacing: 4px;
    font-family: monospace;
    user-select: all;
}

.secret-copy-btn {
    margin-top: 12px;
    background: rgba(255,255,255,0.2);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.secret-copy-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Typing indicator */
.project-chat .typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
}

.project-chat .typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typingDot 1s infinite;
}

.project-chat .typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.project-chat .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* Mobile styles for project chat */
@media (max-width: 768px) {
    .project-chat .chat-messages {
        padding: 15px;
    }
    
    .project-chat .chat-input-area {
        padding: 12px 15px;
    }
    
    .project-chat .chat-textarea {
        font-size: 16px;
        min-height: 44px;
    }
    
    .project-chat .chat-send-btn {
        width: 44px;
        height: 44px;
    }
    
    .project-chat .hint-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .project-chat .chat-message {
        max-width: 95%;
    }
}

/* === FIX: Project chat text colors === */
.project-chat .message-text {
    color: #e0e0e0 !important;
}

.project-chat .message-text p {
    color: #e0e0e0 !important;
}

.project-chat .chat-student .message-text,
.project-chat .chat-student .message-text p {
    color: #fff !important;
}

.project-chat .message-content {
    color: #e0e0e0;
}

.project-chat .chat-teacher .message-content {
    background: #16213e;
    color: #e0e0e0;
}

/* === FIX: Chat container height overflow === */
#lessonChatContainer,
#projectChatContainer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

.lesson-chat,
.project-chat {
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lesson-chat .chat-messages,
.project-chat .chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.iframe-container {
    position: relative;
    overflow: hidden;
}

/* === FIX: Ensure iframe-container constrains chat height === */
.iframe-container {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#lessonChatContainer.active,
#projectChatContainer.active {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden;
}

/* Ensure chat doesn't overflow parent */
.lesson-chat,
.project-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 20px !important;
}

.chat-interactive,
.chat-input-area {
    flex-shrink: 0;
}

/* === FIX: Dynamic header height using CSS custom property === */
:root {
    --header-height: 60px; /* fallback */
}

.main-layout {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#lessonChatContainer.active,
#projectChatContainer.active {
    height: 100% !important;
    max-height: 100% !important;
}

.panel-content {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

.iframe-container {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

/* === FIX: Word wrap for long code lines === */
.message-text pre,
.message-text code,
.chat-code,
.chat-code-wrapper pre,
.chat-code-wrapper code {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

.message-content {
    max-width: 100%;
    overflow-x: hidden;
}

.message-text {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Inline code */
.message-text code:not(pre code),
.inline-code {
    white-space: pre-wrap !important;
    word-break: break-all !important;
}

/* === MOBILE COMPACT STYLES === */
@media (max-width: 768px) {
    /* Компактный header */
    .header {
        padding: 10px 15px !important;
        margin-bottom: 10px !important;
        gap: 8px !important;
    }
    
    .header h1 {
        font-size: 1.1rem !important;
        display: none; /* Скрываем на маленьких экранах */
    }
    
    .lesson-info {
        font-size: 0.85rem !important;
    }
    
    /* Компактные табы */
    .mobile-tabs {
        padding: 5px !important;
        margin-bottom: 10px !important;
        gap: 5px !important;
    }
    
    .mobile-tab-btn {
        padding: 6px 8px !important;
        font-size: 0.8rem !important;
    }
    
    /* Скрываем некоторые кнопки на мобильных */
    #fullscreenBtn {
        display: none !important;
    }
    
    /* Компактный container */
    .container {
        padding: 10px !important;
    }
    
    /* Panel content без лишних отступов */
    .panel-content {
        padding: 10px !important;
        border-radius: 10px !important;
    }
    
    /* iframe-container занимает всё доступное место */
    .iframe-container {
        min-height: calc(100vh - 180px) !important;
    }
}

/* Ещё меньше экраны */
@media (max-width: 480px) {
    .header {
        padding: 8px 10px !important;
    }
    
    .container {
        padding: 5px !important;
    }
    
    .panel-content {
        padding: 8px !important;
    }
}

/* Компактная кнопка "Мои курсы" на мобильных */
@media (max-width: 768px) {
    .btn-back {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }
}

@media (max-width: 480px) {
    .btn-back {
        padding: 5px 8px !important;
        font-size: 0.75rem !important;
    }
}

/* === DESKTOP COMPACT HEADER === */
.header {
    padding: 10px 20px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 0 10px !important;
    row-gap: 0 !important;
}

/* Первая строка: название курса + кнопки справа */
.header h1 {
    font-size: 1rem !important;
    font-weight: 700 !important;
    flex-grow: 1 !important;
    margin: 0 !important;
}

/* Кнопки на одной линии с h1 */
.header .btn-back,
.header .btn-certificate {
    order: 0;
}

/* Скрываем селектор языка на my.yodo.im */
.header .language-selector {
    display: none !important;
}

/* Название урока - на второй строке, на всю ширину */
.header .lesson-info {
    width: 100%;
    order: 10;
    margin: 0;
    font-size: 1rem;
}

/* === УБИРАЕМ ПУСТОЕ ПРОСТРАНСТВО СНИЗУ === */
.container {
    padding-bottom: 5px !important;
}

.panel-content {
    padding-bottom: 5px !important;
}

.iframe-container {
    min-height: auto !important;
}

/* На мобильных - максимально используем экран */
@media (max-width: 768px) {
    .container {
        padding: 5px !important;
    }
    
    .panel-content {
        padding: 5px !important;
    }
    
    .iframe-container {
        min-height: auto !important;
        flex: 1 !important;
    }
}

/* === FIX: Убираем пустое пространство под чатом === */
.panel-content {
    padding: 10px 10px 0 10px !important;
    margin-bottom: 0 !important;
}

.container {
    padding: 10px 10px 0 10px !important;
}

.main-layout {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

#lesson-viewer-panel {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

.iframe-container {
    margin-bottom: 0 !important;
}

#lessonChatContainer,
#projectChatContainer {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

.lesson-chat,
.project-chat {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* === FORCE CHAT TO FILL AVAILABLE SPACE === */
#lesson-viewer-panel {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
}

#lesson-viewer-panel .iframe-container {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    height: auto !important;
}

#lessonChatContainer.active {
    flex: 1 !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    height: auto !important;
    min-height: 0 !important;
}

#lessonChatContainer.active .lesson-chat {
    flex: 1 !important;
    min-height: 0 !important;
    height: auto !important;
}

#lessonChatContainer.active .chat-messages {
    flex: 1 !important;
    min-height: 0 !important;
}

/* === Скрываем пустой chat-controls === */
.chat-controls:empty,
.chat-controls:has(.chat-interactive-container:empty) {
    display: none !important;
    padding: 0 !important;
}

.chat-interactive-container:empty {
    display: none !important;
}

/* Минимальный padding когда есть контент */
.chat-controls {
    padding: 8px 12px !important;
}

/* === Компактная кнопка "Мои курсы" на десктопе === */
.header .btn-back {
    padding: 6px 14px !important;
    font-size: 0.85rem !important;
}

/* === Отступ снизу в чате === */
.chat-messages::after {
    content: "";
    display: block;
    height: 20px;
    flex-shrink: 0;
}

/* === FIX: Project chat same layout as lesson chat === */
#projectChatContainer.active {
    flex: 1 !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    height: auto !important;
    min-height: 0 !important;
}

#projectChatContainer.active .project-chat {
    flex: 1 !important;
    min-height: 0 !important;
    height: auto !important;
}

#projectChatContainer.active .chat-messages {
    flex: 1 !important;
    min-height: 0 !important;
}
