.chat-panel {
  position: fixed;
  top: 80px;
  right: 20px;
  bottom: 20px;
  width: 690px;
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  border-radius: 6px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: width 0s, opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.chat-panel.no-animation {
  transition: none;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chat-panel.sidebar-collapsed {
  width: 450px;
}

.chat-panel.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-panel-header {
  background: #f5f5f5;
  border-bottom: 1px solid #dbdbdb;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  border-radius: 6px 6px 0 0;
}

.chat-panel-header .title {
  color: #363636;
}

.chat-panel-body {
  flex: 1;
  background: #f5f5f5;
  min-height: 300px;
  display: flex;
  position: relative;
}

.chat-sidebar {
  width: 240px;
  background: white;
  border-right: 1px solid #dbdbdb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  transition: width 0s, border 0s;
}

.chat-sidebar.is-hidden {
  width: 0;
  border-right: none;
}

.chat-sidebar-toggle {
  position: absolute;
  left: 228px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: white;
  border: 1px solid #dbdbdb;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #7a7a7a;
  z-index: 10;
  transition: left 0s;
}

.chat-sidebar-toggle:hover {
  background: #f5f5f5;
  color: #363636;
}

.chat-sidebar-toggle svg {
  transition: transform 0.2s ease;
}

.chat-panel.sidebar-collapsed .chat-sidebar-toggle {
  left: -12px;
}

.chat-panel.sidebar-collapsed .chat-sidebar-toggle svg {
  transform: rotate(180deg);
}

.chat-sidebar-header {
  padding: 12px;
  border-bottom: 1px solid #dbdbdb;
  overflow: hidden;
}

.chat-conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-conversation-item {
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
  position: relative;
}

.chat-conversation-item:hover {
  background: #f5f5f5;
}

.chat-conversation-item.is-active {
  background: #eff5fb;
  border-color: #3273dc;
}

.chat-conversation-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #363636;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conversation-meta {
  font-size: 0.75rem;
  color: #7a7a7a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-conversation-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.chat-conversation-item:hover .chat-conversation-delete {
  opacity: 1;
}

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

.chat-panel-footer {
  padding: 1.25rem;
  border-top: 1px solid #dbdbdb;
  background: white;
  flex-shrink: 0;
  border-radius: 0 0 6px 6px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-messages.no-animation .chat-message {
  animation: none;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.chat-message-content {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  word-wrap: break-word;
  line-height: 1.5;
}

.chat-message.user .chat-message-content {
  background: #3273dc;
  color: white;
  border: 1px solid #2366d1;
}

.chat-message.assistant .chat-message-content {
  background: transparent;
  color: #363636;
  border: none;
  padding-left: 0;
}

/* Markdown element styles scoped to assistant bubbles */
.chat-message.assistant .chat-message-content p,
.chat-message.status .chat-message-content p {
  margin-bottom: 0.5rem;
}
.chat-message.assistant .chat-message-content p:last-child,
.chat-message.status .chat-message-content p:last-child {
  margin-bottom: 0;
}
.chat-message.assistant .chat-message-content ul,
.chat-message.assistant .chat-message-content ol {
  margin: 0.4rem 0 0.4rem 1.25rem;
  padding: 0;
}
.chat-message.assistant .chat-message-content li {
  margin-bottom: 0.2rem;
}
.chat-message.assistant .chat-message-content strong {
  font-weight: 600;
}
.chat-message.assistant .chat-message-content code {
  background: #f0f0f0;
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-size: 0.875em;
  font-family: monospace;
}
.chat-message.assistant .chat-message-content h1,
.chat-message.assistant .chat-message-content h2,
.chat-message.assistant .chat-message-content h3 {
  font-weight: 600;
  margin: 0.6rem 0 0.3rem;
  line-height: 1.3;
}
.chat-message.assistant .chat-message-content h1 { font-size: 1.1rem; }
.chat-message.assistant .chat-message-content h2 { font-size: 1rem; }
.chat-message.assistant .chat-message-content h3 { font-size: 0.95rem; }

.chat-message.assistant .chat-message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.6rem 0;
  font-size: 0.875rem;
}
.chat-message.assistant .chat-message-content th,
.chat-message.assistant .chat-message-content td {
  border: 1px solid #dbdbdb;
  padding: 0.4rem 0.65rem;
  text-align: left;
  vertical-align: top;
}
.chat-message.assistant .chat-message-content th {
  background: #f5f5f5;
  font-weight: 600;
}
.chat-message.assistant .chat-message-content tr:nth-child(even) td {
  background: #fafafa;
}

.chat-message-time {
  font-size: 0.75rem;
  color: #7a7a7a;
  padding: 0 0.5rem;
}

.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.15);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.chat-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.chat-typing {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7a7a7a;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Pending message styling */
.chat-message-content.is-pending {
  opacity: 0.8;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  padding: 0.75rem 1rem;
}

.chat-message.assistant .chat-message-content.is-pending {
  padding: 0.75rem 1rem;
}

/* Mobile responsive */
@media screen and (max-width: 768px) {
  .chat-panel {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100vh - 30px);
  }
}
