/* Importing Google Fonts - Poppins */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");

* {
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

:root {
  /* Dark theme colors */
  --text-color: #edf3ff;
  --subheading-color: #97a7ca;
  --placeholder-color: #c3cdde;
  --primary-color: #101623;
  --secondary-color: #283045;
  --secondary-hover-color: #333e58;
  --scrollbar-color: #626a7f;
}

body.light-theme {
  /* Light theme colors */
  --text-color: #0901c3;
  --subheading-color: #7b8cae;
  --placeholder-color: #606982;
  --primary-color: #f3f7ff;
  --secondary-color: #dce6f9;
  --secondary-hover-color: #d2ddf2;
  --scrollbar-color: #a2aac2;
}

body {
  margin: 0;
  padding: 0;
  color: var(--text-color);
  background-color: var(--primary-color);
}

.container {
  overflow-y: auto;
  padding: 32px 0 60px;
  max-height: calc(100vh - 127px);
  scrollbar-color: var(--scrollbar-color) transparent;
}

/* Shared container layout for main sections */
.container .app-header,
.container .suggestions,
.container .prompt-wrapper,
.container .disclaimer-text,
.container .message {
  margin: 0 auto;
  width: 100%;
  padding: 0 20px;
  max-width: 980px;
}

/* Hide header and suggestions initially */
body.chats-active .container .app-header,
body.chats-active .container .suggestions {
  display: none;
}

/* App Heading Stylings */
.container .app-header {
  margin-top: 4vh;
}

.app-header .heading {
  font-size: 3rem;
  width: fit-content;
  background: linear-gradient(to right, #1d7efd, #8f6fff);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-header .sub-heading {
  font-size: 2.6rem;
  margin-top: -5px;
  color: var(--subheading-color);
}

/* Suggestions List Stylings */
.suggestions {
  display: flex;
  gap: 15px;
  margin-top: 9.5vh;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}

.suggestions .suggestions-item {
  width: 228px;
  padding: 18px;
  flex-shrink: 0;
  display: flex;
  cursor: pointer;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  border-radius: 12px;
  background: var(--secondary-color);
  transition: 0.3s ease;
}

.suggestions .suggestions-item:hover {
  background: var(--secondary-hover-color);
}

.suggestions .suggestions-item .text {
  font-size: 1.1rem;
}

.suggestions .suggestions-item span {
  height: 45px;
  width: 45px;
  margin-top: 35px;
  display: flex;
  align-self: flex-end;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #1d7efd;
  background: var(--primary-color);
}

.suggestions .suggestions-item:nth-child(2) span {
  color: #28a745;
}

.suggestions .suggestions-item:nth-child(3) span {
  color: #ffc107;
}

.suggestions .suggestions-item:nth-child(4) span {
  color: #6f42c1;
}

/* Chats Container Stylings */
.chats-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chats-container .message {
  display: flex;
  gap: 11px;
  align-items: center;
}

.chats-container .bot-message .avatar {
  height: 43px;
  width: 43px;
  flex-shrink: 0;
  padding: 6px;
  align-self: flex-start;
  margin-top: 2.4%;
  margin-right: -7px;
  border-radius: 50%;
  background: var(--secondary-color);
  border: 1px solid var(--secondary-hover-color);
}

.chats-container .bot-message.loading .avatar {
  animation: rotate 2s linear infinite;
}

@keyframes rotate {
  100% {
    transform: rotate(360deg);
  }
}

.chats-container .bot-message {
  margin: 9px auto;
}

.chats-container .user-message {
  flex-direction: column;
  align-items: flex-end;
}

.chats-container .user-message .message-text {
  padding: 12px 16px;
  max-width: 75%;
  border-radius: 13px 13px 3px 13px;
  background: var(--secondary-color);
}

/* Prompt Container Styling */
.prompt-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 16px 0;
  background: var(--primary-color);
  z-index: 1000;
}

.prompt-wrapper,
.prompt-form,
.prompt-actions {
  max-width: 980px;
  display: flex;
  gap: 12px;
  height: 56px;
  align-items: center;
}

.prompt-wrapper .prompt-form {
  width: 100%;
  height: 100%;
  border-radius: 130px;
  background: var(--secondary-color);
}

.prompt-form .prompt-input {
  height: 100%;
  width: 100%;
  background: none;
  outline: none;
  border: none;
  font-size: 1rem;
  padding-left: 24px;
  color: var(--text-color);
}

.prompt-form .prompt-input::placeholder {
  color: var(--placeholder-color);
}

.prompt-wrapper button {
  width: 56px;
  height: 100%;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  font-size: 1.4rem;
  flex-shrink: 0;
  color: var(--text-color);
  background: var(--secondary-color);
  transition: 0.3s ease;
}

.prompt-wrapper button:hover,
.prompt-wrapper .file-icon,
.prompt-wrapper #cancel-file-btn {
  background: var(--secondary-hover-color);
}

.prompt-form .prompt-actions {
  gap: 5px;
  margin-right: 7px;
}

.prompt-wrapper .prompt-form button,
.prompt-wrapper .prompt-form img,
.prompt-wrapper .prompt-form .file-upload-wrapper {
  position: relative;
  height: 45px;
  width: 45px;
}

.prompt-form #send-prompt-btn {
  display: none;
  color: #fff;
  background: #1d7efd;
}

#send-prompt-btn:hover {
  background: #0264e3;
}

.prompt-form .prompt-input:valid ~ .prompt-actions #send-prompt-btn {
  display: block;
}

.prompt-form .file-upload-wrapper button,
.prompt-form .file-upload-wrapper img {
  position: absolute;
  border-radius: 50%;
  object-fit: cover;
  display: none;
}

.prompt-form .file-upload-wrapper #add-file-btn,
.prompt-form .file-upload-wrapper.active.img-attached img,
.prompt-form .file-upload-wrapper.active.file-attached .file-icon,
.prompt-form .file-upload-wrapper.active:hover #cancel-file-btn {
  display: block;
}

.img-attachment {
  max-width: 220px; /* prevent it from being too wide */
  max-height: 180px; /* keep height controlled */
  border-radius: 12px;
  object-fit: cover; /* crops neatly if aspect ratio doesn’t match */
  margin-top: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.2s ease-in-out;
}

.img-attachment:hover {
  transform: scale(1.05);
}

.prompt-form .file-upload-wrapper.active #add-file-btn {
  display: none;
}

.prompt-form #cancel-file-btn,
.prompt-form #stop-response-btn:hover {
  color: #d62939;
}

.prompt-form .file-icon {
  color: #1d7efd;
}

.prompt-form #stop-response-btn,
body.bot-responding .prompt-form .file-upload-wrapper {
  display: none;
}

body.bot-responding .prompt-form #stop-response-btn {
  display: block;
}

.prompt-container .disclaimer-text {
  text-align: center;
  font-size: 0.9rem;
  padding: 16px 20px 0;
  color: var(--placeholder-color);
}

@media (max-width: 768px) {
  .prompt-wrapper.hide-controls #theme-toggle-btn,
  .prompt-wrapper.hide-controls #delete-chats-btn {
    display: none;
  }
}

/* Base style for the message text container */
.message-text {
  padding: 3px 16px;
  word-wrap: break-word;
  /* This is the key fix for preserving newlines and spacing */
  /* white-space: pre-wrap; */
}

/* Styles for rendered Markdown in messages */
.message-text h1,
.message-text h2,
.message-text h3 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

.message-text h1 {
  font-size: 1.75em;
}
.message-text h2 {
  font-size: 1.5em;
}
.message-text h3 {
  font-size: 1.25em;
}

.message-text strong {
  font-weight: bold;
}
.message-text em {
  font-style: italic;
}

/* Inline code style */
.message-text code {
  background: var(--secondary-hover-color);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "Courier New", Courier, monospace;
}

/* Code block container style */
.message-text pre {
  background-color: #1e1e1e; /* A standard dark background for code */
  color: #d4d4d4; /* Light text color for contrast */
  padding: 15px;
  border-radius: 8px;
  overflow-x: auto; /* Allow horizontal scrolling for long lines */
  margin: 1em 0;
  border: 1px solid var(--secondary-hover-color);
}

/* Reset background and padding for code inside a pre block, as highlight.js handles it */
.message-text pre code {
  background: none;
  padding: 0;
  font-size: 0.9em;
}

.message-text ul,
.message-text ol {
  margin: 1em 0;
  padding-left: 25px;
}

.message-text li {
  margin-bottom: 0.5em;
}

.message-text a {
  color: #1d7efd;
  text-decoration: underline;
}

.message-text blockquote {
  border-left: 4px solid var(--subheading-color);
  padding-left: 15px;
  margin: 1em 0;
  color: var(--subheading-color);
}
