/* Ensure full height to fill iframe */
html, body {
  height: 100%;
  margin: 0;
  background: transparent !important;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
}
/* Body flex container stretched vertically */
body {
  display: flex;
  justify-content: center;
  align-items: stretch; /* fill vertically */
  min-height: 100vh;
}

/* Main chat container fills full height */
.chat-container {
  height: 100%;       /* instead of 100vh */
  max-height: 100%;
  width: 100%;
  max-width: 600px;
  background-color: #1a1a1f;
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 0 16px 16px;
  box-sizing: border-box;
}

/* Title styles */
.chat-title {
  text-align: center;
  padding: 16px;
  font-size: 24px;
  font-weight: 600;
  border-bottom: 1px solid #2a2a30; /* subtle border */
  user-select: none;
  color: #a855f7; /* purple */
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Chat message box styles */
.chat-box {
  flex-grow: 1;
  padding: 16px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #a855f7 transparent;
  overflow-x: hidden !important; /* Prevent horizontal scroll */
}

/* Scrollbar styles */
.chat-box::-webkit-scrollbar {
  width: 8px;
}

.chat-box::-webkit-scrollbar-thumb {
  background-color: #a855f7;
  border-radius: 10px;
  border: 2px solid #1a1a1f;
}

.chat-box::-webkit-scrollbar-track {
  background: transparent;
}

/* Chat message wrapper */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  word-break: break-word !important; /* Break long words */
  overflow-wrap: break-word !important;
}

.chat-wrapper.user {
  align-self: flex-end;
  text-align: right;
}

.chat-wrapper.bot {
  align-self: flex-start;
  text-align: left;
}

/* Message label */
.chat-label {
  font-size: 0.75rem;
  color: #aaa;
  margin-bottom: 4px;
  padding: 0 4px;
  user-select: none;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Chat message bubble */
.chat-message {
  padding: 12px 16px;
  border-radius: 16px;

  /* Fix overflow for normal text */
  white-space: pre-wrap !important;   /* Wrap lines and preserve line breaks */
  word-wrap: break-word !important;   /* Break long words */
  overflow-wrap: anywhere !important; /* Break anywhere if needed */
  max-width: 100% !important;         /* Prevent exceeding container width */
  box-sizing: border-box !important;
  overflow-x: hidden !important;      /* Hide horizontal scrollbar */

  line-height: 1.5;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 16px;
}

.chat-message.user {
  background-color: #2a2a30;
  color: white;
  align-self: flex-end;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.chat-message.bot {
  background-color: #1f1f25;
  color: white;
  align-self: flex-start;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

/* Input container at bottom */
.input-container {
  display: flex;
  padding: 12px;
  border-top: 1px solid #2a2a30;
  gap: 8px;
  background-color: #1a1a1f;
}

/* Textarea input */
textarea {
  flex: 1;
  padding: 12px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 16px;
  border-radius: 12px;
  border: 2px solid #a855f7;
  resize: none;
  background-color: #1a1a1f;
  color: #e0e0e0;
  line-height: 1.4;
  max-height: 150px;
  overflow-y: auto;
  box-shadow: inset 0 0 5px rgba(168, 85, 247, 0.5);
  transition: border-color 0.3s ease;
}

textarea:focus {
  outline: none;
  border-color: #d6bbfb;
  box-shadow: 0 0 8px #d6bbfb;
}

/* Send button */
button {
  padding: 12px 20px;
  background-color: #a855f7;
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
  user-select: none;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.5);
}

button:hover {
  background-color: #7c3aed;
}

/* Remove unwanted scrollbar in textarea */
.input-container textarea::-webkit-scrollbar {
  width: 6px;
}

.input-container textarea::-webkit-scrollbar-thumb {
  background-color: #a855f7;
  border-radius: 8px;
}

.input-container textarea::-webkit-scrollbar-track {
  background: transparent;
}

/* Code block wrapper with scroll */
.code-block-wrapper {
  position: relative;
  background: #1e1e1e;
  border-radius: 6px;
  margin: 10px 0;
  overflow-x: auto !important;  /* Allow horizontal scroll for code */
  padding: 12px 40px 12px 12px;
  font-family: monospace;
  font-size: 14px;
  color: #eee;
  white-space: pre;              /* Preserve formatting for code */
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.code-block-wrapper pre {
  margin: 0;
  white-space: pre;
  overflow-x: auto;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #77d683;
  border: none;
  color: #222;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  user-select: none;
}

.copy-btn:hover {
  background: #5cb96e;
}
