/* ============== */
/* === DYNBOT === */
/* ============== */

/* === Base === */
:root {
  /* Bubble / action styling (match your manual-decision-button look) */
  --action-bg: #f5f7ff;
  --action-text: #1c2a4b;
  --action-border: #cfd7ff;
  --action-radius: 14px;
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.08);
  /* --chat-font-size: 1.25rem; */
  --chat-font-size: 1.2rem;

  /* layout helpers (JS updates --input-bar-h dynamically) */
  --input-bar-h: 72px;    /* fallback */
  --scroll-btn-gap: 12px; /* gap above input for the floating button */
}

#chat-container,
#chat-container .message,
#chat-container button,
#chat-container .user-question-bubble,
#chat-container .rag-box,
#chat-container .choices-buttons button,
#chat-container .topic-buttons button {
  font-size: var(--chat-font-size);
}

* { box-sizing: border-box; }

body {
  background: #fff;
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === App Layout === */
#chat-container {
  position: relative;  /* anchor for the floating button */
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;    /* prevent overscroll glow */
}

/* wrapper for scroller (messages) */
#chat-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;       /* critical so the child scroller can shrink */
}

/* === Scrollable chat area === */
#chat-output {
  position: relative;
  overflow-y: auto;
  /* start collapsed; fade/expand when .expanded is added */
  max-height: 0;
  opacity: 0;
  transition: max-height 0.6s ease, opacity 0.6s ease;
  padding: 0 1rem;
  /* keep last lines visible above input bar */
  padding-bottom: calc(var(--input-bar-h) + 24px);
  overflow-anchor: none; 
  overscroll-behavior: auto;
}

#chat-output.expanded {
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  opacity: 1;
  padding-top: 1rem;
}

.reply-spacer { 
  display:block; 
}

/* invisible tail spacer; just reserves height, never blocks clicks */
.reserve-tail {
  opacity: 0;
  pointer-events: none;
  display: block;
}

/* Messages */
.message {
  margin: 1rem 0;
  white-space: pre-wrap;
  line-height: 1.5;
  color: #222;
}
.user { text-align: right; font-weight: bold; }

.assistant { 
  text-align: left;
  font-size: 1.2rem;
}

.assistant p {
  font-size: 1.2rem;
}

/* Info text (optional hint above input) */
.info-text {
  background: #fff;
  color: #555;
  text-align: center;
  margin: 1vh 0 1.5vh;
  border-radius: 0;
  font-size: 1.2rem;
}

/* === Input Bar === */
#input-area {
  background: #fff;
  box-shadow: 0 -1px 5px rgba(0,0,0,0.05);
  z-index: 1;
  padding: 0.75rem 1rem;
}

#input-box {
  display: flex;
  align-items: flex-end;          /* align input & button baseline */
  background: rgb(248,248,248);
  border: 1px solid #ccc;
  border-radius: 0.00001rem;  /* was 1rem */
  padding: 0.5rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

#messageInput {
  flex: 1 1 auto;
  border: none;
  outline: none;
  resize: none;
  min-height: 10vh;
  font-size: 1.05rem;
  background: transparent;
  padding: 0.5rem;
  color: rgb(48,48,48) !important;
  -webkit-text-fill-color: rgb(48,48,48) !important;
}

#send-button-wrapper,
.send-button-wrapper {
  display: flex;
  align-items: flex-end;
  padding-left: 0.5rem;
  padding-bottom: 0.25rem;
}

#sendButton {
  background-color: rgb(63,63,63);
  border: none;
  border-radius: 50%;
  width: 2.5rem; height: 2.5rem;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  padding: 0;
  position: relative;
}
#sendButton:hover { background-color: rgb(163,163,163); }

.send-icon svg {
  width: 22px; height: 22px;
  /* stroke: #fff; fill: none; */
  stroke: #EEBE43; fill: none;
  display: block;
  margin-top: 2px;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  /* border-top-color: #fff; */
  border-top-color:#EEBE43;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Topic & Choices Buttons === */
.topic-buttons {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin: 4vh 4vw 1rem;
  align-items: center; justify-content: center;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}
@media (max-width: 600px) {
  .topic-buttons { justify-content: flex-start; }
}

#topic-buttons.collapsed { max-height: 0; opacity: 0; overflow: hidden; }

.topic-buttons button,
.choices-buttons button {
  background: #020C20;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 0px; /* was 12px */
  cursor: pointer;
  font-weight: bold;
  font-size: 15px;
}
.topic-buttons button:hover,
.choices-buttons button:hover { background: #cfcfcf; }

.choices-buttons {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin: 5vh 1rem 1rem;
  justify-content: center;
}
.choices-buttons button.selected {
  background-color: #8d8d8d !important;
  border: 1px solid #cfcfcf;
}

/* === RAG explanation box (optional) === */
.rag-box {
  /* background-color: #e6f0ff; */
  background-color: #020C20;
  color: #EEBE43;
  padding: 12px;
  border-radius: 0px;  /* was 6px */
  margin-top: 10px;
  line-height: 1.4;
}

/* === User Question Bubble (right-aligned) === */
.user-question-bubble {
  /* background: var(--action-bg); */
  background: #020C20;
  color: white;
  /* color: var(--action-text); */
  border: 1px solid var(--action-border);
  border-radius: 0px;    /* was 18px  */
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  max-width: min(75%, 680px);
  margin: 10px 8px 16px auto;  /* right aligned */
  line-height: 1.35;
  word-wrap: break-word;
}

.user-question-meta {
  font-size: 12px;
  color: #6b7280;
  text-align: right;
  margin: -10px 8px 12px auto;
  max-width: min(75%, 680px);
}

/* === “Scroll to end” floating button (circular, centered) ===
   Lives inside #chat-container (NOT inside the scroller) */
.scroll-to-end {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--input-bar-h) + var(--scroll-btn-gap));
  width: 44px; height: 44px;
  border-radius: 50%;
  display: none; /* toggled by JS */
  align-items: center; justify-content: center;
  /* background: #fff; */
  background-color: rgba(255, 255, 255, 0.5);
  /* backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px); 
  /* border-color: rgba(0, 0, 0, 0.08); */
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 22px rgba(0,0,0,0.14);
  cursor: pointer;
  z-index: 5; /* above input bar */
}

.scroll-to-end svg { 
  width: 22px; 
  height: 22px;
  margin-top: 4px;
  /* transform: translateY(2px); */
}
.scroll-to-end:hover { filter: brightness(0.98); }
.scroll-to-end:focus { outline: 2px solid #c7d2fe; outline-offset: 2px; }

/* === Intro / Restart === */
#intro-wrapper {
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}
#intro-wrapper.collapsed { max-height: 0; opacity: 0; }

#restart-area {
  text-align: center;
  padding: 1rem 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#restart-area.visible { opacity: 1; }

#restartButton {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: bold;
  background-color: #e1e1e1;
  color: #fff;
  border: none;
  border-radius: 0.00001rem;    /*  was 1.5rem   */
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,0.1);
  transition: background-color 0.2s ease;
}
#restartButton:hover { background-color: #adadad; }

/* === Optional: unify manual decision button look with bubbles === */
/*
.manual-decision-button {
  background: var(--action-bg);
  color: var(--action-text);
  border: 1px solid var(--action-border);
  border-radius: var(--action-radius);
}  */

/* Instructions copy tidy */
#instructions {
  font-size: 1.2rem;
  color: #020C20;
  font-weight: 700;
  margin-top: 50px;
  margin-bottom: 10px;
  margin-left: 0;
  margin-right: 0;
  padding: 0 10px;
  text-align: center;
  transition: opacity 1s ease;
}
#instructions.fade { opacity: 0; }

/* Start state: input directly below intro-wrapper */
#chat-container.start-mode #input-area {
  position: static;   /* flow directly after intro-wrapper */
  box-shadow: none;   /* optional: remove bottom bar look */
  margin: 1rem 0;     /* small spacing below topic buttons */
}

/* After first send (normal mode) */
#chat-container:not(.start-mode) #input-area {
  position: sticky;
  bottom: 0;
  width: 100%;
}

/* Start state: show input directly below intro; hide scroller */
#chat-container.start-mode #chat-wrapper {
  display: none;          /* prevents the middle flex child from taking space */
}

#chat-container.start-mode #input-area {
  position: static;       /* flow under intro-wrapper */
  box-shadow: none;       /* optional: less "bar" look at start */
  margin: 0.75rem 1rem 0; /* small spacing under the topic buttons */
}

/* Normal mode (after first send) — existing behavior */
#chat-container:not(.start-mode) #input-area {
  position: sticky;
  bottom: 0;
  width: 100%;
}

