/* ============================================================
   CodeForge IDE - Pro Max UI
   ============================================================ */

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

:root {
  --bg-deep: #0a0a0f;
  --bg-primary: #12121a;
  --bg-secondary: #16161e;
  --bg-tertiary: #1e1e2a;
  --bg-elevated: #252532;
  --bg-hover: #2a2a3a;
  --bg-active: #32324a;
  --text-primary: #e4e4ef;
  --text-secondary: #9d9db5;
  --text-muted: #5c5c72;
  --text-dim: #3e3e52;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.12);
  --accent-hover: #a5b4fc;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.12);
  --orange: #fb923c;
  --purple: #c084fc;
  --purple-soft: rgba(192, 132, 252, 0.1);
  --border: rgba(255, 255, 255, 0.06);
  --border-bright: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(129, 140, 248, 0.15);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --transition-fast: 0.12s ease;
  --transition-normal: 0.2s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-corner { background: transparent; }

/* Selection */
::selection {
  background: rgba(129, 140, 248, 0.3);
  color: #fff;
}

/* ---- App Shell ---- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-deep);
}

/* ---- Top Bar ---- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
  position: relative;
  z-index: 100;
}

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

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-bright);
  margin: 0 2px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  user-select: none;
}

.logo svg {
  flex-shrink: 0;
}

.project-name {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 100px;
  max-width: 200px;
  outline: none;
  transition: all var(--transition-fast);
}

.project-name:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}

.btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.15);
}

.btn:active {
  transform: scale(0.97);
}

.btn-icon {
  padding: 6px 8px;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: transparent;
}

.btn-group {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-group .btn {
  border-radius: 0;
  border: none;
}

.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.btn-run {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  font-weight: 600;
  border: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn-run:hover {
  background: linear-gradient(135deg, #047857, #059669);
  color: #fff;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
}

.btn-stop {
  background: var(--bg-elevated);
  color: var(--red);
  border: none;
}

.btn-stop:hover {
  background: var(--red-soft);
  color: var(--red);
}

.lang-select {
  padding: 5px 10px;
  padding-right: 24px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%235c5c72' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all var(--transition-fast);
}

.lang-select:hover {
  border-color: var(--border-bright);
  color: var(--text-primary);
}

.lang-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-ai {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
}

.btn-ai::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.btn-ai:hover {
  background: linear-gradient(135deg, #6d28d9, #9333ea);
  color: #fff;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.35);
}

.btn-ai:hover::before {
  transform: translateX(100%);
}

/* ---- Main Layout ---- */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- Sidebar ---- */
#sidebar {
  width: 230px;
  min-width: 150px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.sidebar-title svg {
  color: var(--text-dim);
}

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

.sidebar-actions button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
}

.sidebar-actions button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

#fileTree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  gap: 8px;
  user-select: none;
  border-left: 2px solid transparent;
}

.file-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.file-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-left-color: var(--accent);
}

.file-item .icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.file-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 400;
}

.file-item.modified .name::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--yellow);
  margin-left: 8px;
  vertical-align: middle;
}

.folder-item {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  gap: 6px;
  user-select: none;
  transition: all var(--transition-fast);
}

.folder-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.folder-item .arrow {
  font-size: 9px;
  width: 12px;
  color: var(--text-dim);
  transition: transform var(--transition-fast);
}

.folder-item.open .arrow {
  transform: rotate(90deg);
}

.folder-children {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  margin-left: 20px;
}

.folder-children.collapsed {
  display: none;
}

/* ---- Resize Handles ---- */
.resize-handle {
  width: 3px;
  cursor: col-resize;
  background: transparent;
  transition: background var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}

.resize-handle::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -2px; right: -2px;
}

.resize-handle:hover, .resize-handle.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.4);
}

.resize-handle-h {
  width: 3px;
  cursor: col-resize;
  background: transparent;
  transition: background var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}

.resize-handle-h::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -2px; right: -2px;
}

.resize-handle-h:hover, .resize-handle-h.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.4);
}

.resize-handle-v {
  height: 3px;
  cursor: row-resize;
  background: transparent;
  transition: background var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}

.resize-handle-v::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -2px; bottom: -2px;
}

.resize-handle-v:hover, .resize-handle-v.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.4);
}

/* ---- Workspace ---- */
#workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---- Editor Tabs ---- */
#editorTabs {
  display: flex;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  height: 38px;
}

#editorTabs::-webkit-scrollbar { height: 0; }

.editor-tab {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 38px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  gap: 8px;
  white-space: nowrap;
  transition: all var(--transition-fast);
  min-width: 0;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  position: relative;
}

.editor-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.editor-tab.active {
  color: var(--text-primary);
  background: var(--bg-primary);
  font-weight: 500;
}

.editor-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 2px 2px 0 0;
}

.editor-tab .tab-close {
  font-size: 14px;
  opacity: 0;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: all var(--transition-fast);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

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

.editor-tab .tab-close:hover {
  opacity: 1;
  background: var(--red-soft);
  color: var(--red);
}

.editor-tab .tab-modified {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.4);
}

/* ---- Panels ---- */
#panels {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#editorPanel {
  flex: 1;
  min-width: 200px;
  overflow: hidden;
  display: flex;
  background: var(--bg-primary);
}

#previewPanel {
  width: 50%;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: #fff;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
}

.preview-bar-left, .preview-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-bar button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.preview-bar button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.preview-url-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 12px 3px 10px;
  flex: 1;
  min-width: 0;
}

.url-icon {
  color: var(--text-dim);
  flex-shrink: 0;
}

.preview-url {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  outline: none;
  min-width: 0;
}

.preview-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.preview-tab {
  font-size: 11px !important;
  font-weight: 500 !important;
  font-family: var(--font-sans) !important;
  padding: 4px 10px !important;
  color: var(--text-muted) !important;
  border-radius: 4px !important;
  display: flex !important;
  align-items: center !important;
  gap: 5px !important;
  transition: all var(--transition-fast) !important;
}

.preview-tab.active {
  color: var(--text-primary) !important;
  background: var(--bg-elevated) !important;
  box-shadow: var(--shadow-sm) !important;
}

#previewFrame {
  flex: 1;
  border: none;
  width: 100%;
  background: #fff;
}

/* ---- Console Panel ---- */
#consolePanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

#consoleOutput {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.console-log { color: var(--text-primary); }
.console-warn { color: var(--yellow); }
.console-error { color: var(--red); }
.console-info { color: var(--accent); }

.console-input-row {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.console-prompt {
  color: var(--accent);
  margin-right: 8px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
}

#consoleInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

#consoleInput::placeholder { color: var(--text-dim); }

/* ---- Terminal ---- */
#terminalPanel {
  height: 180px;
  min-height: 80px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.terminal-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
}

.terminal-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.terminal-bar-left svg {
  color: var(--text-dim);
}

.terminal-bar button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.terminal-bar button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

#terminalOutput {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

.terminal-input-row {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

.terminal-prompt {
  color: var(--green);
  margin-right: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
}

#terminalInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

#terminalInput::placeholder { color: var(--text-dim); }

.term-error { color: var(--red); }
.term-success { color: var(--green); }
.term-info { color: var(--accent); }
.term-warn { color: var(--yellow); }

/* ---- CodeMirror Overrides ---- */
.CodeMirror {
  height: 100% !important;
  font-family: var(--font-mono) !important;
  font-size: 14px;
  background: var(--bg-primary) !important;
  line-height: 1.6;
}

.CodeMirror-gutters {
  background: var(--bg-primary) !important;
  border-right: 1px solid var(--border) !important;
}

.CodeMirror-linenumber {
  color: var(--text-dim) !important;
  padding: 0 8px 0 12px !important;
}

.CodeMirror-cursor {
  border-left: 2px solid var(--accent) !important;
}

.CodeMirror-activeline-background {
  background: rgba(129, 140, 248, 0.04) !important;
}

.CodeMirror-selected {
  background: rgba(129, 140, 248, 0.15) !important;
}

.CodeMirror-focused .CodeMirror-selected {
  background: rgba(129, 140, 248, 0.2) !important;
}

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-xl);
  width: 420px;
  max-width: 90%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: modalSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.modal-title svg {
  color: var(--text-muted);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

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

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.modal-body select, .modal-body input[type="number"] {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast);
}

.modal-body select:focus, .modal-body input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 11px;
  transition: all var(--transition-normal);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-normal);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* ---- Context Menu ---- */
.context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: 4px;
  min-width: 180px;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  animation: contextIn 0.12s ease;
}

@keyframes contextIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.context-item:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.context-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.context-item:hover svg {
  color: var(--accent);
}

.context-danger:hover {
  background: var(--red-soft);
  color: var(--red);
}

.context-danger:hover svg {
  color: var(--red);
}

.context-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* ---- AI Panel ---- */
.ai-panel {
  position: fixed;
  right: 0;
  top: 52px;
  bottom: 0;
  width: 420px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 900;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
  animation: aiPanelIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes aiPanelIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.ai-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(168, 85, 247, 0.04));
}

.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.ai-icon-pulse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  animation: aiPulse 3s ease-in-out infinite;
}

@keyframes aiPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(168, 85, 247, 0); }
}

.ai-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
}

.ai-chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* AI Welcome */
.ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px 20px;
  gap: 12px;
}

.ai-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(168, 85, 247, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.ai-welcome h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.ai-welcome p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
}

.ai-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  width: 100%;
}

.ai-suggestion {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.ai-suggestion:hover {
  background: var(--purple-soft);
  border-color: rgba(192, 132, 252, 0.3);
  color: var(--purple);
  transform: translateY(-1px);
}

/* AI Messages */
.ai-msg {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.6;
  max-width: 92%;
  word-wrap: break-word;
  animation: msgIn 0.2s ease;
}

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

.ai-msg.user {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(168, 85, 247, 0.25);
}

.ai-msg.assistant {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.ai-msg.system {
  background: var(--green-soft);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--green);
  align-self: center;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
  padding: 8px 18px;
}

.ai-msg.error {
  background: var(--red-soft);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--red);
  align-self: center;
  text-align: center;
  font-size: 12px;
  border-radius: 20px;
  padding: 8px 18px;
}

.ai-msg pre {
  background: var(--bg-deep);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin-top: 10px;
  overflow-x: auto;
  font-size: 12px;
  border: 1px solid var(--border);
}

.ai-msg code {
  font-family: var(--font-mono);
}

/* AI Input */
.ai-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.ai-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 14px;
  transition: border-color var(--transition-fast);
}

.ai-input-wrapper:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px var(--purple-soft);
}

.ai-input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  resize: none;
  outline: none;
  padding: 8px 0;
  line-height: 1.5;
}

.ai-input-wrapper textarea::placeholder {
  color: var(--text-dim);
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.ai-send-btn:hover {
  background: linear-gradient(135deg, #6d28d9, #9333ea);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
  transform: scale(1.05);
}

.ai-send-btn:active {
  transform: scale(0.95);
}

.ai-input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 0 2px;
}

.ai-checkbox {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.ai-checkbox input {
  accent-color: #a855f7;
  width: 13px;
  height: 13px;
}

.ai-checkbox span {
  color: var(--text-muted);
}

.ai-hint {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* AI Typing */
.ai-typing {
  display: flex;
  gap: 5px;
  padding: 8px 0;
  align-items: center;
}

.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  animation: aiBounce 1.4s infinite ease-in-out both;
}

.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiBounce {
  0%, 80%, 100% { transform: scale(0.3); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-files-list {
  margin-top: 10px;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ai-files-list .ai-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(129, 140, 248, 0.2);
  border-radius: 20px;
  color: var(--accent);
  font-weight: 500;
  font-size: 11px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  #sidebar { width: 180px; min-width: 120px; }
  .ai-panel { width: 100%; }
  .topbar-center { gap: 6px; }
}

@media (max-width: 600px) {
  #sidebar { display: none; }
  .resize-handle { display: none; }
  #topbar { padding: 0 8px; height: 44px; }
  .topbar-left .topbar-divider,
  .project-name { display: none; }
  .btn-ghost { display: none; }
  .lang-select { display: none; }
}
