/* NTP Assistant — chat page stylesheet.
 *
 * Design tokens, base rules, the sign-in pane, the sidebar and the drawer
 * come from the shared shell (core/static/core/css/shell.css), loaded before
 * this file. Only what is specific to the chat page lives here. Logical
 * properties handle RTL. */

:root { --panel-w: 340px; }
#app.with-citation { grid-template-columns: var(--sidebar-w) 1fr var(--panel-w); }

/* ===== Sidebar: chat-only parts ===== */
#new-chat {
  width: 100%; margin-block-start: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 12px; font-size: 13.5px; font-weight: 600;
  background: var(--brand); color: var(--brand-contrast);
  border: 0; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .15s;
}
#new-chat:hover { background: var(--brand-strong); }

.list-label {
  padding: 12px 16px 4px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint);
}
#conversation-list { list-style: none; margin: 0; padding: 4px 8px 8px; overflow-y: auto; flex: 1; min-height: 0; }
#conversation-list li {
  position: relative;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .12s, color .12s;
}
#conversation-list li:hover { background: var(--surface-hover); color: var(--text); }
#conversation-list li.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
#conversation-list .conv-del {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; padding: 4px; border-radius: 6px; line-height: 0;
  opacity: 0; transition: opacity .12s, color .12s, background .12s;
}
#conversation-list li:hover .conv-del { opacity: 1; }
#conversation-list .conv-del:hover { color: var(--danger); background: var(--surface); }

/* ===== Chat column ===== */
#messages {
  flex: 1; overflow-y: auto;
  padding: 28px clamp(16px, 6vw, 64px);
  display: flex; flex-direction: column; gap: 22px;
}

.message { display: flex; gap: 12px; max-width: 820px; width: 100%; margin: 0 auto; animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .message { animation: none; } }

.avatar {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-strong), var(--brand));
  box-shadow: var(--shadow-sm); margin-top: 2px;
}
.message.user .avatar { background: linear-gradient(135deg, #475569, #64748b); }
.message.user { flex-direction: row-reverse; }

.bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 15px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.message.user .bubble { background: var(--user-bubble); color: var(--user-text); border-color: transparent; }

.bubble .content { overflow-wrap: anywhere; }
.bubble .content > :first-child { margin-top: 0; }
.bubble .content > :last-child { margin-bottom: 0; }
.bubble .content p { margin: 0 0 10px; }
.bubble .content h1, .bubble .content h2, .bubble .content h3 { margin: 14px 0 8px; font-size: 1.05em; font-weight: 700; }
.bubble .content ul, .bubble .content ol { margin: 0 0 10px; padding-inline-start: 22px; }
.bubble .content li { margin: 3px 0; }
.bubble .content code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px;
}
.message.user .content code { background: rgba(255,255,255,0.18); border-color: transparent; }

.bubble .meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-faint); margin-block-start: 8px; }
.message.user .bubble .meta { color: rgba(255,255,255,0.7); }
.bubble .meta .refused { color: var(--danger); font-weight: 600; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 11px; padding: 2px 4px; border-radius: 5px;
}
.copy-btn:hover { color: var(--brand); background: var(--surface-2); }

/* Citation pills (now real buttons → keyboard accessible) */
.cite-tag {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 16px; padding: 0 4px;
  font-size: 10.5px; font-weight: 600; vertical-align: super; line-height: 1;
  background: var(--brand-soft); color: var(--brand-strong);
  border: 0; border-radius: 5px; cursor: pointer;
  margin-inline-start: 3px; transition: background .12s;
}
.cite-tag:hover { background: var(--brand); color: var(--brand-contrast); }
.message.user .cite-tag { background: rgba(255,255,255,0.22); color: #fff; }

/* Thinking indicator */
.dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); animation: blink 1.2s infinite ease-in-out both; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

/* ===== Welcome / empty state ===== */
#welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px; gap: 6px;
}
#welcome h1 { margin: 14px 0 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
#welcome p { margin: 0; max-width: 440px; color: var(--text-muted); }
.examples { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; max-width: 640px; }
.example {
  text-align: start; padding: 12px 16px; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .12s;
  max-width: 300px;
}
.example:hover { border-color: var(--brand); transform: translateY(-1px); }

/* ===== Composer ===== */
#composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 14px clamp(16px, 6vw, 64px) 4px;
  background: var(--bg);
}
#composer textarea {
  flex: 1; resize: none; max-height: 200px;
  padding: 12px 14px; font-family: inherit; font-size: 14.5px; line-height: 1.5;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
#composer textarea:focus { border-color: var(--brand); outline: none; }
#composer button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 18px; height: 44px; font-size: 14px; font-weight: 600;
  background: var(--brand); color: var(--brand-contrast);
  border: 0; border-radius: var(--radius); cursor: pointer; transition: background .15s;
}
#composer button:hover { background: var(--brand-strong); }
#composer button:disabled { opacity: 0.45; cursor: not-allowed; }
.composer-hint { text-align: center; font-size: 11px; color: var(--text-faint); margin: 6px 0 12px; }

/* ===== Citation panel ===== */
#citation-panel {
  background: var(--surface); border-inline-start: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column;
}
#citation-panel header {
  position: sticky; top: 0; background: var(--surface);
  padding: 14px 18px; border-block-end: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
#citation-panel h3 { margin: 0; font-size: 14px; font-weight: 700; }
#close-citation { background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; }
#close-citation:hover { color: var(--text); }
#citation-body { padding: 18px; font-size: 13.5px; }
#citation-body .doc-title { font-weight: 700; font-size: 14px; margin-block-end: 4px; }
#citation-body .page-ref { color: var(--text-muted); font-size: 12px; margin-block-end: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
#citation-body .page-ref .tag {
  background: var(--brand-soft); color: var(--brand-strong);
  padding: 2px 8px; border-radius: 999px; font-weight: 600;
}
#citation-body .passage {
  background: var(--surface-2); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--brand);
  border-radius: var(--radius-sm); padding: 14px; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text);
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  #app.with-citation { grid-template-columns: 1fr; }

  /* Citation becomes a bottom sheet on small screens */
  #app.with-citation #citation-panel {
    position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 40;
    max-height: 70vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 480px) {
  #composer .send-label { display: none; }
  #composer button { padding: 0 14px; }
}
