/* ═══ Efestus Design System ═══ */

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

:root {
  --bg-base: #0c0c10;
  --bg-surface: #131318;
  --bg-elevated: #1a1a22;
  --bg-hover: #22222e;
  --bg-active: #2a2a38;
  --bg-input: #16161e;

  --border: #252530;
  --border-hover: #3a3a4a;
  --border-focus: #d4a017;

  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-tertiary: #55556a;
  --text-inverse: #0c0c10;

  --accent: #d4a017;
  --accent-hover: #e8b82a;
  --accent-dim: rgba(212, 160, 23, 0.1);
  --accent-glow: rgba(212, 160, 23, 0.06);

  --red: #e05555;
  --red-dim: rgba(224, 85, 85, 0.1);
  --green: #22c07a;
  --green-dim: rgba(34, 192, 122, 0.1);
  --blue: #5588ee;
  --blue-dim: rgba(85, 136, 238, 0.1);
  --orange: #e89030;

  --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --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);

  --transition: 150ms ease;
  --sidebar-width: 272px;
}

body {
  font-family: var(--font-mono);
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--text-inverse); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ═══ Layout ═══ */

#app {
  display: flex;
  height: 100vh;
  background: var(--bg-base);
}

/* ═══ Sidebar ═══ */

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo h1 {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.version {
  display: block;
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-top: 1px;
}

/* Nav Buttons */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: left;
  transition: all var(--transition);
  width: 100%;
}

.nav-btn svg { opacity: 0.5; flex-shrink: 0; transition: opacity var(--transition); }
.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn:hover svg { opacity: 0.8; }
.nav-btn.active { background: var(--accent-dim); color: var(--accent); }
.nav-btn.active svg { opacity: 1; color: var(--accent); }

/* Divider */

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 16px;
}

/* Sections */

.sidebar-section {
  padding: 0 10px;
  margin-bottom: 12px;
}

.section-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-tertiary);
  padding: 0 6px;
  margin-bottom: 6px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding: 0 6px;
}

/* Select */

.select-wrapper {
  position: relative;
}

.select-wrapper select {
  width: 100%;
  padding: 8px 30px 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  transition: border-color var(--transition);
}

.select-wrapper select:hover { border-color: var(--border-hover); }
.select-wrapper select:focus { outline: none; border-color: var(--border-focus); }

.select-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

/* Conversations */

.conversations-section { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.conversations-section .section-header { flex-shrink: 0; }

#conversations-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0 2px;
}

#conversations-list li {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition);
}

#conversations-list li:hover { background: var(--bg-hover); color: var(--text-primary); }
#conversations-list li.active { background: var(--accent-dim); color: var(--accent); }

/* Icon Button */

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* Footer */

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  transition: background var(--transition);
}

.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 6px rgba(34, 192, 122, 0.4);
}

.provider-info {
  font-size: 10px;
  color: var(--text-tertiary);
}

/* ═══ Main Content ═══ */

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

.panel { display: none; flex-direction: column; height: 100%; }
.panel.active { display: flex; }

/* ═══ Panel Topbar ═══ */

.panel-topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  min-height: 56px;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.topbar-left h2 { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.topbar-subtitle { font-size: 12px; color: var(--text-tertiary); }
.topbar-badges { display: flex; gap: 6px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* Badges */

.badge {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.badge:empty { display: none; }

.badge-model { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }
.badge-task { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ═══ Chat Panel ═══ */

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: var(--text-tertiary);
  text-align: center;
}

.empty-state p { font-size: 14px; color: var(--text-secondary); }
.empty-state .empty-hint { font-size: 11px; max-width: 320px; line-height: 1.6; }
.empty-state.small { padding: 24px 12px; height: auto; }
.empty-state.small p { font-size: 12px; }

/* Messages */

.message {
  max-width: 72%;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: fadeIn 200ms ease;
}

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

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
  font-family: var(--font-sans);
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
  color: var(--text-primary);
}

.message code {
  font-family: var(--font-mono);
  background: rgba(255,255,255,0.07);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.message.assistant .typing-cursor::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 800ms infinite;
  vertical-align: text-bottom;
}

@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* Chat Input */

#chat-input-area {
  padding: 16px 24px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#chat-input {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  resize: none;
  max-height: 160px;
  line-height: 1.5;
}

#chat-input::placeholder { color: var(--text-tertiary); }
#chat-input:focus { outline: none; }

#send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-inverse);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

#send-btn:hover { background: var(--accent-hover); transform: scale(1.04); }
#send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
#send-btn:active { transform: scale(0.96); }

.input-footer {
  padding: 6px 4px 0;
  display: flex;
  justify-content: space-between;
}

.input-hint { font-size: 10px; color: var(--text-tertiary); }

.input-footer { align-items: center; }

.model-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

.select-wrapper.compact select {
  padding: 4px 24px 4px 8px;
  font-size: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

#chat-model-input {
  padding: 4px 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  width: 200px;
}

#chat-model-input:focus { outline: none; border-color: var(--border-focus); color: var(--accent); }

/* ═══ Brain Panel ═══ */

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  transition: border-color var(--transition);
  color: var(--text-tertiary);
}

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

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  width: 160px;
}

.search-box input::placeholder { color: var(--text-tertiary); }
.search-box input:focus { outline: none; }

#brain-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.brain-sidebar {
  width: 240px;
  min-width: 240px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-surface);
}

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

.doc-item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--text-tertiary);
  flex-shrink: 0;
  transition: background var(--transition);
}

.doc-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.doc-item.active { background: var(--accent-dim); color: var(--accent); }
.doc-item.active::before { background: var(--accent); }

.brain-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  gap: 12px;
  background: var(--bg-base);
}

.editor-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-top input {
  flex: 1;
}

.editor-meta {
  display: flex;
  gap: 6px;
}

.meta-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
}

#doc-title {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  transition: border-color var(--transition);
}

#doc-title:focus { outline: none; border-color: var(--border-focus); }

#doc-content {
  flex: 1;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  transition: border-color var(--transition);
}

#doc-content:focus { outline: none; border-color: var(--border-focus); }

.editor-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

/* ═══ Tasks Panel ═══ */

#tasks-content {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  overflow-x: auto;
}

.task-column {
  flex: 1;
  min-width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.column-header h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 600;
  flex: 1;
}

.column-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-todo { background: var(--text-tertiary); }
.dot-doing { background: var(--orange); box-shadow: 0 0 6px rgba(232, 144, 48, 0.3); }
.dot-done { background: var(--green); box-shadow: 0 0 6px rgba(34, 192, 122, 0.3); }

.column-count {
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  padding: 2px 7px;
  border-radius: 10px;
}

.task-column ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.task-item {
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}

.task-item:hover { border-color: var(--border-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.task-item .task-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.task-item .task-priority {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-item .task-priority::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.task-item .task-priority.high::before { background: var(--red); }
.task-item .task-priority.medium::before { background: var(--orange); }
.task-item .task-priority.low::before { background: var(--green); }

/* ═══ Buttons ═══ */

.btn-accent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-inverse);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-accent:hover { background: var(--accent-hover); }
.btn-accent:active { transform: scale(0.97); }

.btn-ghost {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

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

.btn-danger { border-color: transparent; color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: var(--red-dim); color: var(--red); }

/* ═══ Settings Panel ═══ */

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 640px;
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.settings-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  margin-bottom: 14px;
}

.settings-row:last-child { margin-bottom: 0; }

.settings-row label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.settings-row input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  transition: border-color var(--transition);
}

.settings-row input:focus { outline: none; border-color: var(--border-focus); }
.settings-row input::placeholder { color: var(--text-tertiary); }

.apikey-input {
  display: flex;
  gap: 6px;
  align-items: center;
}

.apikey-input input { flex: 1; }

.settings-actions {
  display: flex;
  gap: 8px;
}

.settings-actions .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.settings-result {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  line-height: 1.5;
  display: none;
}

.settings-result.show { display: block; }
.settings-result.ok { background: var(--green-dim); border: 1px solid var(--green); color: var(--green); }
.settings-result.error { background: var(--red-dim); border: 1px solid var(--red); color: var(--red); }

#models-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

#models-list li {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

#models-list li:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
