:root {
  --md-primary-fg-color: #1e40af;
  --md-primary-fg-color--light: #3b82f6;
  --md-primary-fg-color--dark: #1e3a8a;
  --md-accent-fg-color: #06b6d4;
}

/* Fix code block styling and overflow issues */
.highlight,
.codehilite {
    background-color: #1e1e1e !important;
    border-radius: 8px !important;
    margin: 1.5em 0 !important;
    padding: 1.5em 0 !important;
    overflow: hidden !important;
    border: 1px solid #333 !important;
    position: relative !important;
    clear: both !important;
}

.highlight pre,
.codehilite pre {
    background-color: #1e1e1e !important;
    color: #d4d4d4 !important;
    padding: 1rem !important;
    margin: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: pre !important;
    word-wrap: normal !important;
    word-break: normal !important;
    line-height: 1.5 !important;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', Consolas, monospace !important;
    font-size: 0.875rem !important;
    border: none !important;
    border-radius: 0 !important;
}

.highlight code,
.codehilite code {
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    white-space: pre !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    color: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
}

/* Fix for consecutive code blocks */
.highlight + .highlight,
.codehilite + .codehilite {
    margin-top: 2rem !important;
}

/* Fix for code blocks inside other elements */
.md-typeset .highlight,
.md-typeset .codehilite {
    margin: 1.5em 0 !important;
    clear: both !important;
}

/* Ensure code blocks don't inherit text styles from parent elements */
.highlight *,
.codehilite * {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', Consolas, monospace !important;
}

/* Fix inline code */
code:not(.codehilite code):not(.highlight code) {
    background-color: rgba(175, 184, 193, 0.2) !important;
    padding: 0.125rem 0.25rem !important;
    border-radius: 4px !important;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', Consolas, monospace !important;
    font-size: 0.875em !important;
    color: #0C8DFF !important;
}

/* Mermaid diagram styling */
.mermaid {
    text-align: center !important;
    margin: 2rem 0 !important;
    background: white !important;
    border-radius: 8px !important;
    padding: 1rem !important;
    border: 1px solid #e5e7eb !important;
    overflow: visible !important;
}

/* Dark mode adjustments */
[data-theme="dark"] .mermaid {
    background: #1f2937 !important;
    border-color: #374151 !important;
    color: #f9fafb !important;
}

[data-theme="dark"] code:not(.codehilite code):not(.highlight code) {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #fbbf24 !important;
}

/* Header links */
.headerlink {
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-left: 0.5rem;
  font-size: 0.8em;
  text-decoration: none;
}

h1:hover .headerlink,
h2:hover .headerlink,
h3:hover .headerlink,
h4:hover .headerlink,
h5:hover .headerlink,
h6:hover .headerlink {
  opacity: 1;
}

/* Custom admonition styling */
.md-typeset .admonition {
  border-radius: 8px;
  border-left: 4px solid var(--md-accent-fg-color);
}

/* Custom table styling */
.md-typeset table:not([class]) {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid grey;
}

.md-typeset table:not([class]) th {
  background-color: grey;
}

/* Header styling */
.md-header__title {
  font-weight: 600;
}

/* Button styling */
.md-button {
  border-radius: 6px;
  transition: all 0.2s ease;
}

.md-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Fix potential conflicts */
.highlight,
.codehilite {
    z-index: 1;
    position: relative;
}

/* Ensure proper spacing in content */
.md-content {
    overflow-x: hidden;
}

.md-content__inner {
    overflow-x: hidden;
}

span.filename {
    margin-left: 1em;
    color: #E88F89 !important;
}