/* ============================================
   PROFESSIONAL CODE BLOCK STYLING
   Tech Blog Standard - With Syntax Highlighting
   ============================================ */

/* Base Code Block Container */
.post-content pre,
.blog-post-content pre {
  position: relative;
  background: #1e1e1e !important;
  border: 1px solid #333;
  border-radius: 12px;
  margin: 2rem 0;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}

.post-content pre code,
.blog-post-content pre code {
  display: block;
  padding: 1.5rem;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 14px;
  color: #d4d4d4;
  background: transparent !important;
  counter-reset: line;
}

/* Language Badge */
.post-content pre[class*="language-"]::before,
.blog-post-content pre[class*="language-"]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.375rem 0.75rem;
  background: #252525;
  color: #888;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom-left-radius: 6px;
  border-top-right-radius: 12px;
  z-index: 2;
}

/* Language-specific badge colors */
.post-content pre[class*="language-javascript"]::before,
.post-content pre[class*="language-js"]::before {
  content: "JavaScript";
  background: #f7df1e;
  color: #000;
}

.post-content pre[class*="language-typescript"]::before,
.post-content pre[class*="language-ts"]::before {
  content: "TypeScript";
  background: #3178c6;
  color: #fff;
}

.post-content pre[class*="language-python"]::before,
.post-content pre[class*="language-py"]::before {
  content: "Python";
  background: #3776ab;
  color: #fff;
}

.post-content pre[class*="language-json"]::before {
  content: "JSON";
  background: #292929;
  color: #f3f3f3;
}

.post-content pre[class*="language-bash"]::before,
.post-content pre[class*="language-shell"]::before {
  content: "Shell";
  background: #4eaa25;
  color: #fff;
}

.post-content pre[class*="language-html"]::before {
  content: "HTML";
  background: #e34c26;
  color: #fff;
}

.post-content pre[class*="language-css"]::before {
  content: "CSS";
  background: #264de4;
  color: #fff;
}

.post-content pre[class*="language-sql"]::before {
  content: "SQL";
  background: #e38c00;
  color: #fff;
}

.post-content pre[class*="language-yaml"]::before,
.post-content pre[class*="language-yml"]::before {
  content: "YAML";
  background: #cb171e;
  color: #fff;
}

.post-content pre[class*="language-go"]::before {
  content: "Go";
  background: #00add8;
  color: #fff;
}

.post-content pre[class*="language-rust"]::before {
  content: "Rust";
  background: #ce422b;
  color: #fff;
}

.post-content pre[class*="language-php"]::before {
  content: "PHP";
  background: #777bb4;
  color: #fff;
}

.post-content pre[class*="language-ruby"]::before,
.post-content pre[class*="language-rb"]::before {
  content: "Ruby";
  background: #cc342d;
  color: #fff;
}

/* Copy Button */
.code-block-wrapper {
  position: relative;
}

.copy-code-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #d4d4d4;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 3;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.copy-code-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.copy-code-button:active {
  transform: scale(0.95);
}

.copy-code-button.copied {
  background: #4caf50;
  border-color: #4caf50;
  color: #fff;
}

.copy-code-button svg {
  width: 14px;
  height: 14px;
}

/* Line Numbers (optional enhancement) */
.post-content pre code[data-line-numbers],
.blog-post-content pre code[data-line-numbers] {
  padding-left: 3.5rem;
}

.post-content pre code[data-line-numbers]::before,
.blog-post-content pre code[data-line-numbers]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3rem;
  background: #161616;
  border-right: 1px solid #333;
}

/* Inline Code */
.post-content code,
.blog-post-content code,
:not(pre) > code {
  background: rgba(0, 0, 0, 0.08);
  padding: 0.2em 0.5em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  color: #e01e5a;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-weight: 500;
}

.post-content pre code,
.blog-post-content pre code {
  background: transparent;
  padding: 1.5rem;
  border: none;
  color: #d4d4d4;
  font-weight: normal;
}

/* Syntax Highlighting - VS Code Dark+ Theme */

/* Comments */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6a9955;
  font-style: italic;
}

/* Punctuation */
.token.punctuation {
  color: #d4d4d4;
}

/* Property, tag, constant, symbol, deleted */
.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: #569cd6;
}

/* Boolean, number */
.token.boolean,
.token.number {
  color: #b5cea8;
}

/* Selector, attr-name, string, char, builtin, inserted */
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #ce9178;
}

/* Operator, entity, url, .language-css .string, .style .string, variable */
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
  color: #d4d4d4;
}

/* Atrule, attr-value, function, class-name */
.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
  color: #dcdcaa;
}

/* Keyword */
.token.keyword {
  color: #c586c0;
}

/* Regex, important */
.token.regex,
.token.important {
  color: #d16969;
}

/* Important, bold, italic */
.token.important,
.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}

/* JSON specific */
.language-json .token.property {
  color: #9cdcfe;
}

.language-json .token.string {
  color: #ce9178;
}

.language-json .token.number {
  color: #b5cea8;
}

.language-json .token.boolean {
  color: #569cd6;
}

.language-json .token.null {
  color: #569cd6;
}

/* Shell/Bash specific */
.language-bash .token.function,
.language-shell .token.function {
  color: #dcdcaa;
}

.language-bash .token.parameter,
.language-shell .token.parameter {
  color: #9cdcfe;
}

/* TypeScript/JavaScript specific */
.language-typescript .token.keyword,
.language-javascript .token.keyword,
.language-ts .token.keyword,
.language-js .token.keyword {
  color: #569cd6;
}

.language-typescript .token.class-name,
.language-javascript .token.class-name,
.language-ts .token.class-name,
.language-js .token.class-name {
  color: #4ec9b0;
}

/* Python specific */
.language-python .token.decorator,
.language-py .token.decorator {
  color: #dcdcaa;
}

.language-python .token.builtin,
.language-py .token.builtin {
  color: #4ec9b0;
}

/* Scrollbar styling for code blocks */
.post-content pre code::-webkit-scrollbar,
.blog-post-content pre code::-webkit-scrollbar {
  height: 8px;
}

.post-content pre code::-webkit-scrollbar-track,
.blog-post-content pre code::-webkit-scrollbar-track {
  background: #1e1e1e;
  border-radius: 4px;
}

.post-content pre code::-webkit-scrollbar-thumb,
.blog-post-content pre code::-webkit-scrollbar-thumb {
  background: #424242;
  border-radius: 4px;
}

.post-content pre code::-webkit-scrollbar-thumb:hover,
.blog-post-content pre code::-webkit-scrollbar-thumb:hover {
  background: #4e4e4e;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .post-content pre,
  .blog-post-content pre {
    margin: 1.5rem -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .post-content pre code,
  .blog-post-content pre code {
    padding: 1rem;
    font-size: 13px;
  }

  .copy-code-button {
    top: 0.375rem;
    right: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-size: 11px;
  }

  .post-content pre[class*="language-"]::before,
  .blog-post-content pre[class*="language-"]::before {
    font-size: 10px;
    padding: 0.25rem 0.5rem;
  }
}

/* Dark mode adjustments (if theme supports it) */
@media (prefers-color-scheme: dark) {
  :not(pre) > code {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ff6b9d;
  }
}

/* Highlight specific lines (optional feature) */
.post-content pre code .line-highlight,
.blog-post-content pre code .line-highlight {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid #569cd6;
  display: block;
  margin: 0 -1.5rem;
  padding: 0 1.5rem;
}

/* Command prompt styling for shell examples */
.language-bash code::before,
.language-shell code::before {
  content: "$ ";
  color: #4eaa25;
  user-select: none;
}

/* Code block title (if you add data-title attribute) */
.post-content pre[data-title]::after,
.blog-post-content pre[data-title]::after {
  content: attr(data-title);
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.375rem 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  color: #d4d4d4;
  font-size: 12px;
  font-weight: 500;
  border-bottom-right-radius: 6px;
  border-top-left-radius: 12px;
  z-index: 1;
}
