:root {
  --primary: #10a37f;
  --primary-dark: #0d8a6a;
  --sidebar-bg: #202123;
  --chat-bg: #343541;
  --message-ai-bg: #444654;
  --message-user-bg: #343541;
  --text-primary: #ececf1;
  --text-secondary: #8e8ea0;
  --border-color: #4d4d4f;
  --input-bg: #40414f;
  --pill-bg: #40414f;
  --pill-hover: #4a4b59;
  --slightly-lighter: #444654;
}

pre {
  white-space: normal;
}
p {
  margin: 0;
}
img {
  max-width: 85vw;
}

.message-assistant {
  max-width: 80vw;
  word-break: break-word;
}
.message-assistant p {
  margin-bottom: 1rem;
}
.message-user p ~ p {
  margin-bottom: 1rem;
}
ol p,
ul p {
  margin: 0.5rem 0;
}
li {
  margin: 0.5rem 0;
}
* {
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--chat-bg);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  margin: 0;
}

table {
  margin: 1rem 0 2rem;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 0 8px 3px var(--slightly-lighter);
}
.app-container {
  display: flex;
  height: 100vh;
}

/* Sidebar Styles */
.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
}

.new-chat {
  padding: 0.75rem;
}

.new-chat button {
  width: 100%;
  padding: 0.75rem;
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
}

.new-chat button:hover {
  background-color: #2a2b32;
}

.topic {
  flex: 1;
  overflow-y: auto;
  margin: 0.5rem 0;
}

.topic-item {
  padding: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topic-item strong {
  font-weight: normal;
}

.topic-item:hover {
  background-color: #2a2b32;
}

.topic-item.active {
  background-color: var(--slightly-lighter);
}
.logo {
  font-family: "Russo One", sans-serif;
  color: #fff;
  text-decoration: none;
}

.settings {
  padding: 0.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.25rem;
}

.settings button {
  flex: 1;
  padding: 0.5rem;
  background-color: transparent;
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.settings button:hover {
  background-color: #2a2b32;
}

.search-box {
  flex: 1;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.5rem;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.75rem;
  outline: none;
  box-sizing: border-box;
}

.search-box input:focus {
  border-color: var(--primary);
}

.search-results {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 0.25rem;
}

.search-results:not(:empty) {
  display: block;
}

.search-result-item {
  padding: 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.search-result-item:hover {
  background-color: #2a2b32;
  color: var(--text-primary);
}

/* Main Chat Area */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem;
}

.welcome-message h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.pill-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 800px;
  margin-top: 1rem;
}

.pill {
  background-color: var(--pill-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-size: 0.9rem;
}

.pill:hover {
  background-color: var(--pill-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.message {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1rem;
  max-width: 800px;
}

.message-ai {
  background-color: var(--message-ai-bg);
}

.message-user {
  background-color: var(--message-user-bg);
  margin-left: auto;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-ai {
  background-color: var(--primary);
}

.message.message-user {
  width: auto;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.message-user .message-content {
  background-color: var(--slightly-lighter);
  border-radius: 1rem;
  padding: 1rem;
}

.message-content {
  flex: 1;
  line-height: 1.5;
}

.input-area {
  padding: 1rem;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.input-container {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--input-bg);
  display: flex;
  align-items: flex-end;
}

textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  resize: none;
  padding: 1rem 3rem 1rem 1rem;
  max-height: 200px;
  outline: none;
  font-size: 1rem;
  line-height: 1.5;
}

#sendBtn {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sendBtn:hover {
  background-color: var(--primary-dark);
  color: white;
}

.disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  display: none;
}

.modal-content {
  background-color: var(--sidebar-bg);
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 500px;
}

.modal h2 {
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 1rem;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal-buttons button {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

#saveSettings {
  background-color: var(--primary);
  color: white;
}

#saveSettings:hover {
  background-color: var(--primary-dark);
}

#closeSettings {
  background-color: transparent;
  color: var(--text-primary);
}

#closeSettings:hover {
  background-color: #2a2b32;
}

.regen-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  align-self: flex-end;
}

.message-user:hover .regen-btn {
  opacity: 0.6;
}

.message-user .regen-btn:hover {
  opacity: 1;
  color: var(--primary);
}

.speak-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  align-self: flex-end;
}

.message-assistant:hover .speak-btn {
  opacity: 0.6;
}

.message-assistant .speak-btn:hover {
  opacity: 1;
  color: var(--primary);
}

.speak-btn:disabled {
  cursor: default;
}

/* Loading indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

.thinking-block {
  max-width: 800px;
  padding: 0.5rem 1rem;
}

.thinking-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--pill-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.thinking-bar:hover {
  background: var(--pill-hover);
}

.thinking-bar .fa-brain {
  color: var(--primary);
  font-size: 0.9rem;
}

.thinking-label {
  flex: 1;
  transition: opacity 0.3s ease;
}

.thinking-label.fade {
  opacity: 0;
}

.thinking-tokens {
  font-size: 0.75rem;
  opacity: 0.7;
}

.toggle-icon {
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.thinking-content {
  display: none;
  max-height: 300px;
  overflow-y: auto;
  background: var(--slightly-lighter);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.thinking-content.open {
  display: block;
}

.thinking-text {
  font-family: monospace;
}

.survey-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.survey-overlay.open {
  display: flex;
}

.survey-modal {
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
}

.survey-question {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.survey-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.survey-buttons button {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.75rem 0.5rem;
  flex: 1;
  font-size: 1rem;
  line-height: 1.2;
  transition: border-color 0.2s, background 0.2s;
}

.survey-buttons button:hover {
  border-color: var(--primary);
  background: var(--slightly-lighter);
}

.survey-buttons button small {
  font-size: 0.65rem;
  opacity: 0.7;
}

.survey-thanks {
  font-size: 1rem;
  color: var(--primary);
  margin-top: 1rem;
  display: none;
}

.survey-thanks.show {
  display: block;
}

.hamburger-menu {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    overflow-x: hidden; /* Prevent horizontal scrollbar */
  }

  .input-area {
    height: 11rem;
  }
  .hamburger-menu {
    display: block;
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 101;
  }

  .sidebar {
    position: absolute;
    left: -260px;
    z-index: 100;
    height: 100%;
    transition: transform 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); /* Add a shadow */
  }

  .sidebar.active {
    transform: translateX(260px);
  }

  .chat-container {
    width: 100%; /* Make chat container take full width */
  }

  .chat-header {
    justify-content: center;
  }

  .pill-container {
    grid-template-columns: 1fr;
  }
}
