/**
 * GitHub-Flavored Markdown Styles
 * Includes GitHub callouts/admonitions and proper GFM rendering
 */

/* Base markdown body styles */
.markdown-body {
  background-color: var(--bg-tertiary, #0d1117) !important;
  color: var(--text-primary, #e6edf3) !important;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif) !important;
  font-size: 16px;
  line-height: 1.6;
  padding: 2rem;
  border-radius: 8px;
  word-wrap: break-word;
}

/* Headers */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-family: var(--font-mono, "JetBrains Mono", "Fira Code", Consolas, monospace) !important;
  color: var(--accent-green, #58a6ff) !important;
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
  border-bottom: 1px solid var(--border-color, #21262d);
  padding-bottom: 0.3em;
}

.markdown-body h1 {
  font-size: 2em;
  border-bottom-width: 2px;
}

.markdown-body h2 {
  font-size: 1.5em;
}

.markdown-body h3 {
  font-size: 1.25em;
  border-bottom: none;
}

.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-size: 1em;
  border-bottom: none;
}

/* Paragraphs */
.markdown-body p {
  margin-top: 0;
  margin-bottom: 16px;
}

/* Bold and italic */
.markdown-body strong {
  font-weight: 600;
  color: var(--text-primary, #e6edf3);
}

.markdown-body em {
  font-style: italic;
  color: var(--text-primary, #e6edf3);
}

/* Inline code */
.markdown-body code {
  font-family: var(--font-mono, "JetBrains Mono", "Fira Code", Consolas, monospace) !important;
  background-color: var(--bg-secondary, rgba(110, 118, 129, 0.2)) !important;
  color: var(--accent-yellow, #f0e68c) !important;
  padding: 0.2em 0.4em;
  margin: 0;
  font-size: 85%;
  border-radius: 6px;
}

/* Code blocks */
.markdown-body pre {
  background-color: var(--bg-secondary, #161b22) !important;
  border-radius: 6px;
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  margin-bottom: 16px;
}

.markdown-body pre code {
  background-color: transparent !important;
  padding: 0;
  margin: 0;
  font-size: 100%;
  word-break: normal;
  white-space: pre;
  border: 0;
  display: inline;
  max-width: auto;
  overflow: visible;
  line-height: inherit;
}

/* Links */
.markdown-body a {
  color: var(--accent-green, #58a6ff) !important;
  text-decoration: none;
  font-weight: 500;
}

.markdown-body a:hover {
  text-decoration: underline;
}

/* Images */
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
  display: block;
  margin: 16px auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
  margin-top: 0;
  margin-bottom: 16px;
  padding-left: 2em;
}

.markdown-body li {
  margin-top: 0.25em;
}

.markdown-body li + li {
  margin-top: 0.25em;
}

/* Tables */
.markdown-body table {
  border-spacing: 0;
  border-collapse: collapse;
  display: block;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  margin-bottom: 16px;
}

.markdown-body table th,
.markdown-body table td {
  padding: 6px 13px;
  border: 1px solid var(--border-color, #30363d);
}

.markdown-body table th {
  font-weight: 600;
  background-color: var(--bg-secondary, #161b22);
}

.markdown-body table tr {
  background-color: var(--bg-primary, #0d1117);
  border-top: 1px solid var(--border-color, #30363d);
}

.markdown-body table tr:nth-child(2n) {
  background-color: var(--bg-secondary, rgba(110, 118, 129, 0.05));
}

/* Regular blockquotes (non-callout) */
.markdown-body blockquote {
  margin: 0 0 16px 0;
  padding: 0 1em;
  color: var(--text-secondary, #8b949e) !important;
  border-left: 4px solid var(--accent-green, #30363d) !important;
  background-color: rgba(110, 118, 129, 0.05);
  border-radius: 0 4px 4px 0;
}

.markdown-body blockquote > :first-child {
  margin-top: 0;
}

.markdown-body blockquote > :last-child {
  margin-bottom: 0;
}

/* Horizontal rules */
.markdown-body hr {
  height: 2px;
  padding: 0;
  margin: 24px 0;
  background-color: var(--border-color, #21262d);
  border: 0;
}

/* ========================================
   GitHub-Style Callouts/Admonitions
   ======================================== */

.markdown-callout {
  margin: 16px 0;
  padding: 16px;
  border-left: 4px solid;
  border-radius: 6px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.03), transparent);
  position: relative;
}

.markdown-callout-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 8px;
}

.markdown-callout-icon {
  font-size: 1.2em;
  line-height: 1;
}

.markdown-callout-title {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85em;
  letter-spacing: 0.05em;
}

.markdown-callout-content {
  color: var(--text-primary, #e6edf3);
}

.markdown-callout-content p:last-child {
  margin-bottom: 0;
}

/* Note - Blue */
.markdown-callout-note {
  border-left-color: #3b82f6;
  background: linear-gradient(to right, rgba(59, 130, 246, 0.1), transparent);
}

.markdown-callout-note .markdown-callout-header {
  color: #60a5fa;
}

/* Tip - Green */
.markdown-callout-tip {
  border-left-color: #22c55e;
  background: linear-gradient(to right, rgba(34, 197, 94, 0.1), transparent);
}

.markdown-callout-tip .markdown-callout-header {
  color: #4ade80;
}

/* Important - Purple */
.markdown-callout-important {
  border-left-color: #a855f7;
  background: linear-gradient(to right, rgba(168, 85, 247, 0.1), transparent);
}

.markdown-callout-important .markdown-callout-header {
  color: #c084fc;
}

/* Warning - Yellow/Orange */
.markdown-callout-warning {
  border-left-color: #f59e0b;
  background: linear-gradient(to right, rgba(245, 158, 11, 0.1), transparent);
}

.markdown-callout-warning .markdown-callout-header {
  color: #fbbf24;
}

/* Caution - Red */
.markdown-callout-caution {
  border-left-color: #ef4444;
  background: linear-gradient(to right, rgba(239, 68, 68, 0.1), transparent);
}

.markdown-callout-caution .markdown-callout-header {
  color: #f87171;
}

/* ========================================
   Syntax Highlighting (GitHub Dark Theme)
   ======================================== */

.hljs {
  color: #e6edf3;
  background: #0d1117;
}

.hljs-comment,
.hljs-quote {
  color: #8b949e;
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
  color: #ff7b72;
}

.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr {
  color: #79c0ff;
}

.hljs-string,
.hljs-doctag {
  color: #a5d6ff;
}

.hljs-title,
.hljs-section,
.hljs-selector-id {
  color: #d2a8ff;
  font-weight: bold;
}

.hljs-type,
.hljs-class .hljs-title {
  color: #ffa657;
}

.hljs-tag,
.hljs-name,
.hljs-attribute {
  color: #7ee787;
}

.hljs-regexp,
.hljs-link {
  color: #a5d6ff;
}

.hljs-symbol,
.hljs-bullet {
  color: #79c0ff;
}

.hljs-built_in,
.hljs-builtin-name {
  color: #ffa657;
}

.hljs-meta {
  color: #8b949e;
}

.hljs-deletion {
  background-color: #490202;
  color: #ffebe9;
}

.hljs-addition {
  background-color: #04260f;
  color: #aff5b4;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: bold;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
  .markdown-body {
    padding: 1rem;
    font-size: 14px;
  }

  .markdown-body h1 {
    font-size: 1.75em;
  }

  .markdown-body h2 {
    font-size: 1.4em;
  }

  .markdown-callout {
    padding: 12px;
  }
}
