:root {
  --primary: #0195c1;
  --primary-dark: #0cf;
  --sidebar-bg: #202123;
  --chat-bg: #343541;
  --message-ai-bg: #444654;
  --message-user-bg: #343541;
  --text-primary: #ececf1;
  --text-secondary: #acacbe;
  --border-color: #4d4d4f;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 0px;
}

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

body {
  font-family: 'Inter', Arial, sans-serif;
  background-color: var(--chat-bg);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

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

a:visited {
  color: var(--text-secondary);
}

a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

a:active {
  color: var(--primary);
  text-decoration: underline;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  border-right: 1px solid var(--border-color);
  position: relative;
  z-index: 100;
  overflow: hidden;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
  width: var(--sidebar-collapsed-width);
  border-right: none;
}

.sidebar-header {
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.logo-placeholder {
  width: 40px;
  height: 40px;
  background-color: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  /* font-weight: bold; */
}

.new-chat-btn {
  width: 100%;
  padding: 10px;
  margin: 0;
  border-radius: 20px;
  background-color: var(--sidebar-bg);
  color: white;
  border: 2px solid #444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.new-chat-btn:hover {
  background-color: var(--primary-dark);
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  transition: all 0.3s ease;
  width: calc(100% - var(--sidebar-width));
}

.main-content.expanded {
  width: 100%;
}

.top-bar {
  padding: 15px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--chat-bg);
  z-index: 10;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  margin-right: 15px;
  z-index: 10;
}

.chat-title {
  /* font-weight: 600; */
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.message {
  display: flex;
  gap: 20px;
  width: 100%;
  padding: 20px;
  border-radius: 8px;
  box-sizing: border-box;
}

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

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

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

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

.avatar-user {
  background-color: #6e6e80;
}

.message-content {
  flex: 1;
  padding-top: 5px;
  width: 100%;
  overflow-x: auto;
}

.message-text {
  line-height: 1.5;
  white-space: pre-wrap;
  position: relative;
  overflow-wrap: break-word;
  word-wrap: break-word;
  max-width: 100%;
}

/* Code block styling */
.message-text pre[class*="language-"] {
  background-color: #2d2d2d;
  border-radius: 8px;
  margin: 10px 0;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  position: relative;
  padding: 1.5em 1em 1em 1em;
  white-space: pre;
  word-wrap: normal;
}

.message-text code[class*="language-"] {
  font-family: 'Courier New', Courier, monospace;
  white-space: pre;
  display: block;
  tab-size: 4;
  word-wrap: normal;
  max-width: 100%;
  overflow-x: auto;
}

.copy-btn-text {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(255, 255, 255, 0.1); /* Slight background to see it */
  border: 1px solid rgba(255, 255, 255, 0.2); /* Add border for better visibility */
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  
  /* CHANGED: Always visible */
  opacity: 1; 
  z-index: 10;
  transition: background-color 0.2s;
}

.copy-btn-text:hover {
  background-color: rgba(255, 255, 255, 0.3); /* Brighter on hover */
}

pre:hover .copy-btn-text {
  opacity: 1;
}

/* Language label */
.language-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 8px;
  font-size: 0.7rem;
  color: #999;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 0 0 4px 0;
}

/* Input area */
.input-container {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background-color: var(--chat-bg);
}

.input-box {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  width: 100%;
}

.message-input {
  font-family: 'Inter', Arial, sans-serif;
  width: 100%;
  padding: 12px 50px 12px 15px;
  border-radius:25px;
  border: 1px solid var(--border-color);
  background-color: rgba(64, 65, 79, 0.5);
  color: var(--text-primary);
  font-size: 1rem;
  resize: none;
  min-height: 50px;
  max-height: 200px;
}

.message-input:focus {
  outline: none;
  border-color: var(--primary);
}

.send-btn {
  position: absolute;
  right: 22px;
  bottom: 18px;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 1.2rem;
}

.send-btn:disabled {
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* Counters */
.counter-container {
  display: flex;
  justify-content: space-between;
  max-width: 800px;
  margin: 8px auto 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.character-count, .token-count {
  opacity: 0.7;
}

.token-count {
  margin-left: 10px;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 5px;
  padding: 10px;
}

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

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

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Chat History Items */
.chat-item {
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  padding-right: 30px;
}

.chat-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
  background-color: rgba(255, 255, 255, 0.1);
}

.delete-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 2px 5px;
}

.chat-item:hover .delete-btn {
  opacity: 1;
  padding: 8px 10px;
  background-color: #111;
  border-radius: 25px;
}

.delete-btn:hover {
  color: #ff4d4d;
}

.chat-item .chat-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* Responsive adjustments */
@media (max-width: 320px) {
  .message {
    flex-direction: column;
    gap: 10px;
    padding: 15px;
  }
  
  .avatar {
    align-self: flex-start;
  }
  
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
  }
  
  .sidebar.collapsed {
    transform: translateX(-100%);
  }
  
  .main-content {
    width: 100%;
  }
  
  .main-content.expanded {
    width: 100%;
  }
  
  .chat-container {
    padding: 15px 10px;
    max-width: 100%;
  }
  
  .message-text pre {
    padding: 1.5em 1em 1em 1em;
    border-radius: 6px;
  }
  
  .copy-btn-text {
    padding: 3px 6px;
  }
  
  .counter-container {
    flex-direction: column;
    gap: 4px;
  }
  
  .token-count {
    margin-left: 0;
  }
}

@media (max-width: 1200px) {
  .chat-container {
    max-width: 90%;
  }
}