/* chat-messages.css */
#chatbotContainer {
  background-color: #1e1e1e;
  border-radius: 0.5rem;
  border: 1px solid #333;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  max-height: 80vh;
  overflow-y: auto;
}

#chatbotContainer .card-body {
  padding: 1rem;
}

#chatbotMessages {
  background-color: rgba(255, 255, 255, 0.05);
  margin: 1rem;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-y: auto;
  flex-grow: 1;
}

/* Message bubbles (kept from original file) */
.message-row {
  display: flex;
  align-items: flex-end;
  margin-bottom: 10px;
}

.user-message-row {
  justify-content: flex-end;
}

.user-message-row .icon-bubble {
  order: 2;
  margin-left: 8px;
}

.bot-message-row .icon-bubble {
  margin-right: 8px;
}

.icon-bubble {
  font-size: 2.6em;
  position: relative;
}

.text-bubble {
  max-width: 80%;
  padding: 10px 15px;
  border-radius: 20px;
  word-wrap: break-word;
}

.user-message-row .text-bubble {
  background-color: #bb86fc;
  color: #121212;
}

.bot-message-row .text-bubble {
  background-color: #252525;
  color: #e0e0e0;
}

.icon-bubble .message-timestamp {
  position: absolute;
  font-size: 0.4em;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  color: #9b9ea1;
}

/* ---------- Chat-input area: layout and visual rules ---------- */
.chat-input-container {
  display: flex;
  position: relative;
  margin: 0 1rem 1rem 1rem;
  gap: 0.5rem;
  /* Top-aligned behavior */
  align-items: flex-start;
  /* keep input on one line by default */
}

/* Paperclip icon - left, aligned to first text line */
.file-upload-icon {
  cursor: pointer;
  font-size: 1.2rem;
  color: #9b9ea1;
  position: absolute;
  left: 12px;
  /* align with top padding of textarea (see #chatbotInput) */
  top: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  user-select: none;
}

/* Textarea: top-left start of text, sizing, padding */
#chatbotInput {
  flex-grow: 1;
  resize: none;
  box-sizing: border-box;
  min-height: 44px;            /* 44–48px default */
  max-height: calc((1.5em * 6) + 20px); /* allow ~6 lines before scrollbar */
  line-height: 1.5;
  padding: 8px 12px 8px 44px; /* left padding for icon; top padding to align top-left */
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.06);
  background: transparent;
  color: inherit;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
  /* ensure text aligns to top */
  vertical-align: top;
}

/* placeholder contrast in dark mode */
#chatbotInput::placeholder {
  color: rgba(255,255,255,0.45);
  opacity: 1;
}

/* Send button stays to the right of textarea */
#sendChatbotMessage {
  align-self: flex-start; /* align with first line */
  padding: 8px 12px;
  margin-left: 0;
  height: 38px;
}

/* Make the input area visually like a subtle field */
.chat-input-container .form-control {
  border: 1px solid rgba(255,255,255,0.06);
  background-color: rgba(255,255,255,0.02);
}

/* Focus ring visible in dark mode */
#chatbotInput:focus,
.chat-input-container .file-chip:focus,
.chat-input-container .file-remove-btn:focus,
.file-upload-icon:focus {
  box-shadow: 0 0 0 3px rgba(187,134,252,0.18);
  border-color: rgba(187,134,252,0.9);
  outline: none;
}

/* ---------- File chip (inline, inside input area, right aligned) ---------- */
.file-chip-wrapper {
  position: absolute;
  right: 12px;
  top: 8px; /* align with first text line */
  display: inline-flex;
  gap: 6px;
  align-items: center;
  pointer-events: none; /* default: made visible/interactive via inner elements */
}

/* The visible pill */
.file-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.03);
  color: #e6e6e6;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 999px;
  font-size: 0.82rem;
  max-width: 42%;
  min-width: 80px;
  /* ensure text truncates at the end; JS will implement middle-ellipsis */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

/* icon (paperclip) inside chip */
.file-chip .chip-icon {
  font-size: 0.9rem;
  margin-left: 0;
  opacity: 0.9;
}

/* extra file metadata (size) */
.file-chip .chip-meta {
  color: #9b9ea1;
  font-size: 0.75rem;
  margin-left: 4px;
}

/* Remove button inside chip */
.file-remove-btn {
  pointer-events: auto;
  background: transparent;
  border: none;
  color: #cfcfcf;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

/* Hover / focus affordances for remove */
.file-remove-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
}

/* Error text below the input */
.file-input-error {
  display: block;
  color: #ffb4b4;
  font-size: 0.82rem;
  margin-top: 6px;
  margin-left: 1rem;
}

/* Ensure input area stays at bottom of modal but is top-aligned internally */
.chat-modal-dialog {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.chat-modal-dialog .modal-content {
  display: flex;
  flex-direction: column;
  height: 90vh;
}

.chat-modal-dialog .modal-body {
  overflow-y: auto;
  flex-grow: 1;
}

#chatbotContainer {
  height: 100%;
}

.chat-interface {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-input-container {
  margin-top: auto;
}


.thinking-spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-left-color: #bb86fc;
  animation: spin 1s ease infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
