/* ─────────────────────────────────────────────
   Noetarist — Workspace
   Conversation-first interface for Katherine.
   Dark mode. Same palette as board.css.
   ───────────────────────────────────────────── */

/* ── Reset & base ────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0e0e10;
  --bg-raised:   #18181b;
  --bg-card:     #1e1e22;
  --bg-hover:    #26262b;
  --bg-input:    #18181b;
  --border:      #2a2a2f;
  --border-light:#333339;

  --text:        #e4e4e7;
  --text-dim:    #a1a1aa;
  --text-muted:  #71717a;

  --red:         #dc2626;
  --red-dim:     #991b1b;
  --amber:       #d97706;
  --amber-dim:   #92400e;
  --green:       #16a34a;
  --green-dim:   #166534;
  --blue:        #3b82f6;
  --blue-dim:    #1e3a5f;
  --grey:        #52525b;
  --grey-dim:    #3f3f46;

  --radius:      2px;
  --font:        'SF Mono', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --transition:  150ms ease;
}

html { font-size: 14px; height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

h1, h2, h3 { font-weight: 500; letter-spacing: -0.01em; }

/* ── Top bar ─────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  z-index: 100;
}

.topbar-brand {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar-nav {
  display: flex;
  gap: 0.25rem;
}

.topbar-nav a {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}

.topbar-nav a:hover,
.topbar-nav a.active {
  color: var(--text);
  background: var(--bg-raised);
}

.topbar-time {
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover {
  background: #d4d4d8;
  border-color: #d4d4d8;
}

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

.btn-sm { font-size: 0.75rem; padding: 0.25rem 0.5rem; }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Main layout ─────────────────────────── */
.workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Tabs section ────────────────────────── */
.tabs-section {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tabs-bar {
  display: flex;
  gap: 0;
  padding: 0 1.5rem;
}

.tab-btn {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover {
  color: var(--text-dim);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-count {
  font-family: var(--font);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 0.35rem;
}

.tab-panel {
  display: none;
  padding: 0.75rem 1.5rem;
  max-height: 11rem;
  overflow-x: auto;
  overflow-y: auto;
}

.tab-panel.active {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

/* ── Project cards (in tabs) ─────────────── */
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  min-width: 14rem;
  max-width: 18rem;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.project-card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.project-card.selected {
  border-color: var(--blue);
  background: var(--blue-dim);
}

.project-card-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.3rem;
}

.domain-badge {
  font-family: var(--font);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.05rem 0.3rem;
  border-radius: var(--radius);
  background: var(--grey-dim);
  color: var(--text-dim);
}

.project-progress {
  height: 2px;
  background: var(--bg-raised);
  border-radius: 1px;
  overflow: hidden;
}

.project-progress-fill {
  height: 100%;
  background: var(--amber);
  transition: width 300ms ease;
}

.project-card.completed .project-progress-fill {
  background: var(--green);
}

/* ── Idea cards ──────────────────────────── */
.idea-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  min-width: 14rem;
  max-width: 18rem;
  flex-shrink: 0;
}

.idea-card-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.idea-card-actions {
  display: flex;
  gap: 0.35rem;
}

/* ── Chat section ────────────────────────── */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Focus bar — shows selected project */
.chat-focus {
  display: none;
  padding: 0.4rem 1.5rem;
  background: var(--blue-dim);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-dim);
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chat-focus.visible {
  display: flex;
}

.chat-focus-title {
  font-weight: 500;
  color: var(--text);
}

.chat-focus-clear {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius);
}
.chat-focus-clear:hover { color: var(--text); background: var(--bg-hover); }

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Individual messages */
.msg {
  max-width: 75%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-katherine {
  align-self: flex-end;
  background: var(--blue-dim);
  color: var(--text);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.msg-noetarist {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.msg-system {
  align-self: center;
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  text-align: center;
  max-width: 85%;
}

.msg-time {
  font-family: var(--font);
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.msg-katherine .msg-time { text-align: right; }
.msg-noetarist .msg-time { text-align: left; }

/* Typing indicator */
.msg-typing {
  align-self: flex-start;
  padding: 0.5rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: none;
}

.msg-typing.visible { display: flex; gap: 0.3rem; align-items: center; }

.typing-dot {
  width: 5px;
  height: 5px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingPulse 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ── Inline cards in chat ────────────────── */
.msg-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.msg-card-status {
  border-left: 3px solid var(--amber);
}

.msg-card-decision {
  border-left: 3px solid var(--red);
}

.msg-card-decision .card-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.msg-card-dispatch {
  border-left: 3px solid var(--blue);
}

.msg-card-idea {
  border-left: 3px solid var(--green);
}

.msg-card-briefing {
  border-left: 3px solid var(--amber);
  background: var(--amber-dim);
  color: var(--text);
}

/* ── Input bar ───────────────────────────── */
.chat-input-bar {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chat-input-wrap {
  flex: 1;
  position: relative;
}

.chat-textarea {
  width: 100%;
  min-height: 2.5rem;
  max-height: 8rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
}

.chat-textarea:focus {
  outline: none;
  border-color: var(--text-muted);
}

.chat-textarea::placeholder {
  color: var(--text-muted);
}

.input-actions {
  display: flex;
  gap: 0.35rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: 0.9rem;
}

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

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-send {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-send:hover {
  background: #d4d4d8;
}

/* ── History browser ─────────────────────── */
.history-browser {
  display: none;
  padding: 0.5rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  flex-shrink: 0;
}

.history-browser.visible { display: flex; gap: 0.5rem; align-items: center; }

.history-dates {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
}

.history-date-btn {
  font-family: var(--font);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
}
.history-date-btn:hover { color: var(--text); border-color: var(--border-light); }
.history-date-btn.active { color: var(--text); border-color: var(--text); }

/* ── Toast ───────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: var(--text);
  opacity: 1;
  transition: opacity 300ms ease;
}
.toast--success { border-left: 3px solid var(--green); }
.toast--error   { border-left: 3px solid var(--red); }

/* ── Upload modal ────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 32rem;
  padding: 1.5rem;
}

.modal-title {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ── Add Idea modal form ─────────────────── */
.idea-form-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.75rem;
}
.idea-form-input:focus {
  outline: none;
  border-color: var(--text-muted);
}
.idea-form-input::placeholder { color: var(--text-muted); }

.idea-form-textarea {
  width: 100%;
  min-height: 4rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  resize: vertical;
  margin-bottom: 0.75rem;
}
.idea-form-textarea:focus {
  outline: none;
  border-color: var(--text-muted);
}

/* ── Loading ─────────────────────────────── */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ───────────────────────────── */
::-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-light); }

/* ── Utility ─────────────────────────────── */
.hidden { display: none !important; }
.mono { font-family: var(--font); }
.muted { color: var(--text-muted); }

/* ── Risk / status badges ────────────────── */
.risk-badge {
  font-family: var(--font);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.05rem 0.3rem;
  border-radius: var(--radius);
}
.risk-badge--high   { background: var(--red-dim);   color: #fca5a5; }
.risk-badge--medium { background: var(--amber-dim); color: #fcd34d; }
.risk-badge--low    { background: var(--grey-dim);  color: var(--text-dim); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot--running   { background: var(--amber); }
.status-dot--queued    { background: var(--grey); }
.status-dot--completed { background: var(--green); }
.status-dot--attention { background: var(--red); }

/* ── Bold in messages (markdown-lite) ────── */
.msg strong { font-weight: 600; color: var(--text); }

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
  .topbar { padding: 0.5rem 1rem; }
  .topbar-nav { display: none; }
  .tabs-bar { padding: 0 1rem; }
  .tab-panel { padding: 0.5rem 1rem; }
  .chat-messages { padding: 0.75rem 1rem; }
  .chat-input-bar { padding: 0.5rem 1rem; }
  .msg { max-width: 90%; }
  .project-card { min-width: 12rem; }
}
