/* style.css — PrimeAI simple chat UI
   Clean ChatGPT-style layout: collapsible sidebar + centered chat column.
   One accent color (PrimeAI orange) used sparingly. English / LTR only. */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --accent: #ff6b35;
  --bg: #212121;
  --bg-sidebar: #171717;
  --bg-elevated: #2f2f2f;
  --bg-user-bubble: #3a3a3a;
  --text: #ececec;
  --text-muted: #9b9b9b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --radius: 18px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --content-width: 720px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, textarea, input { font-family: inherit; }

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- Sidebar ---------- */

.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.new-chat-btn:hover { background: var(--bg-elevated); }
.new-chat-btn .icon { font-size: 1.1rem; color: var(--accent); }

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.history-item {
  background: none;
  border: none;
  color: var(--text-muted);
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.history-item:hover { background: var(--bg-elevated); color: var(--text); }
.history-item.is-active { background: var(--bg-elevated); color: var(--text); }
.history-item .del { opacity: 0; flex-shrink: 0; font-size: 0.8rem; }
.history-item:hover .del { opacity: 1; }

.sidebar-footer {
  font-size: 0.76rem;
  color: var(--text-muted);
  padding: 10px 12px 4px;
}

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

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-overlay.is-open { display: block; }
}

/* ---------- Main chat area ---------- */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--bg-elevated); }

.topbar-title { font-weight: 600; font-size: 1rem; }
.topbar-spacer { flex: 1; }

@media (min-width: 861px) {
  #sidebar-toggle { display: none; }
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
}

.chat-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  color: var(--text-muted);
}
.empty-state h1 {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.empty-state p { margin: 0; font-size: 1rem; }
.empty-state.is-hidden { display: none; }

.messages { display: flex; flex-direction: column; gap: 22px; }

.msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.msg .role-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.msg .bubble {
  font-size: 1.02rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg--user { align-items: flex-end; }
.msg--user .bubble {
  background: var(--bg-user-bubble);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-width: 80%;
}
.msg--user .role-label { display: none; }

.msg--assistant .bubble { color: var(--text); }
.msg--assistant.is-loading .bubble { color: var(--text-muted); }

.msg--error .bubble { color: #ff8a65; }

/* ---------- Composer ---------- */

.composer-wrap {
  flex-shrink: 0;
  padding: 0 20px 18px;
}

.composer {
  max-width: var(--content-width);
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 18px;
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1rem;
  resize: none;
  max-height: 180px;
  padding: 6px 0;
  outline: none;
}
#chat-input::placeholder { color: var(--text-muted); }

.send-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #1a1a1a;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.send-btn:disabled { background: var(--line-strong); color: var(--text-muted); cursor: default; }

.composer-hint {
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin: 10px 0 0;
}

@media (max-width: 600px) {
  .chat-inner { padding: 16px 14px 32px; }
  .composer-wrap { padding: 0 12px 14px; }
  .empty-state h1 { font-size: 1.5rem; }
}
