/* ========== Base layout (open page, no outer card) ========== */
:root {
  --bg: #f4f6f9;
  --text: #1f2328;
  --muted: #667085;
  --border: #d0d5dd;
  --border-soft: #ccc;
  --blue: #007bff;
  --blue-dark: #036ae0;
  --success: #12a150;
  --error: #c62828;

  --shadow-1: 0 1px 0 rgba(16,24,40,.02);
  --shadow-2: 0 6px 14px rgba(0,123,255,.18);
  --shadow-3: 0 12px 28px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.08);
}

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

body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: center; /* centers vertically on tall screens */
  align-items: center;
  min-height: 100vh;
  margin: 0;
  text-align: center;
}

.container {
  padding: 0 16px 28px;
  width: 100%;
  max-width: 900px; /* lets chat breathe without an outer card */
  margin: 0 auto;
}

h1 {
  margin: 0 0 24px;
  color: #333;
  font-size: clamp(22px, 3.2vw, 36px);
  line-height: 1.2;
}

/* ========== Form layout: input(+ inside) + submit button ========== */
.inline-form {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto; /* input area | submit */
  align-items: center;
  justify-content: center;
  column-gap: 14px;   /* hard gap so they never touch */
  margin: 0 auto;
  max-width: 760px;
}

.input-wrap {
  position: relative;
  width: 100%;
  max-width: 600px;
}

/* Text input with reserved space for + button */
.input-wrap input[type="text"] {
  height: 48px;
  width: 100%;
  padding: 12px 46px 12px 14px; /* right padding for + */
  border: 2px solid var(--border-soft);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  transition: border-color .25s ease, box-shadow .25s ease, transform .2s ease;
  box-shadow: var(--shadow-1);
}

.input-wrap input[type="text"]::placeholder { color: #98a2b3; }
.input-wrap input[type="text"]:hover { border-color: #b6c3ff; }

.input-wrap input[type="text"]:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 4px rgba(0,123,255,.15);
  transform: translateY(-1px);
}

/* + button inside the input (right side) */
.inside-plus {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: #0b57d0;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  transition: background .15s, box-shadow .2s, transform .1s;
  z-index: 1;
}

.inside-plus:hover  { background:#f6f7f9; }
.inside-plus:active { transform: translateY(-50%) scale(.98); }
.inside-plus:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,123,255,.25);
}

/* Submit button */
input[type="submit"],
.btn {
  height: 48px;
  padding: 0 18px;
  font-size: 16px;
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s, opacity .2s;
  box-shadow: var(--shadow-2);
}

input[type="submit"]:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0,123,255,.24);
}

input[type="submit"]:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(0,123,255,.18);
}

input[type="submit"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,123,255,.25), var(--shadow-2);
}

input[type="submit"]:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* Helper text */
.hint { margin-top: 8px; color: var(--muted); font-size: 14px; }

/* Accessibility helper */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ========== Dropdown menu anchored under the + ========== */
.menu.small {
  position: absolute;
  top: calc(100% + 8px);  /* under the input */
  right: 0;               /* align to the + button */
  width: 260px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-3);
  padding: 8px 0;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 9999;
}

.menu.small.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.menu-item {
  width: 100%;
  display: grid;
  grid-template-columns: 14px 1fr auto; /* dot | label | optional chevron */
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
}

.menu-item:hover { background: #f1f3f5; }
.menu-item:focus-visible { outline: none; background: #eaf2ff; }

.menu-sep {
  height: 1px;
  background: #e6e8eb;
  margin: 6px 0;
}

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #d0d5dd;
  display: inline-block;
}

.chev { opacity: .55; }

/* ========== Chat area (bubbles) ========== */
.chat {
  margin: 20px auto 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 760px;
  text-align: left;
  padding: 0 8px 24px;
  overflow-y: auto;              /* ✅ enables scrolling */
  max-height: 70vh;              /* ✅ prevents the whole page from stretching infinitely */
  scroll-behavior: smooth;       /* ✅ makes scrolling pleasant */
  overscroll-behavior: contain;  /* ✅ prevents bouncing on nested scrolls */
}

.bubble {
  padding: 12px 14px;
  border-radius: 12px;
  line-height: 1.5;
  white-space: pre-wrap;  /* preserve newlines */
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  border: 1px solid rgba(0,0,0,.05);
}

.bubble.user {
  background: #e8f0fe;
  border-color: #d6e2ff;
  justify-self: end;
  max-width: min(85%, 680px);
}

.bubble.agent {
  background: #fff;
  border-color: #eceff3;
  justify-self: start;
  max-width: min(85%, 680px);
}

/* Subtle “thinking…” shimmer (for agent placeholder) */
.bubble.agent.thinking {
  position: relative;
  color: #7d8899;
  overflow: hidden;
}
.bubble.agent.thinking::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.03), transparent);
  animation: shimmer 1.25s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Optional status text under chat */
.status {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  margin-top: 6px;
}

/* ========== Scrollbar (nice but subtle) ========== */
.chat::-webkit-scrollbar { width: 10px; height: 10px; }
.chat::-webkit-scrollbar-thumb {
  background: #cfd6e0;
  border-radius: 10px;
}
.chat::-webkit-scrollbar-track { background: transparent; }

/* ========== Utility: success/error hints (optional) ========== */
.text-success { color: var(--success); }
.text-error   { color: var(--error); }

/* ========== Loading state (toggled by JS) ========== */
.loading { cursor: progress; }
.loading .btn,
.loading input[type="text"],
.loading .inside-plus {
  pointer-events: none;
  opacity: .7;
}

/* ========== Reduced motion accessibility ========== */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .bubble.agent.thinking::after { animation: none !important; }
}

/* ========== Responsive: stack on small screens ========== */
@media (max-width: 640px) {
  .inline-form {
    grid-template-columns: 1fr;   /* stack */
    row-gap: 10px;
  }
  .input-wrap { max-width: 100%; }
  input[type="submit"] { width: 100%; }
  .chat { padding: 0 2px 24px; }
}



