/* Shared styles for documentation pages */

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;
    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96%;
    --secondary-foreground: 222.2 84% 4.9%;
    --muted: 210 40% 96%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96%;
    --accent-foreground: 222.2 84% 4.9%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 84% 4.9%;
    --radius: 0.5rem;
  }

  .dark {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;
    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;
    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;
    --primary: 210 40% 98%;
    --primary-foreground: 222.2 47.4% 11.2%;
    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;
    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;
    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;
    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 212.7 26.8% 83.9%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #ffffff;
  color: #1a1a1a;
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dark mode styles */
@media (prefers-color-scheme: dark) {
  body {
    background: #111827;
    color: #f3f4f6;
  }
}

:root.dark body {
  background: #111827;
  color: #f3f4f6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }
}

/* Hide the first H1 from markdown content */
/* .prose h1:first-of-type,
main.prose > h1:first-child,
main.prose h1:first-of-type {
  display: none !important;
} */

/* Typography inspired by Humming design */
.prose h1 {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.1;
  color: #000000;
  margin: 80px 0 24px 0;
  letter-spacing: -0.02em;
}

.prose h2 {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  color: #000000;
  margin: 64px 0 16px 0;
  letter-spacing: -0.01em;
}

.prose h3 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
  color: #000000;
  margin: 48px 0 12px 0;
}

.prose h4,
.prose h5,
.prose h6 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  color: #000000;
  margin: 32px 0 8px 0;
}

.prose p {
  font-size: 16px;
  line-height: 1.7;
  color: #4a4a4a;
  margin: 16px 0;
  max-width: 720px;
}

/* Dark mode typography */
:root.dark .prose h1,
:root.dark .prose h2,
:root.dark .prose h3,
:root.dark .prose h4,
:root.dark .prose h5,
:root.dark .prose h6 {
  color: #f9fafb;
}

:root.dark .prose p {
  color: #e5e7eb;
}

.prose ul,
.prose ol {
  margin: 24px 0;
  padding-left: 24px;
  max-width: 720px;
}

.prose li {
  margin: 8px 0;
  color: #4a4a4a;
  line-height: 1.6;
}

:root.dark .prose li {
  color: #e5e7eb;
}

.prose li > ul,
.prose li > ol {
  margin: 8px 0;
}

/* Links */
.prose a {
  color: #0066cc;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.prose a:hover {
  border-bottom-color: #0066cc;
}

:root.dark .prose a {
  color: #60a5fa;
}

:root.dark .prose a:hover {
  border-bottom-color: #60a5fa;
}

/* Shiki syntax highlighting styles */
.prose .astro-code {
  margin: 32px 0;
  padding: 24px;
  border-radius: 12px;
  overflow-x: auto;
  font-family:
    "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New",
    monospace;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid #e2e8f0;
  position: relative;
}

:root.dark .prose .astro-code {
  border-color: #374151;
  background: #1f2937;
}

.prose .astro-code code {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  font-size: inherit !important;
  font-family: inherit !important;
}

/* Dark mode support for Shiki dual themes */
@media (prefers-color-scheme: dark) {
  .prose .astro-code {
    border-color: #374151;
  }
}

/* Dark mode code block styling - override light theme colors */
:root.dark .prose .astro-code {
  background-color: #0d1117 !important;
  color: #e6edf3 !important;
}

:root.dark .prose .astro-code .token.comment {
  color: #8b949e !important;
}

:root.dark .prose .astro-code .token.string {
  color: #a5d6ff !important;
}

:root.dark .prose .astro-code .token.keyword {
  color: #ff7b72 !important;
}

:root.dark .prose .astro-code .token.function {
  color: #d2a8ff !important;
}

:root.dark .prose .astro-code .token.operator {
  color: #ff7b72 !important;
}

:root.dark .prose .astro-code .token.number {
  color: #79c0ff !important;
}

:root.dark .prose .astro-code .token.property {
  color: #79c0ff !important;
}

:root.dark .prose .astro-code .token.variable {
  color: #ffa657 !important;
}

:root.dark .prose .astro-code .token.punctuation {
  color: #e6edf3 !important;
}

:root.dark .prose .astro-code .token.class-name {
  color: #ffa657 !important;
}

:root.dark .prose .astro-code .token.tag {
  color: #7ee787 !important;
}

:root.dark .prose .astro-code .token.attr-name {
  color: #79c0ff !important;
}

:root.dark .prose .astro-code .token.attr-value {
  color: #a5d6ff !important;
}

:root.dark .prose .astro-code .token.boolean {
  color: #79c0ff !important;
}

:root.dark .prose .astro-code .token.constant {
  color: #79c0ff !important;
}

:root.dark .prose .astro-code .token.selector {
  color: #7ee787 !important;
}

/* Additional Shiki-specific dark mode styles */
:root.dark .prose .astro-code [style*="color"] {
  color: #e6edf3 !important;
}

:root.dark .prose .astro-code [style*="color:#24292f"] {
  color: #e6edf3 !important;
}

:root.dark .prose .astro-code [style*="color:#cf222e"] {
  color: #ff7b72 !important;
}

:root.dark .prose .astro-code [style*="color:#0550ae"] {
  color: #79c0ff !important;
}

:root.dark .prose .astro-code [style*="color:#8250df"] {
  color: #d2a8ff !important;
}

:root.dark .prose .astro-code [style*="color:#0969da"] {
  color: #79c0ff !important;
}

:root.dark .prose .astro-code [style*="color:#116329"] {
  color: #7ee787 !important;
}

:root.dark .prose .astro-code [style*="color:#953800"] {
  color: #ffa657 !important;
}

:root.dark .prose .astro-code [style*="color:#6f42c1"] {
  color: #d2a8ff !important;
}

:root.dark .prose .astro-code [style*="color:#0a3069"] {
  color: #79c0ff !important;
}

:root.dark .prose .astro-code [style*="color:#6e7781"] {
  color: #8b949e !important;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 32px 0;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
}

.prose th {
  background: #f8f9fa;
  padding: 16px;
  text-align: left;
  font-weight: 600;
  color: #1a1a1a;
  border-bottom: 1px solid #e9ecef;
  font-size: 14px;
}

.prose td {
  padding: 16px;
  border-bottom: 1px solid #f1f3f4;
  color: #4a4a4a;
  font-size: 14px;
  vertical-align: top;
}

:root.dark .prose table {
  border-color: #374151;
}

:root.dark .prose th {
  background: #374151;
  color: #f9fafb;
  border-bottom-color: #4b5563;
}

:root.dark .prose td {
  border-bottom-color: #374151;
  color: #e5e7eb;
}

.prose tr:last-child td {
  border-bottom: none;
}

/* Images */
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 32px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Badges */
.prose img[src*="shields.io"],
.prose img[src*="badge"],
.prose img[src*="dcbadge"] {
  display: inline;
  margin: 0 4px;
  vertical-align: middle;
  box-shadow: none;
  border-radius: 4px;
}

/* Blockquotes */
.prose blockquote {
  border-left: 4px solid #e9ecef;
  margin: 32px 0;
  padding: 16px 24px;
  background: #f8f9fa;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: #6c757d;
}

:root.dark .prose blockquote {
  border-left-color: #4b5563;
  background: #374151;
  color: #9ca3af;
}

/* Horizontal rules */
.prose hr {
  border: none;
  border-top: 1px solid #e9ecef;
  margin: 64px 0;
}

:root.dark .prose hr {
  border-top-color: #4b5563;
}

/* API Documentation specific styles */
.api-section {
  border-radius: 12px;
  padding: 32px;
  margin: 32px 0;
}

.api-section h2 {
  font-size: 24px;
  font-weight: 600;
  color: #000000;
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-section h2::before {
  content: ">";
  color: #0066cc;
  font-weight: 700;
}

.api-section .description {
  color: #6c757d;
  font-size: 14px;
  margin-bottom: 24px;
  font-style: italic;
}

/* Dark mode API section styles */
:root.dark .api-section h2 {
  color: #f9fafb;
}

:root.dark .api-section h2::before {
  color: #60a5fa;
}

:root.dark .api-section .description {
  color: #9ca3af;
}

/* Additional dark mode text improvements */
:root.dark .prose strong {
  color: #f3f4f6;
}

:root.dark .prose em {
  color: #e5e7eb;
}

:root.dark .prose code:not(pre code) {
  background-color: #374151;
  color: #e5e7eb;
  padding: 0.2em 0.4em;
  border-radius: 0.25em;
  font-size: 0.875em;
}

.prose pre {
  padding: 16px;
  margin: 24px 0;
  border-radius: 6px;
}

:root.dark .prose pre {
  background-color: #1f2937;
  border-color: #374151;
}

/* Fix any remaining low contrast text */
:root.dark .prose * {
  color: inherit;
}

/* Ensure headers are always readable */
:root.dark .prose h1 *,
:root.dark .prose h2 *,
:root.dark .prose h3 *,
:root.dark .prose h4 *,
:root.dark .prose h5 *,
:root.dark .prose h6 * {
  color: #f9fafb;
}

/* Fix any muted text that might be too dark */
:root.dark .prose .text-gray-600,
:root.dark .prose .text-gray-500,
:root.dark .prose .text-gray-400 {
  color: #d1d5db !important;
}

/* Fix any remaining dark text elements */
:root.dark .prose [class*="text-gray-"] {
  color: #e5e7eb;
}

/* Anchor link styles for header permalinks */
.prose .anchor-link {
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  text-decoration: none;
  color: #0066cc;
  font-weight: normal;
}

.prose .anchor-link:hover {
  opacity: 1;
  border-bottom: none;
}

.prose h1:hover .anchor-link,
.prose h2:hover .anchor-link,
.prose h3:hover .anchor-link,
.prose h4:hover .anchor-link,
.prose h5:hover .anchor-link,
.prose h6:hover .anchor-link {
  opacity: 1;
}

.prose .anchor-link .icon {
  width: 16px;
  height: 16px;
  display: inline-block;
}

.prose .anchor-link .icon-link::before {
  content: "🔗";
  font-size: 14px;
}

:root.dark .prose .anchor-link {
  color: #60a5fa;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .prose h1 {
    font-size: 36px;
    margin: 48px 0 16px 0;
  }

  .prose h2 {
    font-size: 28px;
    margin: 40px 0 12px 0;
  }

  .prose h3 {
    font-size: 22px;
    margin: 32px 0 8px 0;
  }

  .prose p,
  .prose ul,
  .prose ol {
    font-size: 15px;
  }

  .prose table {
    font-size: 13px;
  }

  .prose th,
  .prose td {
    padding: 12px 8px;
  }

  .api-section {
    padding: 24px 16px;
    margin: 24px 0;
  }
}

@media (max-width: 480px) {
  /* Mobile table styles - horizontal scroll approach */
  .prose table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin: 24px 0;
  }

  .prose table::-webkit-scrollbar {
    height: 6px;
  }

  .prose table::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
  }

  .prose table::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
  }

  .prose table::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
  }

  .prose thead,
  .prose tbody,
  .prose tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  .prose th,
  .prose td {
    display: table-cell;
    padding: 12px 8px;
    border-bottom: 1px solid #e9ecef;
    white-space: normal;
    word-wrap: break-word;
    min-width: 120px;
  }

  .prose th {
    background: #f8f9fa;
    font-weight: 600;
    color: #1a1a1a;
    font-size: 13px;
  }

  .prose td {
    color: #4a4a4a;
    font-size: 13px;
  }

  .prose tr:last-child td {
    border-bottom: none;
  }
}
