:root {
  --primary-color: #7c4dff;
  --secondary-color: #b388ff;
  --text-primary: #333;
  --text-secondary: #666;
  --background-primary: #fff;
  --background-secondary: #f5f7fb;
  --background-tertiary: #edf0f7;
  --ai-message-bg: #f0f4ff;
  --user-message-bg: #7c4dff;
  --user-message-text: #fff;
  --border-color: #e0e0e0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --animation-speed: 0.3s;
  --border-radius: 12px;
  --typing-indicator-color: var(--primary-color);
}

.dark-mode {
  --primary-color: #9d74ff;
  --secondary-color: #b388ff;
  --text-primary: #e0e0e0;
  --text-secondary: #aaaaaa;
  --background-primary: #1a1a1a;
  --background-secondary: #252525;
  --background-tertiary: #333333;
  --ai-message-bg: #2d2d3d;
  --user-message-bg: #9d74ff;
  --user-message-text: #fff;
  --border-color: #444;
  --shadow-color: rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  transition: background-color var(--animation-speed),
    color var(--animation-speed);
}

body {
  background-color: var(--background-secondary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.code-copy-container {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

.code-copy-button {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ddd;
  border: none;
  border-radius: 4px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.code-copy-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.code-copy-button.copied {
  background-color: #4caf50;
  color: white;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding: 20px;
}

.app-container {
  display: flex;
  width: 100%;
  max-width: 1200px;
  height: 85vh;
  background-color: var(--background-primary);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 30px var(--shadow-color);
  overflow: hidden;
  position: relative;
}

/* Sidebar Styles */
.sidebar {
  width: 260px;
  background-color: var(--background-tertiary);
  padding: 20px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 24px;
  color: var(--primary-color);
}

.logo i {
  margin-right: 10px;
  font-size: 24px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 12px;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 20px;
  transition: background-color 0.2s, transform 0.1s;
}

.new-chat-btn:hover {
  background-color: var(--secondary-color);
  transform: translateY(-2px);
}

.new-chat-btn i {
  margin-right: 8px;
}

.history-container {
  flex: 1;
  overflow-y: auto;
}

.history-container h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-left: 5px;
}

.chat-history-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--border-radius);
  margin-bottom: 5px;
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
  overflow: visible;
}
#chat-history span {
  white-space: nowrap;
  width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-history-item:hover {
  background-color: var(--background-secondary);
}

.chat-history-item.active {
  background-color: rgba(124, 77, 255, 0.1);
  font-weight: 500;
}

.chat-history-item i {
  margin-right: 10px;
  color: var(--text-secondary);
  font-size: 14px;
}

.settings {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 15px;
}

.settings button {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 10px 5px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border-radius: var(--border-radius);
  font-size: 14px;
  transition: background-color 0.2s;
}

.settings button:hover {
  background-color: var(--background-secondary);
  color: var(--text-primary);
}

.settings button i {
  margin-right: 10px;
  width: 16px;
}

/* Chat Container Styles */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--background-primary);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  border-bottom: 1px solid var(--border-color);
}

.current-chat-title {
  font-weight: 600;
  font-size: 16px;
}

.header-actions button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 5px;
  border-radius: 5px;
  transition: color 0.2s, background-color 0.2s;
}

.header-actions button:hover {
  color: var(--primary-color);
  background-color: var(--background-tertiary);
}

/* Added regenerate, stop, and export button styling */
.header-actions button#regenerate-response {
  margin-right: 5px;
}

/* Chat messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
}

.message {
  display: flex;
  margin: 25px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-size: 15px;
  line-height: 1.5;
}

.message.ai {
  justify-content: flex-start;
}

.message.user {
  justify-content: flex-end;
}

.message.ai .message-content {
  background-color: var(--ai-message-bg);
  color: var(--text-primary);
  border-radius: var(--border-radius);
}

.message.user .message-content {
  background-color: var(--user-message-bg);
  color: var(--user-message-text);
  border-radius: var(--border-radius);
}

.message.ai .message-content h1 {
  font-size: 22px;
  margin: 16px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  color: var(--primary-color);
}

.message.ai .message-content h2 {
  font-size: 18px;
  margin: 14px 0 8px;
  color: var(--text-primary);
}

.message.ai .message-content h3 {
  font-size: 16px;
  margin: 12px 0 6px;
  color: var(--text-primary);
}

/* List styles for better readability */
.message.ai .message-content ul,
.message.ai .message-content ol {
  margin: 8px 0;
  padding-left: 25px;
}

.message.ai .message-content li {
  margin-bottom: 5px;
}

/* Block quote styling */
.message.ai .message-content blockquote {
  border-left: 4px solid var(--primary-color);
  padding: 0 0 0 15px;
  margin: 10px 0;
  color: var(--text-secondary);
}

/* Table styling */
.message.ai .message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 15px 0;
}

.message.ai .message-content th,
.message.ai .message-content td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.message.ai .message-content th {
  background-color: var(--background-tertiary);
  font-weight: 600;
}

/* Links styling */
.message.ai .message-content a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s;
}

.message.ai .message-content a:hover {
  text-decoration: underline;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-addition {
  color: #c792ea;
}

.hljs-number,
.hljs-string,
.hljs-doctag,
.hljs-regexp {
  color: #89ca78;
}

.hljs-title,
.hljs-section,
.hljs-built_in,
.hljs-name {
  color: #e2b93d;
}

.hljs-variable,
.hljs-template-variable,
.hljs-selector-id,
.hljs-class .hljs-title {
  color: #7fdbca;
}

.hljs-type,
.hljs-tag {
  color: #e06c75;
}

/* Language badge for code blocks */
pre::before {
  content: attr(class);
  position: absolute;
  top: 5px;
  left: 12px;
  font-size: 12px;
  color: #aaa;
  display: none;
}

/* Horizontal rule */
.message.ai .message-content hr {
  border: none;
  height: 1px;
  background-color: var(--border-color);
  margin: 15px 0;
}

.typing-indicator {
  display: flex;
  padding: 15px 25px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  margin: 0 2px;
  background-color: var(--typing-indicator-color);
  border-radius: 50%;
  opacity: 0.6;
  animation: typingAnimation 1.5s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0% {
    transform: translateY(0px);
  }
  25% {
    transform: translateY(-5px);
  }
  50% {
    transform: translateY(0px);
  }
}

.input-area {
  padding: 15px 25px 20px;
  border-top: 1px solid var(--border-color);
}

.input-container {
  display: flex;
  position: relative;
  background-color: var(--background-tertiary);
  border-radius: var(--border-radius);
  overflow: hidden;
}

/* Style for file upload button */
#file-upload-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 15px;
  cursor: pointer;
}

#file-upload-button:hover {
  color: var(--primary-color);
}

textarea {
  flex: 1;
  border: none;
  background: none;
  padding: 15px;
  font-size: 15px;
  resize: none;
  max-height: 150px;
  color: var(--text-primary);
  outline: none;
}

textarea::placeholder {
  color: var(--text-secondary);
}

#send-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  width: 40px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.2s;
}

#send-button:hover {
  background-color: var(--secondary-color);
}

.disclaimer {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 10px;
}

/* Pending file preview (for selected file before send) */
#pending-file-preview {
  display: none;
  margin: 10px 0;
}

/* Intro Message Styles */
.intro-message {
  text-align: center;
  max-width: 600px;
  margin: 40px auto;
  padding: 30px;
  background-color: var(--background-primary);
  border-radius: var(--border-radius);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.5s ease-out;
}

.intro-message h1 {
  color: var(--primary-color);
  font-size: 28px;
  margin-bottom: 15px;
}

.intro-message p {
  color: var(--text-secondary);
  margin-bottom: 25px;
  font-size: 16px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.suggestion-chip {
  background-color: var(--background-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion-chip:hover {
  background-color: var(--background-secondary);
  color: var(--primary-color);
  transform: translateY(-2px);
}

/* Code block styling */
pre {
  position: relative;
  background-color: #282c34;
  border-radius: 8px;
  padding: 12px;
  padding-top: 35px;
  overflow-x: auto;
  margin: 10px 0;
  border: 1px solid #3e4451;
  color: #edf0f7;
}

code {
  font-family: "Fira Code", "Courier New", Courier, monospace;
  font-size: 14px;
}

pre code {
  white-space: pre;
  font-size: 14px;
  line-height: 1.5;
}

:not(pre) > code {
  background-color: rgba(125, 125, 125, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--primary-color);
}

/* New CSS for chat options button and menu */
.chat-options-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 5px;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.chat-options-menu {
  position: absolute;
  right: 10px;
  top: 100%;
  background-color: var(--background-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 8px var(--shadow-color);
  z-index: 100;
}

.chat-options-item {
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.chat-options-item:hover {
  background-color: var(--background-secondary);
}
