/* Base styles for code blocks */
pre[class*="language-"],
code[class*="language-"] {
  color: #abb2bf;
  font-family: var(--font-mono), Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.5;
  tab-size: 4;
  hyphens: none;
}

/* Line numbers */
.line-numbers .line-numbers-rows {
  position: absolute;
  pointer-events: none;
  top: 1em;
  left: 0.75em;
  width: 3em;
  letter-spacing: -1px;
  border-right: 1px solid #404859;
  user-select: none;
}

.line-numbers-rows > span {
  display: block;
  counter-increment: linenumber;
  pointer-events: none;
}

.line-numbers-rows > span:before {
  content: counter(linenumber);
  color: #404859;
  display: block;
  padding-right: 0.8em;
  text-align: right;
}

/* Inline code */
:not(pre) > code {
  background: rgba(115, 125, 140, 0.17);
  color: #abb2bf;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  white-space: normal;
}

/* Scrollbars */
pre[class*="language-"]::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

pre[class*="language-"]::-webkit-scrollbar-track {
  background: transparent;
}

pre[class*="language-"]::-webkit-scrollbar-thumb {
  background-color: #404859;
  border: 4px solid transparent;
  background-clip: content-box;
  border-radius: 7px;
}

pre[class*="language-"]::-webkit-scrollbar-corner {
  background: transparent;
}

/* Selection */
pre[class*="language-"] ::selection,
code[class*="language-"] ::selection {
  background: rgba(171, 178, 191, 0.3);
}

/* Focus styles */
.code-block:focus-within {
  outline: 2px solid #61afef;
  outline-offset: 2px;
}

/* Copy button animation */
.copy-button {
  transition: all 0.2s ease;
}

.copy-button:hover {
  transform: scale(1.05);
}

/* Language badge */
.language-badge {
  font-size: 0.75rem;
  color: #abb2bf;
  background: rgba(115, 125, 140, 0.17);
  padding: 0.25em 0.5em;
  border-radius: 3px;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

/* Show more/less button */
.show-more-button {
  background: linear-gradient(to bottom, transparent, #282c34);
  padding-top: 2rem;
  padding-bottom: 0.5rem;
  text-align: center;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

/* Line highlight */
.highlight-line {
  background-color: rgba(97, 175, 239, 0.1);
  margin: 0 -1rem;
  padding: 0 1rem;
  border-left: 2px solid #61afef;
}

/* Diff highlighting */
.token.deleted {
  background-color: rgba(224, 108, 117, 0.1);
  color: #e06c75;
}

.token.inserted {
  background-color: rgba(152, 195, 121, 0.1);
  color: #98c379;
}

/* Error and warning highlighting */
.error-line {
  background-color: rgba(224, 108, 117, 0.1);
  border-left: 2px solid #e06c75;
}

.warning-line {
  background-color: rgba(229, 192, 123, 0.1);
  border-left: 2px solid #e5c07b;
}

/* Token colors for different themes */
.theme-claude {
  --syntax-comment: #7f848e;
  --syntax-keyword: #c678dd;
  --syntax-function: #61afef;
  --syntax-string: #98c379;
  --syntax-number: #d19a66;
  --syntax-class: #e5c07b;
  --syntax-variable: #e06c75;
}

.theme-dark {
  --syntax-comment: #6a737d;
  --syntax-keyword: #ff79c6;
  --syntax-function: #66d9ef;
  --syntax-string: #f1fa8c;
  --syntax-number: #bd93f9;
  --syntax-class: #8be9fd;
  --syntax-variable: #50fa7b;
}

/* Loading animation for language detection */
.language-detecting {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Code block toolbar */
.code-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(40, 44, 52, 0.8);
  border-bottom: 1px solid #404859;
}

.toolbar-button {
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  background: rgba(115, 125, 140, 0.17);
  color: #abb2bf;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.toolbar-button:hover {
  background: rgba(115, 125, 140, 0.3);
}