/* Base CSS Variables & Styling */
:root {
    --bg-main: #1e1e2e;
    --bg-sidebar: #252538;
    --bg-editor: #181824;
    --fg-text: #cdd6f4;
    --fg-muted: #7f849c;
    --accent-green: #a6e3a1;
    --accent-blue: #89b4fa;
    --accent-red: #f38ba8;
    --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', monospace;
}

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

body {
    background-color: var(--bg-main);
    color: var(--fg-text);
    font-family: var(--font-sans);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar Header */
.toolbar {
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid #313244;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.logo {
    font-family: 'Outfit', var(--font-sans);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 10px;
}

.actions {
    display: flex;
    gap: 12px;
}

.btn {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
}

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

.btn-run {
    background-color: #304f30;
    color: var(--accent-green);
}
.btn-run:hover:not(:disabled) {
    background-color: var(--accent-green);
    color: var(--bg-main);
}

.btn-clear {
    background-color: #45475a;
    color: var(--fg-text);
}
.btn-clear:hover {
    background-color: var(--accent-blue);
    color: var(--bg-main);
}

.btn-help {
    background-color: #45475a;
    color: var(--fg-text);
}
.btn-help:hover {
    background-color: var(--accent-blue);
    color: var(--bg-main);
}

.status {
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.status.loading {
    background-color: rgba(249, 226, 175, 0.1);
    color: #f9e2af;
}
.status.ready {
    background-color: rgba(166, 227, 161, 0.1);
    color: var(--accent-green);
}

/* Main Layout Grid */
.main-container {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* Common Panels styling */
aside, section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #313244;
}

.pane-header {
    background-color: var(--bg-sidebar);
    color: var(--accent-blue);
    padding: 10px 15px;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid #313244;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pane-header.console-header {
    color: var(--accent-green);
}

.pane-header.ai-header {
    color: #cba6f7;
}

/* Sidebar Panels */
.sidebar {
    background-color: var(--bg-sidebar);
    padding: 15px;
    gap: 20px;
}

.section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section h3 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lesson-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 250px;
    padding-right: 4px;
}

.lesson-btn {
    background-color: #313244;
    color: var(--fg-text);
    border: none;
    border-radius: 6px;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.lesson-btn:hover {
    background-color: var(--accent-blue);
    color: var(--bg-main);
}
.lesson-btn.active {
    background-color: var(--accent-blue);
    color: var(--bg-main);
    font-weight: 600;
}

.dictionary-section {
    flex: 1;
}

.dictionary-box {
    background-color: var(--bg-editor);
    border: 1px solid #313244;
    border-radius: 6px;
    padding: 12px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--fg-muted);
    line-height: 1.6;
    overflow-y: auto;
    white-space: pre-wrap;
    flex: 1;
}

.dict-header {
    color: var(--accent-green);
    font-weight: 700;
    margin-top: 10px;
    margin-bottom: 4px;
}
.dict-header:first-child {
    margin-top: 0;
}

/* Code Editor Pane */
.editor-pane {
    background-color: var(--bg-editor);
}

.editor-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Customizing CodeMirror */
.CodeMirror {
    height: 100% !important;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
}

/* Right Pane: Console & AI Preview */
.right-pane {
    border-right: none;
    background-color: var(--bg-main);
}

.console-pane {
    flex: 3;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #313244;
    overflow: hidden;
}

.console-wrapper {
    flex: 1;
    background-color: var(--bg-editor);
    padding: 15px;
    overflow-y: auto;
}

.console-output {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-green);
    white-space: pre-wrap;
    line-height: 1.5;
}

.console-output.error {
    color: var(--accent-red);
}

/* AI Pane */
.ai-pane {
    flex: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-wrapper {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background-color: var(--bg-sidebar);
}

.ai-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--fg-muted);
    text-align: center;
    border: 2px dashed #45475a;
    border-radius: 8px;
    padding: 20px;
    width: 100%;
    flex: 1;
    gap: 10px;
}
.ai-preview-placeholder i {
    font-size: 2.5rem;
}

.ai-preview-img {
    max-width: 100%;
    max-height: 140px;
    border-radius: 6px;
    border: 1px solid #45475a;
    object-fit: contain;
    flex: 1;
}

.ai-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    font-size: 0.85rem;
}

.ai-controls select {
    background-color: #313244;
    color: var(--fg-text);
    border: 1px solid #45475a;
    border-radius: 4px;
    padding: 4px 8px;
    outline: none;
    flex: 1;
}

/* Modals (Dedicated Pop-up Window for Lessons & Help) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background-color: var(--bg-sidebar);
    border: 1px solid #45475a;
    border-radius: 12px;
    width: 90%;
    max-width: 750px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: modal-anim 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
    background-color: var(--bg-main);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #313244;
}

.modal-header h2 {
    font-family: 'Outfit', var(--font-sans);
    color: var(--accent-blue);
    font-size: 1.3rem;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--fg-muted);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.2s;
}
.modal-close-btn:hover {
    color: var(--accent-red);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    line-height: 1.6;
}

.modal-body h1 {
    font-family: 'Outfit', var(--font-sans);
    color: var(--accent-blue);
    font-size: 1.35rem;
    margin-bottom: 12px;
    border-bottom: 1px solid #313244;
    padding-bottom: 6px;
}

.modal-body h2 {
    font-family: 'Outfit', var(--font-sans);
    color: var(--accent-green);
    font-size: 1.1rem;
    margin-top: 18px;
    margin-bottom: 8px;
}

.modal-body p {
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.modal-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-body li {
    margin-bottom: 6px;
    font-size: 0.95rem;
}

/* Highlighted code snippets in lessons */
.modal-body pre.code-snippet {
    background-color: var(--bg-editor);
    color: var(--accent-blue);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid var(--accent-blue);
    margin: 10px 0;
    overflow-x: auto;
    white-space: pre;
}

/* Lesson Example Box */
.modal-body .lesson-example {
    background-color: rgba(137, 180, 250, 0.05);
    border: 1px solid rgba(137, 180, 250, 0.2);
    border-radius: 6px;
    padding: 15px;
    margin-top: 15px;
}

.modal-footer {
    padding: 15px 25px;
    background-color: var(--bg-main);
    border-top: 1px solid #313244;
    display: flex;
    justify-content: flex-end;
}

/* Help Guide grid */
.help-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background-color: var(--bg-editor);
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 0.9rem;
}
.help-grid div {
    padding: 4px;
    border-bottom: 1px solid #313244;
}
.help-grid div:nth-child(2n) {
    color: var(--accent-green);
}
.help-grid div:nth-child(-n+2) {
    color: var(--accent-blue);
    font-weight: 600;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #313244;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}
