/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0e11;
  --bg2: #13151a;
  --bg3: #1a1d25;
  --border: #252830;
  --border2: #2e3240;
  --accent: #7fffb2;
  --accent2: #00e5ff;
  --accent3: #ff6b6b;
  --text: #e8eaf0;
  --text2: #8b909e;
  --text3: #5a5f6e;
  --sidebar-w: 240px;
  --topbar-h: 44px;
  --statusbar-h: 24px;
  --font-ui: 'Syne', sans-serif;
  --font-code: 'JetBrains Mono', monospace;
  --radius: 6px;
  --transition: 0.15s ease;
}

body.light {
  --bg: #f0f1f5;
  --bg2: #ffffff;
  --bg3: #e8eaef;
  --border: #d4d7e0;
  --border2: #bfc3cf;
  --text: #1a1d25;
  --text2: #5a5f6e;
  --text3: #9098a9;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 12px;
  position: relative;
  z-index: 100;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-center {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.logo {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.breadcrumb {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

.tab-bar {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  height: var(--topbar-h);
  align-items: stretch;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 100%;
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all var(--transition);
  border-right: 1px solid var(--border);
  user-select: none;
}
.tab:hover { color: var(--text); background: var(--bg3); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg);
}
.tab-close {
  opacity: 0;
  font-size: 12px;
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1;
  transition: opacity var(--transition);
}
.tab:hover .tab-close, .tab.active .tab-close { opacity: 1; }
.tab-close:hover { background: var(--border2); color: var(--accent3); }

/* ===== BUTTONS ===== */
.icon-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all var(--transition);
  font-family: var(--font-ui);
  line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--border2); background: var(--bg3); }
.icon-btn.sm { font-size: 11px; padding: 3px 7px; }

.btn-run {
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-ui);
  padding: 5px 14px;
  border-radius: var(--radius);
  transition: all var(--transition);
  letter-spacing: 0.5px;
}
.btn-run:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-run:active { transform: translateY(0); }

.btn-cancel {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-ui);
  padding: 5px 14px;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.btn-cancel:hover { color: var(--text); background: var(--bg3); }

/* ===== WORKSPACE ===== */
.workspace {
  display: flex;
  height: calc(100vh - var(--topbar-h) - var(--statusbar-h));
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: 140px;
  max-width: 480px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text3);
}

.sidebar-actions {
  display: flex;
  gap: 4px;
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.empty-state {
  padding: 24px 16px;
  color: var(--text3);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
  font-family: var(--font-code);
}

/* File Tree Items */
.tree-folder, .tree-file {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--text2);
  position: relative;
}
.tree-folder:hover, .tree-file:hover { background: var(--bg3); color: var(--text); }
.tree-file.active { background: var(--bg3); color: var(--accent); }

.tree-indent { padding-left: 22px; }

.tree-icon { font-size: 13px; flex-shrink: 0; }
.tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-arrow {
  font-size: 10px;
  color: var(--text3);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.tree-arrow.open { transform: rotate(90deg); }

.folder-children { display: none; }
.folder-children.open { display: block; }

/* ===== RESIZE HANDLE ===== */
.resize-handle {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background var(--transition);
  position: relative;
  z-index: 10;
}
.resize-handle:hover, .resize-handle.dragging { background: var(--accent); }

/* ===== EDITOR AREA ===== */
.editor-area {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

/* Welcome Screen */
.welcome-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.welcome-content {
  text-align: center;
  animation: fadeIn 0.5s ease;
}

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

.welcome-icon {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 16px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.welcome-content h1 {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 28px;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -1px;
}

.welcome-content p {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.8;
  margin-bottom: 28px;
}

.welcome-shortcuts {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.shortcut {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-code);
}

kbd {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10px;
  font-family: var(--font-code);
  color: var(--text2);
}

/* ===== STATUS BAR ===== */
.statusbar {
  height: var(--statusbar-h);
  background: var(--accent);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 16px;
  font-family: var(--font-code);
  font-size: 11px;
  color: #000;
  font-weight: 500;
}

.status-msg {
  margin-left: auto;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
}
.status-msg.show { opacity: 1; }

body.light .statusbar {
  background: #00c07a;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; animation: fadeIn 0.15s ease; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 24px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-title {
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 14px;
  color: var(--text);
}

.modal-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-code);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}
.modal-input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== CONTEXT MENU ===== */
.context-menu {
  position: fixed;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 2000;
  display: none;
  min-width: 140px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: fadeIn 0.1s ease;
}
.context-menu.show { display: block; }

.ctx-item {
  padding: 7px 12px;
  font-size: 12px;
  font-family: var(--font-code);
  cursor: pointer;
  border-radius: 4px;
  color: var(--text2);
  transition: all var(--transition);
}
.ctx-item:hover { background: var(--bg3); color: var(--text); }
.ctx-item.danger:hover { background: rgba(255,107,107,0.15); color: var(--accent3); }
