:root {
  --bg-dark: #ffffff;
  --bg-sidebar: #f3f3f3;
  --bg-activity: #e8e8e8;
  --bg-tab: #ececec;
  --bg-active-tab: #ffffff;
  --text-color: #333333;
  --accent-color: #007acc;
  --border-color: #e0e0e0;
  --hover-bg: #e4e4e4;
  --term-bg: #f8f8f8;
  --term-fg: #222222;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-dark: #1e1e1e;
    --bg-sidebar: #252526;
    --bg-activity: #333333;
    --bg-tab: #2d2d2d;
    --bg-active-tab: #1e1e1e;
    --text-color: #cccccc;
    --accent-color: #007acc;
    --border-color: #3e3e42;
    --hover-bg: #2a2d2e;
    --term-bg: #181818;
    --term-fg: #cccccc;
  }
}

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

body, html {
  height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-color);
  overflow: hidden;
  touch-action: manipulation;
}

.hidden { display: none !important; }

/* Fast Modal Dialogs */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; justify-content: center; align-items: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-sidebar);
  width: 90%; max-width: 480px;
  border-radius: 8px; border: 1px solid var(--border-color);
  padding: 16px;
}

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px;
}

.modal-header button {
  background: none; border: none; color: var(--text-color); font-size: 18px; cursor: pointer;
}

.ext-card {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-dark); padding: 10px; border-radius: 6px;
  margin-bottom: 8px; border: 1px solid var(--border-color);
}

.ext-info h4 { font-size: 13px; margin-bottom: 2px; }
.ext-info p { font-size: 11px; color: #888; }

.ext-toggle-btn {
  background: var(--accent-color); color: white; border: none;
  padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 11px;
}

.ext-toggle-btn.installed { background: #28a745; }

/* Landing Page */
.landing-container {
  position: fixed; inset: 0; background: var(--bg-dark);
  display: flex; justify-content: center; align-items: center;
  z-index: 999; padding: 20px;
}

.landing-content { max-width: 800px; text-align: center; }
.logo-badge { font-size: 50px; color: var(--accent-color); margin-bottom: 15px; }
.landing-content h1 { font-size: 2.5rem; margin-bottom: 10px; color: var(--text-color); }
.landing-content h1 span { color: var(--accent-color); }
.tagline { color: #888; font-size: 1.1rem; margin-bottom: 30px; }

.features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px; margin-bottom: 30px;
}

.feature-card {
  background: var(--bg-sidebar); padding: 15px; border-radius: 8px;
  border: 1px solid var(--border-color); text-align: left;
}

.feature-card i { font-size: 22px; color: var(--accent-color); margin-bottom: 8px; }
.feature-card h3 { font-size: 0.95rem; color: var(--text-color); margin-bottom: 4px; }
.feature-card p { font-size: 0.8rem; color: #888; }

.primary-btn {
  background: var(--accent-color); color: white; border: none;
  padding: 12px 30px; font-size: 1rem; font-weight: bold;
  border-radius: 4px; cursor: pointer;
}

/* Main Layout */
.app-container { display: flex; height: 100vh; width: 100vw; }

.activity-bar {
  width: 48px; background: var(--bg-activity);
  display: flex; flex-direction: column; justify-content: space-between;
  align-items: center; padding: 10px 0;
}

.act-btn {
  background: none; border: none; color: #858585;
  font-size: 20px; margin-bottom: 15px; cursor: pointer;
  width: 100%; height: 40px;
}

.act-btn:hover, .act-btn.active {
  color: var(--text-color); border-left: 2px solid var(--accent-color);
}

/* Sidebar */
.sidebar {
  width: 220px; background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column; user-select: none;
}

.sidebar.collapsed { width: 0 !important; opacity: 0; overflow: hidden; border-right: none; }

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

.explorer-actions button {
  background: none; border: none; color: #a0a0a0;
  cursor: pointer; font-size: 13px; margin-left: 6px;
}

.file-tree { padding-top: 5px; overflow-y: auto; }

.file-item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; font-size: 13px; cursor: pointer;
}

.file-item-row:hover { background: var(--hover-bg); }
.file-item-row.active { background: var(--hover-bg); font-weight: bold; }

.file-info { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.file-actions { display: flex; gap: 8px; }
.file-actions i { color: #888; font-size: 12px; padding: 2px; }
.file-actions i:hover { color: #ff5555; }

/* File Syntax Colors */
.folder-icon { color: #dcb67a; }
.html-icon { color: #e44d26; }
.css-icon { color: #264de4; }
.js-icon { color: #f7df1e; }
.php-icon { color: #787cb5; }
.py-icon { color: #3776ab; }
.go-icon { color: #00add8; }
.md-icon { color: #42a5f5; }

/* Mobile Code Toolbar (Spck Editor Style) */
.mobile-code-bar {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-activity); padding: 4px 6px;
  border-bottom: 1px solid var(--border-color); overflow-x: auto;
}

.mobile-code-bar button {
  background: var(--bg-tab); color: var(--text-color);
  border: 1px solid var(--border-color); padding: 5px 10px;
  border-radius: 4px; font-size: 11px; cursor: pointer; white-space: nowrap;
}

.mobile-code-bar button:active { background: var(--accent-color); color: white; }

/* Workspace */
.workspace { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.editor-section { flex: 2; display: flex; border-bottom: 1px solid var(--border-color); min-height: 0; }
.editor-container { flex: 1; display: flex; flex-direction: column; border-right: 1px solid var(--border-color); }

.tabs-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-sidebar); height: 35px;
}

.tab {
  background: var(--bg-active-tab); padding: 0 12px; height: 100%;
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  border-top: 1px solid var(--accent-color); color: var(--text-color);
}

#close-tab-btn {
  background: none; border: none; color: #888; cursor: pointer;
  font-size: 12px; margin-left: 6px; display: flex; align-items: center;
}

#run-btn {
  background: #0e639c; color: white; border: none;
  padding: 4px 10px; margin-right: 10px; font-size: 12px;
  border-radius: 2px; cursor: pointer;
}

#editor { flex: 1; height: calc(100% - 65px); }

.CodeMirror {
  height: 100% !important; font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 14px; background-color: var(--bg-dark) !important; color: var(--text-color) !important;
}

/* Preview Panel */
.preview-container { flex: 1; display: flex; flex-direction: column; background: #ffffff; transition: all 0.2s ease; }
.preview-container.minimized { flex: 0 0 35px !important; overflow: hidden; }
.preview-container.minimized #preview-frame { display: none; }

.preview-header {
  background: var(--bg-sidebar); color: var(--text-color);
  padding: 8px 12px; font-size: 11px; display: flex;
  justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.preview-controls button { background: none; border: none; color: var(--text-color); cursor: pointer; margin-left: 8px; }
#preview-frame { flex: 1; border: none; width: 100%; height: 100%; background: white; }

/* Terminal */
.terminal-section { flex: 1; background: var(--term-bg); display: flex; flex-direction: column; min-height: 130px; }
.terminal-header {
  background: var(--bg-sidebar); color: var(--text-color);
  padding: 5px 15px; font-size: 11px; font-weight: bold;
  display: flex; justify-content: space-between; border-top: 1px solid var(--border-color);
}
.badge { color: #888; font-weight: normal; }
#terminal { flex: 1; padding: 5px; }

@media (max-width: 768px) {
  .editor-section { flex-direction: column; }
  .preview-container { height: 180px; }
}
