/* =========================================================================
   GITHUB PRIMER DARK × AVODIGITAL STUDIO THEME (theme-github-avo)
   Authentic GitHub Primer Dark (#0d1117 / #010409 / #161b22 / #30363d)
   Fused with AVOdigital Brand Emerald (#2AC74A / #238636 / #2ea043)
   Zero Blur · Crisp 1px Borders · High-Contrast Developer Craft
   ========================================================================= */

:is(html.theme-github-avo, html[data-theme="github-avo"], .theme-github-avo) {
  /* Core Shadcn / Tailwind HSL Variables mapped to GitHub Primer Dark */
  --background: 215 28% 7% !important;          /* #0d1117 canvas.default */
  --foreground: 210 29% 93% !important;         /* #e6edf3 fg.default */
  --card: 215 21% 11% !important;               /* #161b22 canvas.subtle */
  --card-foreground: 210 29% 93% !important;    /* #e6edf3 */
  --popover: 215 21% 11% !important;            /* #161b22 canvas.overlay */
  --popover-foreground: 210 29% 93% !important; /* #e6edf3 */
  --primary: 132 65% 47% !important;            /* #2AC74A AVOdigital emerald */
  --primary-foreground: 0 0% 100% !important;
  --secondary: 215 15% 15% !important;          /* #21262d btn.bg */
  --secondary-foreground: 210 25% 91% !important;
  --muted: 215 15% 15% !important;              /* #21262d */
  --muted-foreground: 212 9% 58% !important;    /* #8b949e fg.muted */
  --accent: 215 15% 16% !important;             /* #21262d hover */
  --accent-foreground: 210 29% 95% !important;
  --destructive: 2 93% 63% !important;          /* #f85149 danger.fg */
  --destructive-foreground: 0 0% 100% !important;
  --border: 212 12% 21% !important;             /* #30363d border.default */
  --input: 212 12% 21% !important;              /* #30363d */
  --ring: 212 92% 58% !important;               /* #2f81f7 accent.fg focus ring */
  --radius: 0.375rem !important;                /* 6px GitHub Primer radius */

  --nav-tab-glow: 132 65% 47% / 0.12 !important;
  --nav-tab-ring: 212 12% 21% / 1 !important;
  --nav-input-focus-ring: 212 92% 58% / 0.28 !important;

  /* AVO Mascot Tokens */
  --avo-mascot-bg: #2AC74A;
  --avo-mascot-leaf: #56d364;
  --avo-mascot-eye: #ffffff;
  --avo-mascot-stroke: rgba(240, 246, 252, 0.16);

  /* Explicit GitHub Primer Palette Tokens */
  --gh-canvas-default: #0d1117;
  --gh-canvas-inset: #010409;
  --gh-canvas-subtle: #161b22;
  --gh-canvas-overlay: #161b22;
  --gh-control-bg: #21262d;
  --gh-control-hover: #30363d;
  --gh-border-default: #30363d;
  --gh-border-muted: #21262d;
  --gh-fg-default: #e6edf3;
  --gh-fg-muted: #8b949e;
  --gh-accent-fg: #58a6ff;
  --gh-accent-emphasis: #1f6feb;
  --gh-avo-btn-bg: #238636;
  --gh-avo-btn-hover: #2ea043;
  --gh-avo-emerald: #2AC74A;
  --gh-avo-lime: #3fb950;
}

/* 1. Typography & Root Canvas */
:is(html.theme-github-avo, html[data-theme="github-avo"]) body {
  background-color: var(--gh-canvas-default) !important;
  color: var(--gh-fg-default) !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "InterVar", Helvetica, Arial, sans-serif !important;
  -webkit-font-smoothing: antialiased;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) code,
:is(html.theme-github-avo, html[data-theme="github-avo"]) pre,
:is(html.theme-github-avo, html[data-theme="github-avo"]) kbd,
:is(html.theme-github-avo, html[data-theme="github-avo"]) .font-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace !important;
}

/* Zero-Slop Rule: No backdrop-filter blur anywhere in GitHub Primer */
:is(html.theme-github-avo, html[data-theme="github-avo"]) *,
:is(html.theme-github-avo, html[data-theme="github-avo"]) *::before,
:is(html.theme-github-avo, html[data-theme="github-avo"]) *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* 2. GitHub Primer Inset Top Header & Sidebar (#010409 + 1px #30363d) */
:is(html.theme-github-avo, html[data-theme="github-avo"]) header,
:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="header"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) div.border-b.bg-background\/80,
:is(html.theme-github-avo, html[data-theme="github-avo"]) div.border-b.bg-card {
  background-color: var(--gh-canvas-inset) !important;
  border-bottom: 1px solid var(--gh-border-default) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) aside,
:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="sidebar"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) #root aside,
:is(html.theme-github-avo, html[data-theme="github-avo"]) div[class*="w-72"][class*="border-r"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) div[class*="border-r"][class*="bg-card"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) div[class*="border-r"][class*="bg-background"] {
  background-color: var(--gh-canvas-inset) !important;
  border-right: 1px solid var(--gh-border-default) !important;
}

/* Branded GitHub × AVOdigital Header Badge in Sidebar */
:is(html.theme-github-avo, html[data-theme="github-avo"]) h1[style*="font-family"]::after {
  content: "GH·AVO";
  display: inline-block;
  margin-left: 7px;
  padding: 1px 5px;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.03em;
  vertical-align: middle;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  color: #3fb950;
  background-color: rgba(46, 160, 67, 0.14);
  border: 1px solid rgba(46, 160, 67, 0.4);
  border-radius: 999px;
}

/* Crisp AVO Logo in GitHub Theme */
:is(html.theme-github-avo, html[data-theme="github-avo"]) img[src*="avo-logo"] {
  filter: drop-shadow(0 0 1px rgba(42, 199, 74, 0.35));
}

/* 3. Chat Canvas: Primer Engineering Dot-Grid + Subtle Octo-AVO Watermark */
:is(html.theme-github-avo, html[data-theme="github-avo"]) main,
:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="chat-feed"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) .chat-messages-pane {
  background-color: var(--gh-canvas-default) !important;
  background-image: radial-gradient(rgba(48, 54, 61, 0.55) 1px, transparent 1px) !important;
  background-size: 24px 24px !important;
  background-position: 0 0 !important;
  position: relative;
}

/* Subtle GitHub-style AVO Repo Watermark on Empty / Feed Stage */
:is(html.theme-github-avo, html[data-theme="github-avo"]) .chat-messages-pane::after {
  content: "";
  position: fixed;
  top: 46%;
  left: calc(50% + 136px);
  transform: translate(-50%, -50%);
  width: min(320px, 36vw);
  height: min(320px, 36vw);
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120' fill='none'%3E%3Crect x='14' y='28' width='92' height='68' rx='16' stroke='%233fb950' stroke-width='4'/%3E%3Cpath d='M36 28V16h14v12M70 28V16h14v12' stroke='%233fb950' stroke-width='4' stroke-linecap='round'/%3E%3Crect x='62' y='46' width='10' height='22' fill='%2358a6ff'/%3E%3Crect x='82' y='46' width='10' height='22' fill='%2358a6ff'/%3E%3Cpath d='M30 82h24' stroke='%233fb950' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E");
}

@media (max-width: 768px) {
  :is(html.theme-github-avo, html[data-theme="github-avo"]) .chat-messages-pane::after {
    left: 50%;
    width: 220px;
    height: 220px;
  }
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) .chat-messages-pane > * {
  position: relative;
  z-index: 1;
}

/* 4. Sidebar Active Session & Navigation Tabs (Primer Repo Nav Style) */
:is(html.theme-github-avo, html[data-theme="github-avo"]) [class*="bg-emerald-500/"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) .bg-emerald-500\/15 {
  background-color: var(--gh-canvas-subtle) !important;
  border-color: var(--gh-border-default) !important;
  box-shadow: inset 3px 0 0 0 var(--gh-avo-emerald) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) [class*="border-emerald-500"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) .border-emerald-500\/50 {
  border-color: rgba(46, 160, 67, 0.55) !important;
}

/* Segmented Switchers in Sidebar (Projects / Conversations / Running) */
:is(html.theme-github-avo, html[data-theme="github-avo"]) aside .bg-muted\/50 {
  background-color: var(--gh-canvas-default) !important;
  border: 1px solid var(--gh-border-default) !important;
  border-radius: 6px !important;
  padding: 2px !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) aside button[aria-pressed="true"] {
  background-color: var(--gh-control-bg) !important;
  color: var(--gh-fg-default) !important;
  border: 1px solid #484f58 !important;
  box-shadow: none !important;
  font-weight: 600 !important;
}

/* 5. Primary Buttons: Iconic GitHub Merge/New Button (#238636 -> #2ea043) */
:is(html.theme-github-avo, html[data-theme="github-avo"]) .bg-primary,
:is(html.theme-github-avo, html[data-theme="github-avo"]) button.bg-primary,
:is(html.theme-github-avo, html[data-theme="github-avo"]) .bg-blue-600:not(.rounded-br-md),
:is(html.theme-github-avo, html[data-theme="github-avo"]) .bg-blue-500 {
  background-color: var(--gh-avo-btn-bg) !important;
  color: #ffffff !important;
  border: 1px solid rgba(240, 246, 252, 0.14) !important;
  box-shadow: 0 1px 0 rgba(1, 4, 9, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) .bg-primary:hover,
:is(html.theme-github-avo, html[data-theme="github-avo"]) button.bg-primary:hover,
:is(html.theme-github-avo, html[data-theme="github-avo"]) .hover\:bg-blue-600:hover,
:is(html.theme-github-avo, html[data-theme="github-avo"]) .hover\:bg-blue-700:hover {
  background-color: var(--gh-avo-btn-hover) !important;
  color: #ffffff !important;
  border-color: rgba(240, 246, 252, 0.22) !important;
}

/* 6. Cards, Popovers, Dialogs & Menus (#161b22 + Crisp 1px #30363d) */
:is(html.theme-github-avo, html[data-theme="github-avo"]) .bg-card,
:is(html.theme-github-avo, html[data-theme="github-avo"]) .bg-popover,
:is(html.theme-github-avo, html[data-theme="github-avo"]) [role="dialog"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) .avo-drawer-panel,
:is(html.theme-github-avo, html[data-theme="github-avo"]) .avo-artifact-card {
  background-color: var(--gh-canvas-subtle) !important;
  border-color: var(--gh-border-default) !important;
  color: var(--gh-fg-default) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) .shadow-xl,
:is(html.theme-github-avo, html[data-theme="github-avo"]) .shadow-2xl {
  box-shadow: 0 8px 24px #010409, 0 0 0 1px var(--gh-border-default) !important;
}

/* 7. User Message Bubble: GitHub PR Author Comment Box (#121d2f + #1f6feb hairline) */
:is(html.theme-github-avo, html[data-theme="github-avo"]) .rounded-br-md.bg-blue-600,
:is(html.theme-github-avo, html[data-theme="github-avo"]) .chat-message.user .bg-blue-600 {
  background-color: #121d2f !important;
  color: var(--gh-fg-default) !important;
  border: 1px solid rgba(56, 139, 253, 0.42) !important;
  border-radius: 8px 8px 2px 8px !important;
  box-shadow: 0 1px 0 rgba(1, 4, 9, 0.4) !important;
}

/* 8. Prompt Input Composer (GitHub Comment Editor Box) */
:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input"] {
  background-color: var(--gh-canvas-default) !important;
  border: 1px solid var(--gh-border-default) !important;
  border-radius: 8px !important;
  box-shadow: inset 0 1px 0 rgba(1, 4, 9, 0.35) !important;
  transition: border-color 120ms ease, box-shadow 120ms ease !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input"]:focus-within {
  border-color: #2f81f7 !important;
  box-shadow: 0 0 0 2px rgba(47, 129, 247, 0.28) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input-footer"] {
  background-color: var(--gh-canvas-subtle) !important;
  border-top: 1px solid var(--gh-border-muted) !important;
  border-radius: 0 0 7px 7px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  padding: 6px 10px !important;
  min-width: 0 !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input-tools"] {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 6px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scrollbar-width: none !important;
  min-width: 0 !important;
  flex: 1 1 0% !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input-tools"]::-webkit-scrollbar {
  display: none !important;
}

@media (min-width: 1024px) {
  :is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input-tools"] {
    overflow-x: visible !important;
  }
}

/* Composer Footer Controls & Header Icon Buttons (#21262d GitHub Secondary Button) */
:is(html.theme-github-avo, html[data-theme="github-avo"]) .avo-hdr-artifacts-btn,
:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input-tools"] button {
  background-color: var(--gh-control-bg) !important;
  border: 1px solid var(--gh-border-default) !important;
  color: var(--gh-fg-default) !important;
  border-radius: 6px !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) .avo-hdr-artifacts-btn:hover,
:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input-tools"] button:hover {
  background-color: var(--gh-control-hover) !important;
  border-color: #8b949e !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) .avo-hdr-artifacts-btn:active,
:is(html.theme-github-avo, html[data-theme="github-avo"]) [data-slot="prompt-input-tools"] button:active,
:is(html.theme-github-avo, html[data-theme="github-avo"]) button.bg-primary:active {
  transform: translateY(0.5px);
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) .avo-hdr-browser-btn[data-active="true"] {
  border-color: var(--gh-avo-emerald) !important;
  background-color: rgba(46, 160, 67, 0.16) !important;
  color: #3fb950 !important;
}

/* Working Activity Tab above Composer */
:is(html.theme-github-avo, html[data-theme="github-avo"]) .chat-activity-tab {
  background-color: var(--gh-canvas-subtle) !important;
  border-color: var(--gh-border-default) !important;
  border-bottom: 0 !important;
  color: var(--gh-fg-default) !important;
}

/* 9. GitHub Flavored Markdown (GFM) Prose, Tables, Links & Code Blocks */
:is(html.theme-github-avo, html[data-theme="github-avo"]) a:not([class*="bg-"]) {
  color: var(--gh-accent-fg) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) pre {
  background-color: var(--gh-canvas-subtle) !important;
  border: 1px solid var(--gh-border-default) !important;
  border-radius: 6px !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) :not(pre) > code {
  background-color: rgba(110, 118, 129, 0.28) !important;
  color: var(--gh-fg-default) !important;
  border-radius: 6px !important;
  padding: 0.15em 0.4em !important;
  font-size: 85% !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) table {
  border-collapse: collapse !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) th,
:is(html.theme-github-avo, html[data-theme="github-avo"]) td {
  border: 1px solid var(--gh-border-default) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) th {
  background-color: var(--gh-canvas-subtle) !important;
  color: var(--gh-fg-default) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) tr:nth-child(2n) td {
  background-color: rgba(22, 27, 34, 0.55) !important;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) blockquote {
  border-left: 3px solid var(--gh-border-default) !important;
  color: var(--gh-fg-muted) !important;
  background: transparent !important;
}

/* 10. Scrollbars in GitHub Primer Dark */
:is(html.theme-github-avo, html[data-theme="github-avo"]) ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) ::-webkit-scrollbar-track {
  background: transparent;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) ::-webkit-scrollbar-thumb {
  background-color: #30363d;
  border-radius: 4px;
}

:is(html.theme-github-avo, html[data-theme="github-avo"]) ::-webkit-scrollbar-thumb:hover {
  background-color: #484f58;
}

/* Hide upstream external promo links */
:is(html.theme-github-avo, html[data-theme="github-avo"]) a[href*="github.com/siteboon"],
:is(html.theme-github-avo, html[data-theme="github-avo"]) a[href*="discord.gg"] {
  display: none !important;
}
