/* QuantiaMagica IDE - VS Code Dark Theme */

:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d2d;
    --bg-hover: #37373d;
    --bg-active: #094771;
    --border-color: #3c3c3c;
    --text-primary: #cccccc;
    --text-secondary: #9d9d9d;
    --text-muted: #6d6d6d;
    --accent-blue: #0078d4;
    --accent-green: #4ec9b0;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --sidebar-width: 260px;
    --toolbar-height: 40px;
    --statusbar-height: 24px;
    --tab-height: 35px;
    --terminal-height: 200px;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 顶部工具栏 */
.toolbar {
    height: var(--toolbar-height);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    user-select: none;
    -webkit-app-region: drag;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    background: linear-gradient(135deg, #0078d4, #00b4d8);
    color: white;
    font-weight: bold;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
}

.title {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.toolbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    -webkit-app-region: no-drag;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    -webkit-app-region: no-drag;
}

.tool-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    transition: all 0.15s ease;
}

.tool-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tool-btn.run-btn {
    background: var(--success);
    color: white;
}

.tool-btn.run-btn:hover {
    background: #45a049;
}

.tool-btn.run-btn svg {
    width: 12px;
    height: 12px;
}

.separator {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 8px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 主体区域 */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    min-width: 180px;
    max-width: 400px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.workspace-path {
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-tree {
    flex: 1;
    overflow: auto;
    padding: 4px 0;
}

.file-tree::-webkit-scrollbar {
    width: 10px;
}

.file-tree::-webkit-scrollbar-track {
    background: transparent;
}

.file-tree::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 5px;
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: background 0.1s;
}

.tree-item:hover {
    background: var(--bg-hover);
}

.tree-item.active {
    background: var(--bg-active);
}

.tree-item .icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    flex-shrink: 0;
}

.tree-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-item .arrow {
    width: 16px;
    height: 16px;
    margin-right: 2px;
    transition: transform 0.15s;
    opacity: 0.7;
}

.tree-item .arrow.expanded {
    transform: rotate(90deg);
}

.tree-children {
    display: none;
}

.tree-children.expanded {
    display: block;
}

/* 分隔条 */
.resizer {
    width: 4px;
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s;
}

.resizer:hover,
.resizer.dragging {
    background: var(--accent-blue);
}

.resizer-h {
    height: 4px;
    background: transparent;
    cursor: row-resize;
    transition: background 0.2s;
}

.resizer-h:hover,
.resizer-h.dragging {
    background: var(--accent-blue);
}

/* 编辑器区域 */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 标签栏 */
.tab-bar {
    height: var(--tab-height);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-end;
    overflow-x: auto;
}

.tab-bar::-webkit-scrollbar {
    height: 3px;
}

.tabs {
    display: flex;
    height: 100%;
    align-items: flex-end;
}

.tab {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 180px;
    transition: all 0.15s;
}

.tab:hover {
    background: var(--bg-hover);
}

.tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-top: 2px solid var(--accent-blue);
}

.tab .tab-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab .tab-close {
    width: 18px;
    height: 18px;
    margin-left: 8px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.1s;
}

.tab:hover .tab-close,
.tab.active .tab-close {
    opacity: 0.7;
}

.tab .tab-close:hover {
    opacity: 1;
    background: var(--bg-hover);
}

.tab.modified .tab-name::after {
    content: ' *';
    color: var(--warning);
}

/* 编辑器容器 */
.editor-container {
    flex: 1;
    overflow: hidden;
}

/* 终端面板 */
.terminal-panel {
    height: var(--terminal-height);
    min-height: 100px;
    max-height: 50vh;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.terminal-header {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.terminal-title {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.terminal-content {
    flex: 1;
    overflow: auto;
    padding: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-content::-webkit-scrollbar {
    width: 10px;
}

.terminal-content::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
}

.output-line {
    margin-bottom: 2px;
}

.output-line.error {
    color: var(--error);
}

.output-line.success {
    color: var(--success);
}

.output-line.info {
    color: var(--accent-blue);
}

/* 状态栏 */
.statusbar {
    height: var(--statusbar-height);
    background: var(--accent-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 12px;
}

.status-left,
.status-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.statusbar .separator {
    height: 14px;
    background: rgba(255,255,255,0.3);
    margin: 0 4px;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 450px;
    max-width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 500;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.modal-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.modal-input:focus {
    border-color: var(--accent-blue);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #006cbd;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* 右键菜单 */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 0;
    min-width: 160px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    z-index: 1000;
}

.context-item {
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
}

.context-item:hover {
    background: var(--bg-active);
}

.context-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* 欢迎页面 */
.welcome-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.welcome-logo {
    font-size: 64px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #0078d4, #00b4d8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: bold;
}

.welcome-title {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-subtitle {
    font-size: 14px;
    margin-bottom: 32px;
}

.welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.welcome-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 250px;
}

.welcome-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
}

.welcome-btn svg {
    color: var(--accent-blue);
}

/* 文件图标颜色 */
.icon-python { color: #3572A5; }
.icon-folder { color: #dcb67a; }
.icon-file { color: var(--text-secondary); }
.icon-json { color: #cbcb41; }
.icon-md { color: #519aba; }

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    animation: fadeIn 0.15s ease;
}

/* 滚动条全局样式 */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 选择文本颜色 */
::selection {
    background: var(--accent-blue);
    color: white;
}
