@import "tailwindcss";

@custom-variant dark (&:is(.dark *));

@theme {
  --color-background: hsl(var(--background));
  --color-foreground: hsl(var(--foreground));
  --color-card: hsl(var(--card));
  --color-card-foreground: hsl(var(--card-foreground));
  --color-popover: hsl(var(--popover));
  --color-popover-foreground: hsl(var(--popover-foreground));
  --color-primary: hsl(var(--primary));
  --color-primary-foreground: hsl(var(--primary-foreground));
  --color-secondary: hsl(var(--secondary));
  --color-secondary-foreground: hsl(var(--secondary-foreground));
  --color-muted: hsl(var(--muted));
  --color-muted-foreground: hsl(var(--muted-foreground));
  --color-accent: hsl(var(--accent));
  --color-accent-foreground: hsl(var(--accent-foreground));
  --color-destructive: hsl(var(--destructive));
  --color-destructive-foreground: hsl(var(--destructive-foreground));
  --color-border: hsl(var(--border));
  --color-input: hsl(var(--input));
  --color-ring: hsl(var(--ring));
  --color-sidebar-bg: hsl(var(--sidebar-bg));
  --color-sidebar-border: hsl(var(--sidebar-border));
  --color-sidebar-item-hover: hsl(var(--sidebar-item-hover));
  --color-sidebar-active-bg: hsl(var(--sidebar-active-bg));
  --color-sidebar-section-text: hsl(var(--sidebar-section-text));
  --color-sidebar-muted: hsl(var(--sidebar-muted));
  --color-status-online: hsl(var(--status-online));
  --color-status-offline: hsl(var(--status-offline));
  --color-badge-unread: hsl(var(--badge-unread));
  --color-badge-unread-text: hsl(var(--badge-unread-text));
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
}

@layer base {
  :root {
    --background: 40 30% 96%;
    --foreground: 0 0% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 0 0% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 0 0% 3.9%;
    --primary: 45 93% 47%;
    --primary-foreground: 0 0% 2%;
    --secondary: 40 20% 92%;
    --secondary-foreground: 0 0% 9%;
    --muted: 40 20% 92%;
    --muted-foreground: 0 0% 45.1%;
    --accent: 40 20% 92%;
    --accent-foreground: 0 0% 9%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 35 15% 87%;
    --input: 35 15% 87%;
    --ring: 45 93% 47%;
    --radius: 0.5rem;

    /* Sidebar */
    --sidebar-bg: 40 30% 96%;
    --sidebar-border: 35 20% 90%;
    --sidebar-item-hover: 40 20% 93%;
    --sidebar-active-bg: 45 93% 47% / 0.12;
    --sidebar-section-text: 0 0% 45%;
    --sidebar-muted: 0 0% 55%;

    /* Status indicators */
    --status-online: 142 71% 45%;
    --status-offline: 0 0% 70%;
    --badge-unread: 25 95% 55%;
    --badge-unread-text: 0 0% 100%;

    /* Agent graph node status colors */
    --node-running: 45 95% 42%;
    --node-looping: 38 90% 42%;
    --node-complete: 43 70% 38%;
    --node-pending: 35 15% 72%;
    --node-pending-bg: 35 10% 94%;
    --node-pending-border: 35 10% 80%;
    --node-error: 0 65% 50%;

    /* Agent graph trigger node colors */
    --trigger-bg: 210 25% 94%;
    --trigger-border: 210 20% 78%;
    --trigger-text: 210 30% 35%;
    --trigger-icon: 210 40% 40%;

    /* Draft graph chrome colors */
    --draft-edge: 220 10% 75%;
    --draft-edge-arrow: 220 10% 65%;
    --draft-edge-label: 220 10% 50%;
    --draft-back-edge: 220 10% 80%;
    --draft-group-fill: 220 10% 96%;
    --draft-group-stroke: 220 10% 72%;
    --draft-chrome-text: 220 10% 45%;
    --draft-chrome-text-dim: 220 10% 55%;
    --draft-node-text: 0 0% 25%;
    --draft-node-text-hover: 0 0% 10%;

    /* Sub-agent mux pane colors */
    --mux-title-bg: 220 10% 95%;
    --mux-title-border: 220 10% 88%;
    --mux-body-bg: 0 0% 98%;
    --mux-grid-bg: 0 0% 93%;
    --mux-frame-border: 220 10% 85%;
    --mux-frame-bg: 0 0% 97%;
    --mux-dim-text: 0 0% 45%;
    --mux-content-text: 0 0% 15%;
    --mux-waiting-text: 0 0% 70%;
    --mux-overlay-bg: 0 0% 100% / 0.82;
    --mux-finished-check: 142 50% 40%;

    /* Trigger status colors */
    --trigger-status-active: 142 40% 45%;
    --trigger-status-inactive: 210 20% 55%;
    --trigger-active-bg: 210 30% 90%;
    --trigger-active-border: 210 40% 60%;
    --trigger-active-text: 210 40% 30%;
    --trigger-active-icon: 210 50% 45%;
  }

  .dark {
    --background: 240 6% 6%;
    --foreground: 0 0% 95%;
    --card: 240 5% 8%;
    --card-foreground: 0 0% 95%;
    --popover: 240 5% 8%;
    --popover-foreground: 0 0% 95%;
    --primary: 45 93% 47%;
    --primary-foreground: 0 0% 2%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 50.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 45 93% 47%;

    /* Sidebar */
    --sidebar-bg: 240 6% 7%;
    --sidebar-border: 240 4% 12%;
    --sidebar-item-hover: 240 5% 11%;
    --sidebar-active-bg: 45 93% 47% / 0.12;
    --sidebar-section-text: 240 5% 55%;
    --sidebar-muted: 240 5% 50%;

    /* Status indicators */
    --status-online: 142 71% 45%;
    --status-offline: 240 5% 40%;
    --badge-unread: 25 95% 55%;
    --badge-unread-text: 0 0% 100%;

    /* Agent graph node status colors */
    --node-running: 45 95% 58%;
    --node-looping: 38 90% 55%;
    --node-complete: 43 70% 45%;
    --node-pending: 35 15% 28%;
    --node-pending-bg: 35 10% 12%;
    --node-pending-border: 35 10% 20%;
    --node-error: 0 65% 55%;

    /* Agent graph trigger node colors */
    --trigger-bg: 210 25% 14%;
    --trigger-border: 210 30% 30%;
    --trigger-text: 210 30% 65%;
    --trigger-icon: 210 40% 55%;

    /* Draft graph chrome colors */
    --draft-edge: 220 10% 30%;
    --draft-edge-arrow: 220 10% 35%;
    --draft-edge-label: 220 10% 45%;
    --draft-back-edge: 220 10% 25%;
    --draft-group-fill: 220 15% 18%;
    --draft-group-stroke: 220 10% 40%;
    --draft-chrome-text: 220 10% 50%;
    --draft-chrome-text-dim: 220 10% 55%;
    --draft-node-text: 0 0% 78%;
    --draft-node-text-hover: 0 0% 92%;

    /* Sub-agent mux pane colors */
    --mux-title-bg: 240 15% 6%;
    --mux-title-border: 240 10% 15%;
    --mux-body-bg: 240 20% 4%;
    --mux-grid-bg: 0 0% 7%;
    --mux-frame-border: 240 10% 15%;
    --mux-frame-bg: 240 20% 4%;
    --mux-dim-text: 0 0% 33%;
    --mux-content-text: 0 0% 80%;
    --mux-waiting-text: 0 0% 20%;
    --mux-overlay-bg: 240 20% 4% / 0.82;
    --mux-finished-check: 142 50% 40%;

    /* Trigger status colors */
    --trigger-status-active: 140 40% 50%;
    --trigger-status-inactive: 210 20% 40%;
    --trigger-active-bg: 210 30% 18%;
    --trigger-active-border: 210 50% 50%;
    --trigger-active-text: 210 40% 75%;
    --trigger-active-icon: 210 60% 65%;
  }
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply bg-background text-foreground;
  }

  button {
    cursor: pointer;
  }

  textarea {
    padding: 0;
    margin: 0;
  }
}

* {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

*:hover,
*:active {
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Webkit (Chrome/Safari/Edge) — thin overlay track */
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}

*:hover::-webkit-scrollbar-thumb,
*:active::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Light mode adjustments */
:root:not(.dark) *:hover,
:root:not(.dark) *:active {
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

:root:not(.dark) *:hover::-webkit-scrollbar-thumb,
:root:not(.dark) *:active::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}

:root:not(.dark) *::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.35);
}

/* Keep scrollbar-hide for elements that truly need no scrollbar (e.g. tab bars) */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Pulse ring animation for SVG elements */
@keyframes pulse-ring {
  0% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0; transform: scale(1.05); }
  100% { opacity: 0.25; transform: scale(1); }
}

/* Slide-in animation */
@keyframes slide-in-from-right {
  from { transform: translateX(10px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.animate-in.slide-in-from-right {
  animation: slide-in-from-right 0.2s ease-out;
}

/* Slide-up animation for question widget */
@keyframes slide-in-from-bottom {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.animate-in.slide-in-from-bottom {
  animation: slide-in-from-bottom 0.25s ease-out;
}

/* Home status line shimmer */
@keyframes queen-debate-line {
  0%, 100% {
    opacity: 0.72;
    transform: translateY(0);
    background-position: 0% 50%;
  }
  50% {
    opacity: 1;
    transform: translateY(-1px);
    background-position: 100% 50%;
  }
}

.queen-debate-line {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  color: hsl(var(--muted-foreground));
  background-image: linear-gradient(
    90deg,
    hsl(var(--muted-foreground) / 0.75),
    hsl(var(--primary) / 0.95),
    hsl(var(--muted-foreground) / 0.75)
  );
  background-size: 220% 100%;
  background-position: 0% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: queen-debate-line 1.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .queen-debate-line {
    animation: none;
    background-image: none;
    color: hsl(var(--muted-foreground));
  }
}
