/* ПРОСТОЕ БЫСТРОЕ РЕШЕНИЕ ДЛЯ PLACEHOLDER */
@media (max-width: 1200px) {
    .placeholder { display: none !important; }
    #placeholder { display: none !important; }
}

/* General Styling & Variables */
:root {
    --primary-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --upgrade-grad: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    --project-grad: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --completed-bg: #e6fffa;
    --completed-border: #38a169;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f4f8;
    color: #333;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #ffffff;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}

.header h1 {
    flex-grow: 1;
    color: #4a5568;
    font-size: 1.8rem;
}

.lesson-info {
    color: #666;
    font-size: 1rem;
}

.btn-upgrade {
    background: var(--upgrade-grad);
    color: white;
    font-weight: bold;
    text-decoration: none;
    text-align: center;
}
.btn-upgrade:hover {
    box-shadow: 0 4px 15px rgba(253, 160, 133, 0.5);
}

/* NEW STYLE FOR BACK BUTTON */
.btn-back {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
}
.btn-back:hover {
    background: #e2e8f0;
    box-shadow: none;
    transform: translateY(-1px);
}


/* Generic Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; /* Use viewport height for robust centering */
    background: rgba(0, 0, 0, 0.7);
    z-index: 20;
    display: -webkit-flex; /* Safari fix */
    display: flex;
    -webkit-align-items: center; /* Safari fix */
    align-items: center;
    -webkit-justify-content: center; /* Safari fix */
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 15px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    -webkit-flex-shrink: 0; /* Safari fix */
    flex-shrink: 0;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 1.5rem;
}

.modal-content p {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.6;
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 16px;
    text-align: center;
}

.modal-input:focus {
    outline: none;
    border-color: #667eea;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
}

.modal-btn.primary {
    background: var(--primary-grad);
    color: #fff;
}
.modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.modal-btn.secondary {
    background: #e2e8f0;
    color: #4a5568;
}
.modal-btn.secondary:hover {
    background: #cbd5e0;
}

.modal-error {
    color: #e53e3e;
    margin-bottom: 15px;
    font-size: 14px;
    min-height: 20px;
}

/* Secret Code Modal - ИСПРАВЛЕННЫЕ СТИЛИ */
.secret-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 20;
    display: none; /* ВАЖНО: по умолчанию скрыто */
    align-items: center;
    justify-content: center;
}

.secret-modal.active {
    display: flex;
}

.secret-modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 15px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.secret-modal h3 {
    margin-bottom: 15px;
    color: #4a5568;
}

.secret-modal p {
    margin-bottom: 20px;
    color: #666;
}

.secret-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 16px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 2px;
}

.secret-input:focus {
    outline: none;
    border-color: #667eea;
}

.secret-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.secret-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secret-btn.primary {
    background: var(--primary-grad);
    color: #fff;
}

.secret-btn.secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.secret-error {
    color: #e53e3e;
    margin-top: 10px;
    font-size: 14px;
}

/* Syllabus Sidebar & Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 12;
    display: none;
}

.overlay.active {
    display: block;
}

.syllabus-sidebar {
    position: fixed;
    top: 0;
    left: -350px;
    width: 350px;
    height: 100%;
    background: #fff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 15;
    transition: left 0.3s ease-in-out;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.syllabus-sidebar.active {
    left: 0;
}

.syllabus-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.syllabus-sidebar h2 {
    color: #4a5568;
    font-size: 1.3rem;
}

.syllabus-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #4a5568;
}

.search-box {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 1rem;
}

/* Lesson List Styling */
.topic-group {
    margin-bottom: 15px;
}

.topic-header {
    font-size: 1rem;
    color: #4a5568;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.08);
    border-radius: 8px;
    font-weight: 600;
}

.lessons-sublist {
    list-style: none;
    padding-left: 10px;
    border-left: 2px solid #e2e8f0;
}

.lesson-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f7fafc;
    position: relative;
}

.lesson-item:hover {
    background: #e2e8f0;
    transform: translateX(5px);
}

.lesson-item.active {
    background: var(--primary-grad);
    color: #fff;
    border-color: #667eea;
    transform: translateX(10px);
}

.lesson-item.project {
    background: rgba(240, 147, 251, 0.1);
    border-left: 4px solid #f093fb;
}

.lesson-item.project:hover {
    background: rgba(240, 147, 251, 0.2);
}

.lesson-item.project.active {
    background: var(--project-grad);
    border-color: #f093fb;
}

.lesson-item.project::before {
    content: "📋 ";
    margin-right: 5px;
    font-size: 0.9em;
}

.lesson-item.locked {
    opacity: 0.6;
    background: rgba(203, 213, 224, 0.3);
    position: relative;
}

.lesson-item.locked::after {
    content: "🔒";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1em;
}

.lesson-item.completed {
    background-color: var(--completed-bg);
    border-left: 4px solid var(--completed-border);
}

.lesson-item.completed::before {
    content: "✔";
    color: var(--completed-border);
    font-weight: bold;
    margin-right: 10px;
}

.lesson-item.completed.active {
    background: var(--primary-grad);
}

/* Main Layout & Panels */
.main-layout {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.panel-content {
    flex: 1;
    background: #fff;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}

.iframe-container {
    flex: 1;
    background: #fff; /* Match panel background */
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    min-height: 600px;
}

.typebot-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.placeholder {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    background: transparent; /* ИЗМЕНЕНИЕ: Убран серый фон */
    color: #666;
    font-size: 1.2rem;
    text-align: center;
    z-index: 5;
    pointer-events: none; /* Allow clicks to pass through */
}

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

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

/* Controls & Buttons */
.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    background: var(--primary-grad);
    color: #fff;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.menu-button {
    background: none;
    border: 1px solid #ccc;
    font-size: 1rem;
    color: #4a5568;
    font-weight: bold;
}

.menu-button:hover,
.menu-button.active {
    background: var(--primary-grad);
    color: #fff;
    border-color: transparent;
}

.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* Code Editor & Console */
.py-editor-container {
    display: flex;
    flex: 1;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    overflow: hidden;
    background: #282a36;
    min-height: 500px;
}

.editor-panel,
.console-panel,
.html-output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.console-panel,
.html-output-panel {
    border-left: 1px solid #444;
}

.panel-header {
    background: #44475a;
    color: white;
    padding: 12px 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.run-button {
    background: #50fa7b;
    color: #282a36;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.run-button:hover {
    background: #8affa4;
}

.run-button:disabled {
    background: #777;
    cursor: not-allowed;
}

.editor-content {
    flex: 1;
    position: relative;
}

.CodeMirror {
    height: 100% !important;
    font-size: 14px;
}

.console-output {
    flex-grow: 1;
    background: #282a36;
    color: #f8f8f2;
    font-family: 'Monaco', monospace;
    padding: 10px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.console-output .error {
    color: #ff5555;
}

/* Responsive Design */
.mobile-tabs {
    display: none;
    justify-content: space-around;
    background: #fff;
    border-radius: 15px;
    margin-bottom: 20px;
    padding: 10px;
    gap: 10px;
}

.mobile-tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: #e2e8f0;
    color: #4a5568;
    font-weight: 600;
    cursor: pointer;
}

.mobile-tab-btn.active {
    background: var(--primary-grad);
    color: #fff;
}

@media (max-width: 1200px) {
    .main-layout {
        flex-direction: column;
    }
    .mobile-tabs {
        display: flex;
    }
    .panel-content {
        display: none;
    }
    .panel-content.active-panel {
        display: flex;
    }
    .py-editor-container {
        flex-direction: column;
        height: auto;
    }
    .console-panel,
    .html-output-panel {
        display: none !important;
    }
}

/* АГРЕССИВНОЕ ИСПРАВЛЕНИЕ - ПРИНУДИТЕЛЬНОЕ СКРЫТИЕ PLACEHOLDER НА МОБИЛЬНЫХ */
@media (max-width: 1200px) {
    /* Скрываем ВСЕ placeholder на мобильных устройствах */
    .placeholder {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        width: 0 !important;
        position: absolute !important;
        top: -9999px !important;
        left: -9999px !important;
        z-index: -1 !important;
    }
    
    /* Скрываем placeholder во всех возможных панелях */
    #lesson-viewer-panel .placeholder,
    #code-editor-panel .placeholder,
    #console-output-panel .placeholder,
    .panel-content .placeholder,
    .iframe-container .placeholder {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        width: 0 !important;
        position: absolute !important;
        top: -9999px !important;
        left: -9999px !important;
        z-index: -1 !important;
    }
    
    /* Принудительно скрываем элементы с ID placeholder */
    #placeholder {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        width: 0 !important;
        position: absolute !important;
        top: -9999px !important;
        left: -9999px !important;
        z-index: -1 !important;
    }
    
    /* Обеспечиваем корректное отображение контента */
    .iframe-container {
        background: white !important;
        min-height: 400px !important;
        position: relative !important;
        overflow: visible !important;
    }
    
    .typebot-iframe {
        background: white !important;
        min-height: 400px !important;
        z-index: 10 !important;
        position: relative !important;
        display: block !important;
    }
    
    /* Исправления для console output panel */
    #console-output-panel {
        background: white !important;
        min-height: 400px !important;
    }
    
    .console-output {
        min-height: 400px !important;
        background: #282a36 !important;
    }
    
    /* Убираем все возможные серые фоны */
    .panel-content.active-panel {
        background: white !important;
    }

    /* Дополнительная защита для активных панелей */
    #lesson-viewer-panel.active-panel .placeholder,
    #code-editor-panel.active-panel .placeholder,
    #console-output-panel.active-panel .placeholder {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

