/* Fikir AI — Cursor / VS Code Dark+ clone */
/* codicons loaded via <link> in chat.php */

:root {
  --activityBar-bg: #181818;
  --sideBar-bg: #252526;
  --editor-bg: #1e1e1e;
  --titleBar-bg: #3c3c3c;
  --statusBar-bg: #007acc;
  --tab-active: #1e1e1e;
  --tab-inactive: #2d2d2d;
  --border: #2b2b2b;
  --border2: #3c3c3c;
  --fg: #cccccc;
  --fg-dim: #858585;
  --fg-bright: #ffffff;
  --hover: #2a2d2e;
  --selection: #04395e;
  --selection-inactive: #37373d;
  --accent: #0078d4;
  --link: #4daafc;
  --input-bg: #3c3c3c;
  --composer-bg: #252526;
  --composer-border: #3c3c3c;
  --badge-bg: rgba(0,120,212,0.15);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Cascadia Code', 'Consolas', monospace;
  --activity-w: 48px;
  --sidebar-w: 260px;
  --chat-w: 400px;
  --title-h: 30px;
  --status-h: 22px;
  --tab-h: 35px;
}

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

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

.workbench {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Title bar ── */
.titlebar {
  height: var(--title-h);
  background: var(--titleBar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  -webkit-app-region: drag;
  user-select: none;
}

.titlebar-menus {
  position: absolute;
  left: 8px;
  display: flex;
  gap: 0;
  -webkit-app-region: no-drag;
  z-index: 200;
}

.menu-wrap { position: relative; }

.menu-item {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--fg);
  cursor: default;
  border-radius: 3px;
  border: none;
  background: transparent;
  font-family: inherit;
}
.menu-item:hover,
.menu-item.open { background: rgba(255,255,255,0.1); }

.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #252526;
  border: 1px solid var(--border2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  padding: 4px 0;
  z-index: 300;
}
.menu-dropdown.open { display: block; }

.menu-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 20px 6px 24px;
  border: none;
  background: none;
  color: var(--fg);
  font-size: 12px;
  font-family: inherit;
  text-align: left;
  cursor: default;
}
.menu-dropdown-item:hover { background: var(--accent); color: #fff; }
.menu-dropdown-item:disabled { opacity: 0.45; pointer-events: none; }
.menu-dropdown-item .shortcut { color: var(--fg-dim); font-size: 11px; margin-left: 24px; }
.menu-dropdown-item:hover .shortcut { color: rgba(255,255,255,0.8); }
.menu-sep { height: 1px; background: var(--border2); margin: 4px 0; }

.titlebar-title {
  font-size: 12px;
  color: var(--fg-dim);
  pointer-events: none;
}

.titlebar-controls {
  position: absolute;
  right: 0;
  display: flex;
  -webkit-app-region: no-drag;
}

.win-btn {
  width: 46px;
  height: var(--title-h);
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 10px;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}
.win-btn:hover { background: rgba(255,255,255,0.08); }
.win-btn.close:hover { background: #e81123; color: #fff; }

/* ── Main body ── */
.workbench-body {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}

/* Activity bar */
.activitybar {
  width: var(--activity-w);
  background: var(--activityBar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.act-item {
  width: var(--activity-w);
  height: 48px;
  border: none;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.act-item .codicon { font-size: 24px; }
.act-item:hover { color: var(--fg-bright); }
.act-item.active { color: var(--fg-bright); }
.act-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--fg-bright);
}

.act-spacer { flex: 1; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sideBar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  min-width: 170px;
  max-width: 500px;
}
.sidebar.hidden { display: none; }

.sidebar-title {
  height: 35px;
  padding: 0 8px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg-dim);
  flex-shrink: 0;
}

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

.icon-btn {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn .codicon { font-size: 16px; }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel { display: none !important; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.panel.active { display: flex !important; }

/* File tree */
.tree-row {
  display: flex;
  align-items: center;
  height: 22px;
  padding-right: 8px;
  cursor: pointer;
  color: var(--fg);
  font-size: 13px;
  white-space: nowrap;
}
.tree-row:hover { background: var(--hover); }
.tree-row.selected { background: var(--selection); color: var(--fg-bright); }

.tree-indent { flex-shrink: 0; }
.tree-twistie {
  width: 16px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--fg-dim);
}
.tree-twistie .codicon { font-size: 14px; }
.tree-icon { width: 16px; display: flex; justify-content: center; flex-shrink: 0; margin-right: 4px; }
.tree-icon .codicon { font-size: 16px; }
.tree-label { overflow: hidden; text-overflow: ellipsis; }

/* Search */
.search-box { padding: 8px 12px; }
.search-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid transparent;
  color: var(--fg);
  padding: 4px 8px;
  font-size: 13px;
  outline: none;
  font-family: var(--font);
}
.search-input:focus { border-color: var(--accent); }
.search-results { padding: 4px 0; }
.search-hit {
  padding: 4px 20px;
  cursor: pointer;
  font-size: 12px;
}
.search-hit:hover { background: var(--hover); }
.search-hit .path { color: var(--fg-dim); font-size: 11px; }
.search-hit .line { color: var(--link); }

/* Editor area */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  background: var(--editor-bg);
}

.tabs-bar {
  height: var(--tab-h);
  background: var(--tab-inactive);
  display: flex;
  overflow-x: auto;
  flex-shrink: 0;
}

.tab {
  height: var(--tab-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: var(--tab-inactive);
  border-right: 1px solid var(--border);
  color: var(--fg-dim);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  min-width: 80px;
  max-width: 200px;
}
.tab.active {
  background: var(--tab-active);
  color: var(--fg-bright);
  border-top: 1px solid var(--accent);
}
.tab .tab-name { overflow: hidden; text-overflow: ellipsis; }
.tab .tab-close {
  opacity: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
}
.tab:hover .tab-close, .tab.active .tab-close { opacity: 0.7; }
.tab .tab-close:hover { background: rgba(255,255,255,0.1); opacity: 1; }

.breadcrumb {
  height: 22px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--fg-dim);
  background: var(--editor-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#monaco-container {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: none;
}
#monaco-container.show { display: block; }

.editor-welcome {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  gap: 12px;
  min-height: 0;
}
.editor-welcome.show { display: flex; }
.editor-welcome h2 { color: var(--fg); font-weight: 400; font-size: 24px; }
.editor-welcome kbd {
  background: var(--input-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  border: 1px solid var(--border2);
}

/* Resize handle */
.resize-v {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
}
.resize-v:hover, .resize-v.dragging { background: var(--accent); }

/* Chat panel (auxiliary bar) */
.auxiliarybar {
  width: var(--chat-w);
  background: var(--editor-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  min-width: 280px;
  max-width: 600px;
}
.auxiliarybar.hidden { display: none; }

.chat-toolbar {
  height: 35px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--sideBar-bg);
}

.chat-toolbar-left { display: flex; align-items: center; gap: 4px; }
.chat-toolbar-title { font-size: 13px; font-weight: 600; color: var(--fg); }

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

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--fg-dim);
  max-width: 280px;
}
.chat-empty .codicon { font-size: 32px; margin-bottom: 12px; opacity: 0.5; }
.chat-empty h3 { color: var(--fg); font-weight: 500; font-size: 16px; margin-bottom: 8px; }
.chat-empty p { font-size: 12px; line-height: 1.6; }

/* Messages */
.msg-block { font-size: 13px; line-height: 1.6; }
.msg-block.user { color: var(--fg-bright); }
.msg-block.user .msg-label {
  font-size: 11px;
  color: var(--fg-dim);
  margin-bottom: 4px;
  font-weight: 600;
}
.msg-block.ai .msg-label {
  font-size: 11px;
  color: var(--link);
  margin-bottom: 6px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-block pre {
  background: #2d2d2d;
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}
.msg-block code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255,255,255,0.06);
  padding: 1px 4px;
  border-radius: 3px;
}
.msg-block pre code { background: none; padding: 0; }
.msg-block p { margin-bottom: 8px; }
.msg-block a { color: var(--link); text-decoration: none; }
.msg-block a:hover { text-decoration: underline; }
.msg-block img.gen { max-width: 100%; border-radius: 6px; margin-top: 8px; }

.ctx-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.ctx-tag {
  font-size: 11px;
  background: var(--badge-bg);
  color: var(--link);
  padding: 2px 8px;
  border-radius: 4px;
}

.sources { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.sources small { color: var(--fg-dim); font-size: 11px; }
.sources a { display: block; font-size: 11px; margin-top: 4px; }

.typing-indicator {
  color: var(--fg-dim);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.typing-dots span {
  animation: blink 1.2s infinite;
  opacity: 0.3;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100%{opacity:.3} 40%{opacity:1} }

/* Composer — Cursor style */
.composer-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--sideBar-bg);
  flex-shrink: 0;
}

.composer-box {
  background: var(--composer-bg);
  border: 1px solid var(--composer-border);
  border-radius: 8px;
  overflow: hidden;
}

.composer-box:focus-within { border-color: var(--accent); }

#chatInput {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--fg-bright);
  padding: 10px 12px 4px;
  font-size: 13px;
  font-family: var(--font);
  resize: none;
  outline: none;
  min-height: 22px;
  max-height: 150px;
  line-height: 1.5;
}
#chatInput::placeholder { color: var(--fg-dim); }

.composer-footer {
  display: flex;
  align-items: center;
  padding: 4px 8px 8px;
  gap: 4px;
}

.composer-btn {
  height: 26px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.composer-btn:hover { background: var(--hover); color: var(--fg); }
.composer-btn .codicon { font-size: 14px; }

.composer-spacer { flex: 1; }

.model-pill {
  font-size: 11px;
  color: var(--fg-dim);
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
}

.send-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--fg-dim);
  color: var(--editor-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.send-circle:hover { background: var(--fg-bright); }
.send-circle:disabled { opacity: 0.35; cursor: not-allowed; }
.send-circle .codicon { font-size: 14px; }

/* History dropdown */
.dropdown-wrap { position: relative; }
.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--sideBar-bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  border: none;
  background: none;
  width: 100%;
  color: var(--fg);
  text-align: left;
}
.dropdown-item:hover { background: var(--hover); }
.dropdown-item.active { background: var(--selection); }
.dropdown-item .time { color: var(--fg-dim); font-size: 10px; flex-shrink: 0; margin-left: 8px; }
.dropdown-item .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* @ context menu */
.ctx-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 12px;
  margin-bottom: 4px;
  background: var(--sideBar-bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  min-width: 200px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.ctx-menu.open { display: block; }
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  border: none;
  background: none;
  width: 100%;
  color: var(--fg);
  text-align: left;
}
.ctx-menu-item:hover { background: var(--hover); }

.attach-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px 8px; }
.attach-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  background: var(--input-bg);
  padding: 2px 8px;
  border-radius: 4px;
}
.attach-chip button { border: none; background: none; color: var(--fg-dim); cursor: pointer; }

/* Status bar */
.statusbar {
  height: var(--status-h);
  background: var(--statusBar-bg);
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
  gap: 0;
}
.status-item {
  padding: 0 8px;
  height: 100%;
  display: flex;
  align-items: center;
  cursor: default;
}
.status-item:hover { background: rgba(255,255,255,0.12); }
.status-spacer { flex: 1; }

/* Drop overlay */
.drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,120,212,0.08);
  border: 2px dashed var(--accent);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--fg-bright);
  pointer-events: none;
}
.drop-overlay.on { display: flex; }

#fileInput { display: none; }

.codicon-modifier-spin {
  animation: codicon-spin 1.2s linear infinite;
}
@keyframes codicon-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.folder-empty { padding: 16px 20px; text-align: center; color: var(--fg-dim); font-size: 12px; }
.open-folder-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; border: none;
  padding: 8px 16px; border-radius: 4px; font-size: 13px;
  cursor: pointer;
}
.open-folder-btn:hover { filter: brightness(1.1); }
#importStatus { font-size: 11px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .auxiliarybar { position: fixed; right: 0; top: var(--title-h); bottom: var(--status-h); z-index: 50; box-shadow: -4px 0 20px rgba(0,0,0,0.5); }
  .sidebar { position: fixed; left: var(--activity-w); top: var(--title-h); bottom: var(--status-h); z-index: 50; box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
}
