/* Global Styles */
:root {
  --primary-color: #007bff;
  --secondary-color: #357abd;
  --background-color: #f5f7fa;
  --text-color: #333333;
  --chat-background: #e1e5eb;
  --message-background: #ffffff;
  --user-message-color: #ffffff;
  --bot-message-color: #333333;
  --link-color: #4a90e2;
  --visited-link-color: #9b59b6;
  --active-link-color: #e74c3c;
  --border-color: #d1d5db;
  --transition-speed: 0.3s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: 'Inter', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  transition: all var(--transition-speed) ease-in-out;
  height: 100%;
  overflow: hidden;
}

/* Loader Styles */
.loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--background-color);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity var(--transition-speed) ease-in-out;
}

@keyframes rotating {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.holder {
  opacity: 0;
  transition: opacity var(--transition-speed) ease-in-out;
}

.rotating {
  animation: rotating 2s linear infinite;
}

.loading-logo {
  margin: auto;
  width: 25%;
  display: block;
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Chat Styles */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  height: 100dvh;
}

.chat {
  width: 100%;
  max-width: 1200px;
  height: 95vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  background-color: var(--message-background);
}

.chat-header {
  background-color: var(--primary-color);
  color: #ffffff;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.chat-header h2 {
  display: flex;
  align-items: center;
  font-size: 1.8rem;
  font-weight: 600;
}

.chat-header img {
  height: 35px;
  margin-right: 15px;
}

.header-buttons {
  gap: 5px;
}

.header-button {
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-weight: 500;
  transition: all var(--transition-speed) ease;
  cursor: pointer;
}

.header-button:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.chat-history {
  flex: 1;
  background-color: var(--chat-background);
  overflow-y: auto;
  padding: 2dvh;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message-bubble {
  max-width: 70%;
  padding: 15px 20px;
  border-radius: 16px;
  font-size: 1rem;
  line-height: 1.5;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.user-message {
  background-color: var(--primary-color);
  color: var(--user-message-color);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bot-message {
  background-color: var(--message-background);
  color: var(--bot-message-color);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-message {
  display: flex;
  padding: 15px;
  background-color: var(--message-background);
  border-top: 1px solid var(--border-color);
}

.message-input {
  flex: 1;
  border: 1px solid var(--border-color);
  outline: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  resize: none;
  min-height: 4vh;
  max-height: 15vh;
  background-color: var(--background-color);
  color: var(--text-color);
  transition: all var(--transition-speed) ease;
}

.message-input:focus {
  box-shadow: 0 0 0 2px var(--primary-color);
  border-color: var(--primary-color);
}

.send-button {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  padding: 12px 25px;
  margin-left: 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  font-weight: 500;
}

.send-button:hover {
  background-color: var(--secondary-color);
  transform: translateY(-2px);
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background-color: var(--message-background);
  border-top: 1px solid var(--border-color);
}

/* Dark Theme */
.dark {
  --primary-color: #007bff;
  --secondary-color: #357abd;
  --background-color: #1a1e23;
  --text-color: #e1e5eb;
  --chat-background: #2c3137;
  --message-background: #23282e;
  --user-message-color: #ffffff;
  --bot-message-color: #e1e5eb;
  --link-color: #61afef;
  --visited-link-color: #c678dd;
  --active-link-color: #e06c75;
  --border-color: #38414a;
}

/* Button Styles */
.clickable-button {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  font-weight: 500;
}

.clickable-button:hover {
  background-color: var(--secondary-color);
  transform: translateY(-2px);
}

/* Toggle Switch Styles */
.toggle-output {
  --switch-width: 3.5em;
  --switch-height: 1.75em;
  --switch-padding: 0.2em;
  --switch-animation-duration: 0.2s;

  display: flex;
  align-items: center;
  font-size: 16px;
}

.toggle-output label {
  margin-right: 0.75em;
}

.toggle-output input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: var(--switch-width);
  height: var(--switch-height);
  background-color: #4b5563;
  border-radius: calc(var(--switch-height) / 2);
  position: relative;
  cursor: pointer;
  padding: var(--switch-padding);
  transition: background-color var(--switch-animation-duration) ease;
}

.toggle-output input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: calc(var(--switch-height) - (var(--switch-padding) * 2));
  height: calc(var(--switch-height) - (var(--switch-padding) * 2));
  border-radius: 50%;
  background-color: #ffffff;
  transition: transform var(--switch-animation-duration) ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toggle-output input[type="checkbox"]:checked {
  background-color: var(--primary-color);
}

.toggle-output input[type="checkbox"]:checked::before {
  transform: translateX(calc(var(--switch-width) - var(--switch-height)));
}

/* Popup Styles */
#whats-new-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity var(--transition-speed) ease;
}

.popup-content {
  background: var(--message-background);
  color: var(--text-color);
  padding: 3dvh;
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.popup-hidden {
  display: none;
}

/* Link Styles */
a {
  color: var(--link-color);
  text-decoration: none;
  transition: color var(--transition-speed) ease;
}

a:hover {
  text-decoration: underline;
}

a:visited {
  color: var(--visited-link-color);
}

a:active {
  color: var(--active-link-color);
}

/* List Styles */
ul, ol {
  padding-left: 25px;
  margin-bottom: 15px;
}

/* Code Block Styles */
pre, code {
  background-color: #f1f5f9;
  border-radius: 0 0 6px 6px; /* Rounded corners on the bottom only */
  font-family: 'Fira Code', monospace;
  font-weight: normal;
  padding: 4px 6px;
  font-size: 0.9em;
}

.code-topbar {
  background-color: var(--chat-background); /* Use the same background color as chat */
  padding: 10px 15px; /* Padding for spacing */
  display: flex; /* Flex to layout items in a row */
  justify-content: space-between; /* Space between the language tag and button */
  align-items: center; /* Center items vertically */
  border-bottom: 1px solid var(--border-color); /* Optional border at the bottom */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* Slight shadow for depth */
  border-radius: 8px 8px 0 0; /* Rounded corners on the top only */
}

.dark .code-topbar {
  background-color: var(--chat-background); /* Use the same background color as chat */
}

pre[class*=language-] {
  margin-top: 0px !important;
}

.dark pre, .dark code {
  background-color: #2d3748;
}

.pwa .chat {
  height: 100dvh;
  border-radius: 0;
  max-width: none;
}

.pwa .container {
  padding: 0;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--chat-background);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat {
    height: 100dvh;
    border-radius: 0;
  }

  .container {
    padding: 0;
  }

  .message-bubble {
    max-width: 85%;
  }

  .chat-header h2 {
    font-size: 1.5rem;
  }

  .chat-header img {
    height: 28px;
  }

  .chat-header {
    flex-direction: column;
  }
}

@media (max-width: 500px) {
  .footer {
    flex-direction: column;
    gap: 2px;
  }

  .message-input {
    font-size: 0.9rem;
  }

  .send-button {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
}