/* Urboids legal chat (urboids.com/bogota/legalChat). Built on styles.css (colours, type, buttons, top bar, sign-in);
   only what the chat adds is here. Mobile first. */

.chat-hero { padding-bottom: 40px; }
.chat-title { max-width: 22ch; }
.chat-langs { margin: 10px 0 0; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--na); }

/* the question box */
.chat-form { margin-top: 24px; max-width: 680px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); }
.chat-form textarea { width: 100%; min-height: 96px; padding: 8px 6px; border: 0; resize: vertical; background: transparent;
  color: var(--ink); font: 1rem/1.5 var(--sans); }
.chat-form textarea:focus { outline: none; }
.chat-form:focus-within { border-color: var(--moss); }
.chat-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chat-count { font-size: 0.75rem; color: var(--na); }
.chat-send { min-height: 44px; }
.chat-send:disabled, .example:disabled { opacity: 0.5; cursor: not-allowed; }

/* example questions */
.examples { display: grid; gap: 8px; max-width: 680px; margin-top: 18px; }
.example { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
  font: 0.88rem/1.4 var(--sans); text-align: left; cursor: pointer; }
.example::after { content: " →"; color: var(--clay); }
.example:hover:not(:disabled), .example:focus-visible { border-color: var(--moss); }

/* history and conversation */
.chat-section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.chat-h2 { margin: 0; font: 500 1.5rem/1.2 var(--serif); }
.chat-sources { font-size: 0.8rem; color: var(--na); }
.history-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.history-item { display: grid; gap: 2px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.history-item:hover, .history-item:focus-visible, .history-item.is-active { background: color-mix(in srgb, var(--moss) 14%, transparent); }
.history-title { font-size: 0.88rem; line-height: 1.35; overflow-wrap: anywhere; }
.history-date { font-size: 0.7rem; color: var(--na); }

/* ---- R63: the page = history panel on the left + the main column ---- */
.chat-page { display: flex; align-items: flex-start; }
.chat-main { flex: 1 1 auto; min-width: 0; }
.side { flex: 0 0 270px; width: 270px; box-sizing: border-box; position: sticky; top: var(--top-h, 0px); align-self: flex-start;
  height: calc(100vh - var(--top-h, 0px)); overflow-y: auto; padding: 16px 14px; border-right: 1px solid var(--line);
  background: var(--bg-tint); transition: margin-left 0.3s ease; }
.side[hidden] { display: none; }
body.side-closed .side { margin-left: -270px; visibility: hidden; transition: margin-left 0.3s ease, visibility 0s 0.3s; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.side-title { margin: 0; font: 600 0.8rem/1.3 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--moss); }
.side-close { display: none; border: 0; background: none; color: var(--ink-soft); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.side-new { width: 100%; margin-bottom: 12px; }
.side-empty { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.side-toggle { position: sticky; top: calc(var(--top-h, 0px) + 8px); z-index: 5; display: inline-flex; align-items: center; gap: 6px;
  margin: 8px 0 0 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink); font: 600 0.82rem var(--sans); cursor: pointer; }
.side-toggle[hidden] { display: none; }
@media (max-width: 760px) {  /* phone: the panel opens on top of the page */
  .side { position: fixed; left: 0; top: 0; z-index: 40; height: 100vh; box-shadow: 8px 0 30px rgba(0, 0, 0, 0.2); }
  .side-close { display: block; }
}

/* ---- R63: three screens ---- */
.ask-area { max-width: 680px; }
.thread-foot .ask-area { display: flex; flex-direction: column; }
.thread-foot .chat-form { margin-top: 28px; }
.thread-foot .usage { order: 2; }  /* screen 3: the question box first, the limit box under it */
.msg { scroll-margin-top: calc(var(--top-h, 0px) + 12px); }
body[data-screen="2"] .thread-foot { display: none; }
/* screen 2 (while Urboids answers): only the question and the loading bar */
body[data-screen="2"] #chat-view, body[data-screen="2"] #docs, body[data-screen="2"] .footer,
body[data-screen="2"] .side, body[data-screen="2"] .side-toggle, body[data-screen="2"] .chat-section-head { display: none; }
body[data-screen="2"] .chat-thread { display: grid; align-content: center; min-height: 60vh; background: none; }
body[data-screen="2"] .msg-user { justify-self: center; max-width: 100%; }
body[data-screen="2"] .msg-user .msg-meta { display: none; }
body[data-screen="2"] .msg-user .msg-body { padding: 0; border: 0; background: none; color: var(--ink-soft); font-style: italic; text-align: center; }
/* screen 3 (after an answer): the page title and the examples step aside for the conversation */
body[data-screen="3"] #chat-view { display: none; }

.messages { display: grid; gap: 20px; margin: 0; padding: 0; list-style: none; }
.msg { display: grid; gap: 4px; max-width: 100%; }
.msg-user { justify-self: end; max-width: 88%; }
.msg-meta { margin: 0; font-size: 0.68rem; color: var(--na); }
.msg-user .msg-meta { text-align: right; }
.msg-body { padding: 12px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg-user .msg-body { background: var(--moss); border-color: var(--moss); color: var(--bg); }
.msg-body p { margin: 0; }
.msg-wait { width: 100%; }  /* the loading bar (build-loader.css) spans the thread while Urboids answers */

/* the chatbot's markdown, drawn as plain elements */
.md > * + * { margin-top: 10px; }
.md p, .md ul, .md ol { margin: 0; }
.md ul, .md ol { padding-left: 1.3em; }
.md li + li { margin-top: 4px; }
.md-h { margin: 14px 0 0; font: 600 1rem/1.3 var(--sans); }
.md code { padding: 1px 5px; border-radius: 5px; background: var(--bg-tint); font-size: 0.9em; }
.md hr { border: 0; border-top: 1px solid var(--line); }
.md .md-sources { font-size: 0.78rem; line-height: 1.45; color: var(--na); }  /* "Artículos consultados: …" */
.md .md-sources strong { color: inherit; }

.chat-docs { display: grid; gap: 12px; }

/* the survey page (its question cards are in limit-box.css) */
.survey-back { display: inline-block; margin-bottom: 18px; color: var(--moss); font-weight: 600; text-decoration: none; }
.survey-progress { margin: 22px 0 0; font-weight: 600; }
.survey-signin { margin-top: 24px; display: grid; gap: 12px; justify-items: start; }
.survey-signin p { margin: 0; }
@media (min-width: 640px) {
  .examples { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .chat-docs { grid-template-columns: 1fr 2fr; gap: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}
