/* General Styles */
* {
  font-family: Arial, Helvetica, sans-serif;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: #f9f9f9;
  font-size: 16px;
  color: #333;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Main Content */
main {
  flex: 1;
  width: 100%;
  padding: 20px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* Align elements to the left */
}

main > h1 {
  width: 100%;
  text-align: left; /* Left-align the heading */
  font-size: 2.5em;
  margin-bottom: 0.5em;
  color: #0056b3;
}

main > p {
  text-align: left; /* Left-align paragraphs */
  margin: 0.5em 0;
  font-size: 1.1em;
  color: #555;
}

/* Input Fields */
input[type="text"] {
  width: 100%;
  max-width: 600px;
  padding: 10px;
  margin: 10px 0;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 4px;
}

input[type="text"]:focus {
  border-color: #0056b3;
  outline: none;
  box-shadow: 0 0 5px rgba(0, 86, 179, 0.2);
}

/* Button Container */
.button-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
button {
  padding: 10px 20px;
  font-size: 1em;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #0056b3;
}

button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* Error Messages */
.hidden {
  display: none;
}

.text-danger {
  color: #d9534f;
  font-size: 0.9em;
  margin-top: -5px;
  text-align: left; /* Left-align error messages */
}

/* Loading Spinner */
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* PDF Container and Download Link */
#pdfContainer, #pdfDownloadLink {
  width: 100%;
  margin-top: 20px;
  text-align: left; /* Left-align the PDF container and download link */
}

#pdfDownloadLink p {
  margin: 10px 0;
}

.download-link {
  display: inline-block;
  padding: 10px 20px;
  background-color: #28a745;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}

.download-link:hover {
  background-color: #218838;
}

/* Footer */
footer {
  margin-top: 20px;
  text-align: center;
  width: 100%;
  padding: 20px;
  background-color: #0056b3;
  color: white;
}

footer a {
  color: white;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Chat Interface Styles */
#chatContainer {
  width: 100%;
  flex: 1;
  min-height: 400px;
  border: 1px solid #ccc;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  margin-top: 20px;
  background: #fff;
  box-sizing: border-box;
}

.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background: #f8f9fa;
  border-radius: 8px 8px 0 0;
  width: 100%;
  box-sizing: border-box;
}

.chat-message {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.user-message {
  align-items: flex-end;
}

.user-message .message-content {
  background: #007bff;
  color: white;
  padding: 10px 15px;
  border-radius: 18px 18px 4px 18px;
  max-width: 70%;
  word-wrap: break-word;
}

.assistant-message {
  align-items: flex-start;
}

.assistant-message .message-content {
  background: #e9ecef;
  color: #333;
  padding: 10px 15px;
  border-radius: 18px 18px 18px 4px;
  max-width: 80%;
  word-wrap: break-word;
}

.assistant-message .message-content code {
  background: #f8f9fa;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.chat-input-container {
  display: flex;
  padding: 15px;
  background: #fff;
  border-radius: 0 0 8px 8px;
  border-top: 1px solid #dee2e6;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.chat-input-container input[type="text"] {
  flex: 1;
  margin: 0;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid #ccc;
  font-size: 1em;
  min-width: 0;
  max-width: none;
  width: auto;
  box-sizing: border-box;
}

.chat-input-container button {
  padding: 12px 20px;
  border-radius: 20px;
  white-space: nowrap;
}

.mcp-results {
  margin: 10px 0;
  padding: 10px;
  background: #e3f2fd;
  border-left: 4px solid #2196f3;
  border-radius: 4px;
  font-size: 0.9em;
  color: #1565c0;
}

.mcp-suggestions {
  margin: 10px 0;
  padding: 8px 12px;
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  border-radius: 4px;
  font-size: 0.9em;
  color: #856404;
}

.mcp-results details {
  margin-top: 8px;
}

.mcp-results summary {
  cursor: pointer;
  font-weight: bold;
  color: #1565c0;
}

.mcp-results pre {
  background: #f8f9fa;
  padding: 8px;
  border-radius: 4px;
  font-size: 0.8em;
  overflow-x: auto;
  max-height: 200px;
  margin: 5px 0 0 0;
}

/* Responsive Design */
@media (max-width: 480px) {
  html, body {
    font-size: 14px;
  }

  main > h1 {
    font-size: 2em;
  }

  main {
    padding: 15px;
  }

  input[type="text"] {
    max-width: 100%;
  }

  #chatContainer {
    flex: 1;
    min-height: 300px;
  }
  
  .user-message .message-content,
  .assistant-message .message-content {
    max-width: 90%;
  }
  
  .chat-input-container {
    padding: 10px;
  }
  
  .chat-input-container input[type="text"] {
    padding: 10px;
  }
  
  .chat-input-container button {
    padding: 10px 15px;
  }
}

/* Forced Colors Mode */
@media (-ms-high-contrast: active), (forced-colors: active) {
  body {
    background-color: Canvas;
    color: CanvasText;
  }

  a {
    color: LinkText;
  }

  button, .download-link {
    background-color: Highlight;
    color: HighlightText;
  }

  footer {
    background-color: Highlight;
    color: HighlightText;
  }
}