/* ============================================
   Waled Fiesta — Design Tokens
   Same visual family as Waled Claude (near-black/near-white, one accent),
   plus a distinguishing dot color per provider column.
   ============================================ */

:root {
  --accent: #d97a3f;
  --accent-dim: #d97a3f33;

  --claude-color: #d97a3f;
  --openai-color: #74aa9c;
  --gemini-color: #4c8bf5;

  --bg: #0e0e0f;
  --bg-elevated: #161617;
  --bg-hover: #1e1e20;
  --border: #2a2a2d;
  --text: #e8e6e2;
  --text-dim: #8a8884;
  --text-faint: #55534f;
}

[data-theme="light"] {
  --bg: #faf9f7;
  --bg-elevated: #ffffff;
  --bg-hover: #f0eee9;
  --border: #e3e0da;
  --text: #1c1b19;
  --text-dim: #75726c;
  --text-faint: #a8a49c;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: "SF Mono", "JetBrains Mono", "Roboto Mono", monospace; }
button { font-family: inherit; cursor: pointer; }
textarea { font-family: inherit; }

/* ============ Layout ============ */
.app { display: flex; height: 100vh; overflow: hidden; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ============ Sidebar (same pattern as Waled Claude) ============ */
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform 0.25s ease;
}
.sidebar-header { padding: 14px 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.new-chat-btn {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px;
}
.new-chat-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.new-chat-btn .plus { color: var(--accent); font-weight: 600; font-size: 16px; }
.sidebar-close { display: none; background: none; border: none; color: var(--text-dim); font-size: 22px; padding: 0 6px; }

.session-list { flex: 1; overflow-y: auto; padding: 8px; }
.session-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 9px 10px; border-radius: 7px; font-size: 13.5px; color: var(--text-dim);
  cursor: pointer; white-space: nowrap; overflow: hidden; margin-bottom: 2px;
}
.session-item:hover { background: var(--bg-hover); color: var(--text); }
.session-item.active { background: var(--bg-hover); color: var(--text); }
.session-title-text { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.session-providers-mini { display: flex; gap: 3px; flex-shrink: 0; }
.mini-dot { width: 5px; height: 5px; border-radius: 50%; opacity: 0.35; }
.mini-dot.on { opacity: 1; }
.session-delete { opacity: 0; background: none; border: none; color: var(--text-faint); font-size: 15px; padding: 2px 4px; }
.session-item:hover .session-delete { opacity: 1; }
.session-delete:hover { color: var(--accent); }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.brand-mark { font-family: "SF Mono", "JetBrains Mono", monospace; font-size: 10.5px; letter-spacing: 0.12em; color: var(--text-faint); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9; }

/* ============ Topbar ============ */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.menu-btn { display: none; flex-direction: column; gap: 4px; background: none; border: none; padding: 6px; }
.menu-btn span { width: 18px; height: 1.5px; background: var(--text-dim); display: block; }
.session-title { font-size: 13.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--text-dim);
}
.theme-toggle svg { width: 16px; height: 16px; }
.icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: block; }

/* ============ 3-column layout ============ */
.columns {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: flex 0.2s ease, opacity 0.2s ease;
}
.column:last-child { border-right: none; }
.column.off {
  flex: 0;
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
  opacity: 0;
}

.col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border); gap: 8px; flex-shrink: 0;
}
.col-header-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.claude-dot { background: var(--claude-color); }
.openai-dot { background: var(--openai-color); }
.gemini-dot { background: var(--gemini-color); }
.col-name { font-size: 13.5px; font-weight: 600; }

.col-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.col-model-select {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  font-size: 11.5px; padding: 5px 7px; border-radius: 7px;
  font-family: "SF Mono", "JetBrains Mono", monospace; max-width: 120px;
}

.col-toggle { position: relative; display: inline-block; width: 32px; height: 18px; flex-shrink: 0; }
.col-toggle input { opacity: 0; width: 0; height: 0; }
.col-toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 100px; transition: background 0.15s;
}
.col-toggle-slider::before {
  content: ''; position: absolute; height: 14px; width: 14px; left: 2px; bottom: 2px;
  background: var(--text); border-radius: 50%; transition: transform 0.15s;
}
.col-toggle input:checked + .col-toggle-slider { background: var(--accent); }
.col-toggle input:checked + .col-toggle-slider::before { transform: translateX(14px); background: #fff; }

.col-usage {
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 10.5px; color: var(--text-faint);
  padding: 6px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}

.col-messages {
  flex: 1; overflow-y: auto; padding: 14px 14px 24px;
  display: flex; flex-direction: column; gap: 14px;
}

.col-msg { display: flex; flex-direction: column; gap: 4px; }
.col-msg.user { align-items: flex-end; }
.col-msg.assistant { align-items: flex-start; }
.col-msg-bubble {
  padding: 9px 12px; border-radius: 11px; font-size: 13.8px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word; max-width: 92%;
}
.col-msg.user .col-msg-bubble { background: var(--bg-hover); border-radius: 12px 12px 4px 12px; }
.col-msg.assistant .col-msg-bubble { padding-left: 0; max-width: 100%; }
.col-msg.error .col-msg-bubble { color: #ff6b6b; font-size: 12.5px; }

.col-typing { display: flex; gap: 4px; padding: 8px 0; }
.col-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--text-faint); animation: pulse 1.2s infinite ease-in-out; }
.col-typing span:nth-child(2) { animation-delay: 0.2s; }
.col-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.col-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 12.5px; text-align: center; padding: 20px;
}

/* ============ Composer ============ */
.composer { padding: 12px 16px 16px; flex-shrink: 0; }
.attachment-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.attachment-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  padding: 5px 9px; border-radius: 7px; font-size: 12px; color: var(--text-dim);
}
.attachment-chip button { background: none; border: none; color: var(--text-faint); font-size: 13px; padding: 0; }

.composer-form {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 16px;
  padding: 8px 8px 8px 12px; max-width: 900px; margin: 0 auto;
}
.composer-form:focus-within { border-color: var(--accent); }
.attach-btn, .send-btn {
  background: none; border: none; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--text-dim); flex-shrink: 0;
}
.attach-btn svg, .send-btn svg { width: 18px; height: 18px; }
.attach-btn:hover { background: var(--bg-hover); color: var(--text); }
.send-btn { background: var(--accent); color: #fff; }
.send-btn:disabled { background: var(--border); color: var(--text-faint); cursor: not-allowed; }

#messageInput {
  flex: 1; background: none; border: none; outline: none; color: var(--text);
  font-size: 14.5px; resize: none; max-height: 160px; padding: 7px 0; line-height: 1.4;
}
#messageInput::placeholder { color: var(--text-faint); }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 10; height: 100%; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .sidebar-close { display: block; }
  .menu-btn { display: flex; }

  .columns { flex-direction: column; overflow-y: auto; }
  .column { border-right: none; border-bottom: 1px solid var(--border); min-height: 320px; flex: none; }
  .column.off { display: none; min-height: 0; }
  .col-messages { max-height: 50vh; }
}
