/* Chat UI — matches Cobrain landing page design tokens */

/* ── Layout ── */
.chat-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.sidebar-logo svg {
  color: var(--accent);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'DM Sans', system-ui, sans-serif;
  white-space: nowrap;
}

.new-chat-btn:hover {
  background: #b8701f;
}

.sidebar-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 12px 4px;
}

.session-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  margin-bottom: 2px;
}

.session-item:hover {
  background: var(--bg);
}

.session-item.active {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.session-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.session-time {
  font-size: 11px;
  color: var(--fg-faint);
  margin-top: 2px;
  display: block;
}

/* ── Main chat area ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-topbar {
  height: var(--nav-h);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(245,244,240,0.9);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.chat-topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  font-family: 'Syne', sans-serif;
}

.chat-topbar-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}

.badge-dot {
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
}

/* ── Messages ── */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0;
  scroll-behavior: smooth;
}

.messages-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 28px;
}

.message {
  margin-bottom: 28px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
}

.message.user .message-avatar {
  background: var(--fg);
  color: var(--bg);
  order: 2;
}

.message.assistant .message-avatar {
  background: var(--accent);
  color: #fff;
}

.message.user {
  flex-direction: row-reverse;
}

.message-content {
  max-width: 86%;
}

.message.user .message-content {
  text-align: right;
}

.message-bubble {
  display: inline-block;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  text-align: left;
  max-width: 100%;
}

.message.user .message-bubble {
  background: var(--fg);
  color: var(--bg);
  border-radius: 16px 4px 16px 16px;
}

.message.assistant .message-bubble {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* Markdown-style formatting in assistant messages */
.message.assistant .message-bubble strong {
  font-weight: 600;
}

.message.assistant .message-bubble em {
  font-style: italic;
  color: var(--fg-muted);
}

.message-time {
  font-size: 11px;
  color: var(--fg-faint);
  margin-top: 6px;
  padding: 0 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-items: center;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--fg-faint);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 20px;
}

.empty-state h2 {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 10px;
  letter-spacing: -0.03em;
}

.empty-state p {
  font-size: 15px;
  color: var(--fg-muted);
  max-width: 400px;
  line-height: 1.6;
  margin-bottom: 28px;
}

.starter-prompts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 500px;
  width: 100%;
}

.starter-prompt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-size: 13px;
  color: var(--fg);
  font-family: 'DM Sans', system-ui, sans-serif;
}

.starter-prompt:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(201,125,46,0.1);
}

.starter-prompt-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* ── Input area ── */
.chat-input-area {
  padding: 16px 28px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.input-wrapper {
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

.chat-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 56px 14px 18px;
  font-size: 15px;
  color: var(--fg);
  font-family: 'DM Sans', system-ui, sans-serif;
  resize: none;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 52px;
  max-height: 200px;
  line-height: 1.5;
  display: block;
}

.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,125,46,0.12);
}

.chat-input::placeholder {
  color: var(--fg-faint);
}

.send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  color: #fff;
}

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

.send-btn:active {
  transform: scale(0.94);
}

.send-btn:disabled {
  background: var(--fg-faint);
  cursor: not-allowed;
}

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--fg-faint);
  margin-top: 8px;
}

/* ── Mobile toggle ── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg);
  padding: 4px;
}

/* ── Streaming cursor ── */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

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

/* ── Scrollbar ── */
.messages-container::-webkit-scrollbar,
.sidebar-sessions::-webkit-scrollbar { width: 4px; }
.messages-container::-webkit-scrollbar-track,
.sidebar-sessions::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb,
.sidebar-sessions::-webkit-scrollbar-thumb { background: var(--fg-faint); border-radius: 2px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }

  .sidebar-toggle { display: flex; }

  .starter-prompts { grid-template-columns: 1fr; }

  .messages-inner { padding: 0 16px; }

  .chat-input-area { padding: 12px 16px 20px; }

  .chat-topbar { padding: 0 16px; }
}
