/* ========================================
   CHATBOT PAGE — Full-viewport layout
   Input always visible, mobile-first
   ======================================== */

/* --- Layout shell -------------------------------------------------- */
.chatbot-page {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 80px);
  height: calc(100vh - 80px);
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

/* --- Header -------------------------------------------------------- */
.chatbot-page__header {
  flex-shrink: 0;
  padding: 28px 0 20px;
  text-align: center;
}

.chatbot-page__header h1 {
  font-family: var(--font-sans-stack);
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.chatbot-page__header p {
  font-size: 0.92rem;
  color: #64748b;
  margin: 0;
  line-height: 1.5;
}

/* --- Messages area ------------------------------------------------- */
.chatbot-page__messages {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 0;
  scroll-behavior: smooth;
}

/* Scrollbar */
.chatbot-page__messages::-webkit-scrollbar { width: 5px; }
.chatbot-page__messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-page__messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
.chatbot-page__messages::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.chatbot-page__messages { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

/* --- Welcome state ------------------------------------------------- */
.chatbot-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 20px 0;
  text-align: center;
}

.chatbot-welcome__icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.chatbot-welcome__icon svg {
  width: 28px;
  height: 28px;
  color: #fff;
}

.chatbot-welcome__title {
  font-family: var(--font-sans-stack);
  font-size: 1.15rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 6px;
}

.chatbot-welcome__subtitle {
  font-size: 0.88rem;
  color: #64748b;
  margin: 0 0 28px;
  max-width: 380px;
}

.chatbot-welcome__suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

.chatbot-welcome__suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.chatbot-welcome__suggestion:hover {
  border-color: #94a3b8;
  background: #f8fafc;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.chatbot-welcome__suggestion-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  font-size: 0.85rem;
}

/* --- Messages ------------------------------------------------------ */
.chatbot-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  animation: chatbot-slide-in 0.25s ease-out;
}

@keyframes chatbot-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* User message */
.chatbot-msg--user {
  flex-direction: row-reverse;
}

.chatbot-msg__avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  margin-top: 2px;
}

.chatbot-msg--bot .chatbot-msg__avatar {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
}

.chatbot-msg--user .chatbot-msg__avatar {
  background: #e2e8f0;
  color: #475569;
}

.chatbot-msg__body {
  max-width: 80%;
  min-width: 0;
}

.chatbot-msg__bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.65;
  color: #1e293b;
  word-break: break-word;
}

.chatbot-msg--bot .chatbot-msg__bubble {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.chatbot-msg--user .chatbot-msg__bubble {
  background: #1e293b;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Bot bubble links */
.chatbot-msg--bot .chatbot-msg__bubble a {
  color: #2563eb;
  text-decoration: underline;
  text-decoration-color: #93c5fd;
  text-underline-offset: 2px;
}

.chatbot-msg--bot .chatbot-msg__bubble a:hover {
  text-decoration-color: #2563eb;
}

/* Typing indicator */
.chatbot-typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.chatbot-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: chatbot-dot-pulse 1.4s infinite ease-in-out;
}

.chatbot-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-dot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* --- Sources ------------------------------------------------------- */
.chatbot-sources {
  margin-top: 12px;
}

.chatbot-sources__title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.chatbot-sources__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chatbot-sources__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #475569;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatbot-sources__link:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.chatbot-sources__link svg {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
}

/* --- Follow-up questions ------------------------------------------- */
.chatbot-followup {
  margin-top: 14px;
}

.chatbot-followup__title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.chatbot-followup__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chatbot-followup__btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.85rem;
  color: #334155;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  line-height: 1.4;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chatbot-followup__btn:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

/* --- Input area ---------------------------------------------------- */
.chatbot-page__input {
  flex-shrink: 0;
  padding: 16px 0 max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.chatbot-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 8px 12px 8px 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chatbot-input-row:focus-within {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.12);
}

.chatbot-input-row textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-sans-stack);
  font-size: 0.92rem;
  color: #1e293b;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 120px;
  line-height: 1.5;
  padding: 4px 0;
}

.chatbot-input-row textarea::placeholder {
  color: #94a3b8;
}

.chatbot-input-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.chatbot-input-btn--voice {
  background: transparent;
  color: #94a3b8;
}

.chatbot-input-btn--voice:hover {
  color: #475569;
}

.chatbot-input-btn--voice.recording {
  color: #ef4444;
  animation: chatbot-mic-pulse 1s infinite ease-in-out;
}

@keyframes chatbot-mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chatbot-input-btn--send {
  background: #1e293b;
  color: #fff;
}

.chatbot-input-btn--send:hover:not(:disabled) {
  background: #334155;
}

.chatbot-input-btn--send:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

.chatbot-input-btn svg {
  width: 16px;
  height: 16px;
}

.chatbot-page__disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 8px;
  line-height: 1.4;
}

/* --- Error --------------------------------------------------------- */
.chatbot-error {
  color: #dc2626;
  font-weight: 500;
}

/* --- Responsive ---------------------------------------------------- */

/* Tablets and small desktops */
@media (max-width: 1035px) {
  .chatbot-page {
    height: calc(100dvh - 70px);
    height: calc(100vh - 70px);
  }
}

/* Mobile */
@media (max-width: 640px) {
  .chatbot-page {
    padding: 0 12px;
  }

  .chatbot-page__header {
    padding: 16px 0 12px;
  }

  .chatbot-page__header h1 {
    font-size: 1.25rem;
  }

  .chatbot-page__header p {
    font-size: 0.85rem;
  }

  .chatbot-msg__body {
    max-width: 88%;
  }

  .chatbot-msg__bubble {
    padding: 10px 14px;
    font-size: 0.88rem;
  }

  .chatbot-welcome__suggestion {
    padding: 12px 14px;
    font-size: 0.85rem;
  }

  .chatbot-welcome__suggestion-icon {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .chatbot-input-row {
    padding: 6px 10px 6px 14px;
  }

  .chatbot-sources__link {
    max-width: 200px;
  }
}

/* Very small screens */
@media (max-height: 500px) {
  .chatbot-page__header {
    padding: 8px 0;
  }

  .chatbot-page__header p {
    display: none;
  }
}
