.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--vscode-editor-background);
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--vscode-editorGroup-border);
  background-color: var(--vscode-sideBar-background);
}

.chat-panel-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--vscode-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.chat-panel-model {
  position: relative;
}

.model-selector-button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
  background: transparent;
  border: 1px solid var(--vscode-input-border);
  border-radius: 4px;
  cursor: pointer;
}

.model-selector-button:hover {
  background-color: var(--vscode-list-hoverBackground);
}

.model-dropdown-icon {
  font-size: 10px;
}

.model-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 160px;
  max-height: 300px;
  overflow-y: auto;
  background-color: var(--vscode-dropdown-background);
  border: 1px solid var(--vscode-dropdown-border);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 100;
}

.model-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  text-align: left;
  color: var(--vscode-foreground);
  background: transparent;
  border: none;
  cursor: pointer;
}

.model-option:hover {
  background-color: var(--vscode-list-hoverBackground);
}

.model-option.active {
  background-color: var(--vscode-list-activeSelectionBackground);
  color: var(--vscode-list-activeSelectionForeground);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  min-height: 100%;
  box-sizing: border-box;
  color: var(--vscode-descriptionForeground);
}

.chat-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.chat-welcome h2 {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 500;
  color: var(--vscode-foreground);
}

.chat-welcome p {
  margin: 0 0 12px 0;
  font-size: 14px;
}

.chat-welcome ul {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.chat-welcome li {
  padding: 4px 0;
  font-size: 13px;
}

.chat-welcome li::before {
  content: '•';
  margin-right: 8px;
  color: var(--vscode-textLink-foreground);
}

.chat-message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-message-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: 50%;
  background-color: var(--vscode-input-background);
}

.chat-message.user .chat-message-avatar {
  background-color: var(--vscode-button-background);
}

.chat-message-content {
  max-width: 80%;
  min-width: 100px;
}

.chat-message.user .chat-message-content {
  text-align: right;
}

.chat-message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-message.user .chat-message-header {
  justify-content: flex-end;
}

.chat-message-role {
  font-size: 12px;
  font-weight: 500;
  color: var(--vscode-descriptionForeground);
}

.streaming-indicator {
  color: var(--vscode-button-background);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.chat-message-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--vscode-foreground);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 10px 14px;
  border-radius: 12px;
  background-color: var(--vscode-input-background);
  user-select: text;
  cursor: text;
}

.chat-message.user .chat-message-text {
  background-color: var(--vscode-button-background);
  color: var(--vscode-button-foreground);
  border-radius: 12px 12px 2px 12px;
}

.chat-message.assistant .chat-message-text {
  border-radius: 12px 12px 12px 2px;
}

.chat-message.streaming .chat-message-text {
  background: linear-gradient(
    90deg,
    var(--vscode-input-background) 0%,
    var(--vscode-list-hoverBackground) 50%,
    var(--vscode-input-background) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.chat-thinking-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.chat-thinking-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--vscode-descriptionForeground);
  animation: bounce 1.4s infinite ease-in-out both;
}

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

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

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

.chat-input-container {
  padding: 16px;
  border-top: 1px solid var(--vscode-editorGroup-border);
  background-color: var(--vscode-sideBar-background);
}

.chat-abort-button {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 8px;
  font-size: 13px;
  color: var(--vscode-errorForeground);
  background-color: transparent;
  border: 1px solid var(--vscode-errorForeground);
  border-radius: 4px;
  cursor: pointer;
}

.chat-abort-button:hover {
  background-color: var(--vscode-inputValidation-errorBackground);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background-color: var(--vscode-input-background);
  border: 1px solid var(--vscode-input-border);
  border-radius: 8px;
  padding: 8px;
}

.chat-input-wrapper:focus-within {
  border-color: var(--vscode-focusBorder);
}

.chat-input {
  flex: 1;
  min-height: 24px;
  max-height: 200px;
  padding: 0;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--vscode-input-foreground);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
}

.chat-input::placeholder {
  color: var(--vscode-input-placeholderForeground);
}

.chat-send-button {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--vscode-button-foreground);
  background-color: var(--vscode-button-background);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s;
}

.chat-send-button:hover:not(:disabled) {
  background-color: var(--vscode-button-hoverBackground);
}

.chat-send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* API Key form */
.api-key-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  width: 100%;
  max-width: 400px;
}

.api-key-input {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--vscode-input-foreground);
  background-color: var(--vscode-input-background);
  border: 1px solid var(--vscode-input-border);
  border-radius: 6px;
  outline: none;
}

.api-key-input:focus {
  border-color: var(--vscode-focusBorder);
}

.api-key-submit {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--vscode-button-foreground);
  background-color: var(--vscode-button-background);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.api-key-submit:hover:not(:disabled) {
  background-color: var(--vscode-button-hoverBackground);
}

.api-key-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.api-key-error {
  font-size: 13px;
  color: var(--vscode-errorForeground);
  margin-top: 4px;
}

/* Markdown content styling for AI responses */
.chat-message.assistant .chat-message-text {
  white-space: normal;
}

.chat-message-text p {
  margin: 0 0 0.5em 0;
}

.chat-message-text p:last-child {
  margin-bottom: 0;
}

.chat-message-text h1,
.chat-message-text h2,
.chat-message-text h3,
.chat-message-text h4 {
  margin: 0.75em 0 0.5em 0;
  font-weight: 600;
  color: var(--vscode-foreground);
}

.chat-message-text h1:first-child,
.chat-message-text h2:first-child,
.chat-message-text h3:first-child {
  margin-top: 0;
}

.chat-message-text h1 { font-size: 1.3em; }
.chat-message-text h2 { font-size: 1.2em; }
.chat-message-text h3 { font-size: 1.1em; }
.chat-message-text h4 { font-size: 1em; }

.chat-message-text ul,
.chat-message-text ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.chat-message-text li {
  margin: 0.25em 0;
}

.chat-message-text code {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background-color: var(--vscode-textCodeBlock-background, rgba(0, 0, 0, 0.2));
  border-radius: 3px;
}

.chat-message-text pre {
  margin: 0.75em 0;
  padding: 12px;
  overflow-x: auto;
  background-color: var(--vscode-textCodeBlock-background, rgba(0, 0, 0, 0.2));
  border-radius: 6px;
}

.chat-message-text pre code {
  padding: 0;
  background: transparent;
  font-size: 0.85em;
  line-height: 1.4;
}

.chat-message-text table {
  width: 100%;
  margin: 0.75em 0;
  border-collapse: collapse;
  font-size: 0.9em;
}

.chat-message-text th,
.chat-message-text td {
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--vscode-editorGroup-border);
}

.chat-message-text th {
  font-weight: 600;
  background-color: var(--vscode-list-hoverBackground);
}

.chat-message-text tr:nth-child(even) {
  background-color: var(--vscode-list-hoverBackground);
}

.chat-message-text blockquote {
  margin: 0.75em 0;
  padding: 0.5em 1em;
  border-left: 3px solid var(--vscode-textLink-foreground);
  background-color: var(--vscode-textBlockQuote-background, rgba(0, 0, 0, 0.1));
  color: var(--vscode-descriptionForeground);
}

.chat-message-text blockquote p {
  margin: 0;
}

.chat-message-text a {
  color: var(--vscode-textLink-foreground);
  text-decoration: none;
}

.chat-message-text a:hover {
  text-decoration: underline;
}

.chat-message-text hr {
  margin: 1em 0;
  border: none;
  border-top: 1px solid var(--vscode-editorGroup-border);
}

.chat-message-text strong {
  font-weight: 600;
}

.chat-message-text em {
  font-style: italic;
}

/* Tool usage markers */
.tool-markers {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background-color: var(--vscode-textBlockQuote-background, rgba(127, 127, 127, 0.1));
  border-left: 3px solid var(--vscode-textLink-foreground, #3794ff);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
}

.tool-marker {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--vscode-descriptionForeground);
  line-height: 1.4;
}

.tool-marker.pending .tool-marker-icon {
  color: var(--vscode-charts-yellow, #cca700);
  animation: tool-pulse 1.2s ease-in-out infinite;
}

.tool-marker.completed .tool-marker-icon {
  color: var(--vscode-charts-green, #89d185);
}

.tool-marker-name {
  font-family: var(--vscode-editor-font-family, monospace);
  font-weight: 600;
  color: var(--vscode-foreground);
}

.tool-marker-args {
  color: var(--vscode-descriptionForeground);
  font-family: var(--vscode-editor-font-family, monospace);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

@keyframes tool-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
