/* Base page styling matches overarching site */
body {
  background-color: #edf0ff;
  color: #333366;
  font-family: "Times New Roman";
  font-size: large;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Headings */
h1 {
  color: #880000;
  text-transform: capitalize;
  margin-top: 20px;
}

h3 {
  color: #000088;
  font-weight: normal;
  margin-top: 5px;
}

/* Horizontal menu (copied from site CSS for consistency) */
.menuHorizontal {
  width: 100%;
  background-color: #aabbff;
  margin: -8px 0 10px 0;
}
.menuHorizontal ul {
  margin: 0;
  padding: 0;
}
.menuHorizontal ul li {
  display: inline-block;
  color: #000088;
  background-color: #aabbff;
  font-weight: bold;
  padding: 8px 15px;
}
.menuHorizontal ul li a {
  text-decoration: none;
  color: #000088;
  font-weight: bold;
}
.menuHorizontal ul li a:hover,
.menuHorizontal ul li a.current {
  color: #fff;
  background-color: #0b75b2;
}

/* Chatbot container */
.chat-container {
  width: 60%;
  max-width: 1000px;
  background: white;
  border: 2px solid #aabbff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 20px 0;
}

.messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  max-height: 400px;
}

.message {
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 75%;
  font-family: "Times New Roman";
  line-height: 1.4;
}

.user {
  background: #0b75b2;
  color: white;
  align-self: flex-end;
}

.bot {
  background: #eaeaea;
  align-self: flex-start;
}

/* Input area */
.input-container {
  display: flex;
  border-top: 1px solid #ddd;
  align-items: stretch; /* allow button to match textarea height */
  gap: 8px;
}

.input-container input {
  flex: 1;
  padding: 10px;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: "Times New Roman";
}

.input-container textarea {
  flex: 1; /* take remaining width */
  padding: 10px;
  border: none; /* remove border */
  outline: none;
  font-size: 16px; /* same size as other inputs */
  font-family: "Times New Roman";
  resize: none;
  overflow: hidden;
  box-sizing: border-box;
  background: transparent;
}

.input-container textarea::placeholder {
  font-family: "Times New Roman";
  color: inherit;
  opacity: 0.7;
}

.input-container button {
  padding: 10px 20px;
  border: none;
  background: #0b75b2;
  color: white;
  cursor: pointer;
  font-size: 16px;
  font-family: "Times New Roman";
  align-self: stretch; /* fill container height to visually match textarea */
}

.input-container button:hover {
  background: #0056b3;
}

/* Message formatting */
.message.bot p {
  margin: 0;
  padding: 0;
}

.message.bot code {
  background-color: #f4f4f4;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
}

.message.bot pre {
  background-color: #f4f4f4;
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
}

.message.bot ul,
.message.bot ol {
  margin: 0;
  padding-left: 20px;
}

/* Animated thinking dots */
.loading {
  font-style: italic;
  padding: 5px;
}

.loading::after {
  content: "";
  display: inline-block;
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0%,
  20% {
    content: "";
  }
  40% {
    content: ".";
  }
  60% {
    content: "..";
  }
  80%,
  100% {
    content: "...";
  }
}

/* upload page styling */
.container {
  text-align: center;
  max-width: 980px;
  width: 94%;
  margin: 18px auto;
  padding: 14px;
  box-sizing: border-box;
}

#upload-form {
  margin-top: 20px;
}

#status {
  margin-top: 20px;
  font-weight: bold;
}

.doc-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}

.doc-controls-secondary {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  width: 100%;
}

.delete-selected-btn {
  background: crimson;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  margin-left: auto; /* pushes this button to the far right in .doc-controls */
  display: inline-block;
}

.delete-selected-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.delete-btn:hover:not(:disabled) {
  filter: brightness(0.9);
}

/* Small, non-intrusive layout improvements */
#file-name,
#text-name {
  display: block;
  max-width: 380px; /* a bit bigger than the placeholder text */
  width: 100%;
  margin: 6px auto 10px; /* centered horizontally */
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
  background: #fff;
  box-sizing: border-box;
  font-family: "Times New Roman";
}

/* Make textarea look like the name boxes and sit inline with the submit button */
#text-input {
  display: inline-block;
  vertical-align: middle;
  width: calc(60% - 64px); /* leave room for the button on wide layouts */
  max-width: 400px;
  min-height: 80px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
  background: #fff;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit; /* make textarea use the same font as other inputs */
  font-size: 14px;
  color: inherit;
  #text-input::placeholder {
    font-family: inherit; /* ensure placeholder matches */
    color: #94a3b8; /* adjust to match other placeholders if needed */
    opacity: 1;
  }
}

#submit-text-btn {
  display: inline-block;
  vertical-align: middle;
  margin-left: 12px;
  cursor: pointer;
}

/* Optional: if your markup has a wrapper for the paste area (.text-upload) prefer flex layout */
.text-upload {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Responsive: stack on small screens */
@media (max-width: 640px) {
  #text-input {
    display: block;
    width: 100%;
    max-width: 520px;
  }
  #submit-text-btn {
    display: block;
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
    height: auto;
  }
  .text-upload {
    flex-direction: column;
    align-items: stretch;
  }
}

/* List layout: no bullets, checkbox left, label right */
ul#document-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

ul#document-list li {
  display: flex;
  align-items: center;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 6px; /* reduced vertical gap */
  background: transparent;
}

/* checkbox sizing & alignment */
ul#document-list li .doc-checkbox {
  margin: 0;
  flex: none;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

ul#document-list li label {
  margin-left: 8px;
  flex: 1;
  text-align: left;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.05s ease, color 0.05s ease, font-weight 0.05s ease,
    transform 0.05s ease;
}

/* hover affordance for labels */
ul#document-list li label:hover {
  background: rgba(0, 0, 0, 0.03);
  transform: translateY(-1px);
}

ul#document-list li input.doc-checkbox:checked + label {
  font-weight: 550; /* slightly bolder when selected */
}
