@import 'tailwindcss';

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

:root {
  /* CCS Brand Colors - Calculated from Crail, Pampas, White, Cloudy */
  /* Primary: Neutral (Dark Warm Grey) - Demoted Crail from Primary */
  --primary: oklch(0.15 0.02 40); /* Darker for better contrast */
  --primary-foreground: oklch(0.9635 0.0067 97.35); /* Pampas */

  --secondary: oklch(0.88 0.012 95); /* Slightly darker */
  --secondary-foreground: oklch(0.15 0.02 40);

  /* Accent: Crail (Moved from Primary) */
  --accent: oklch(0.52 0.15 39.87); /* Crail - slightly darker */
  --accent-foreground: oklch(1 0 0); /* White */

  --background: oklch(0.9635 0.0067 97.35); /* Pampas */
  --foreground: oklch(0.15 0.02 40); /* Darker for better readability */

  --muted: oklch(0.9 0.012 95);
  --muted-foreground: oklch(0.4 0.025 40); /* Much darker: 0.55 -> 0.40 */

  --border: oklch(0.78 0.02 91.6); /* Darker: 0.85 -> 0.78 */
  --input: oklch(0.78 0.02 91.6);

  --ring: oklch(0.15 0.02 40); /* Match primary */
  --radius: 0.5rem;

  --popover: oklch(0.98 0.005 97.35); /* Slight depth */
  --popover-foreground: oklch(0.15 0.02 40); /* Match foreground */

  --card: oklch(0.98 0.005 97.35); /* Slight depth from background */
  --card-foreground: oklch(0.15 0.02 40); /* Match foreground */

  --destructive: oklch(0.5 0.22 27); /* Darker red for visibility */
  --destructive-foreground: oklch(0.98 0.005 97.35); /* White */

  /* Sidebar colors - Light */
  --sidebar: oklch(0.9635 0.0067 97.35); /* Pampas */
  --sidebar-foreground: oklch(0.15 0.02 40);
  --sidebar-primary: oklch(0.15 0.02 40); /* Neutral - darker */
  --sidebar-primary-foreground: oklch(0.9635 0.0067 97.35);
  --sidebar-accent: oklch(0.52 0.15 39.87); /* Crail - darker */
  --sidebar-accent-foreground: oklch(1 0 0);
  --sidebar-border: oklch(0.78 0.02 91.6); /* Darker */
  --sidebar-ring: oklch(0.15 0.02 40);
}

.dark {
  /* Dark Theme */
  /* Primary: Neutral (Pampas) */
  --primary: oklch(0.9635 0.0067 97.35);
  --primary-foreground: oklch(0.2 0.02 40);

  /* Background: RGB(38, 38, 36) -> approx oklch(0.21 0.006 100) */
  --background: oklch(0.21 0.006 100);
  --foreground: oklch(0.9635 0.0067 97.35); /* Pampas */

  --secondary: oklch(0.25 0.01 40);
  --secondary-foreground: oklch(0.96 0.007 97);

  --muted: oklch(0.25 0.01 40);
  --muted-foreground: oklch(0.7 0.01 40);

  /* Accent: Crail */
  --accent: oklch(0.65 0.14 39.87);
  --accent-foreground: oklch(1 0 0);

  --border: oklch(0.35 0.01 40);
  --input: oklch(0.35 0.01 40);

  --ring: oklch(0.9635 0.0067 97.35);

  --popover: oklch(0.21 0.006 100); /* Match dark bg */
  --popover-foreground: oklch(0.9635 0.0067 97.35); /* Match dark fg */

  --card: oklch(0.21 0.006 100); /* Match dark bg */
  --card-foreground: oklch(0.9635 0.0067 97.35); /* Match dark fg */

  --destructive: oklch(0.396 0.141 25.723); /* Red 900 */
  --destructive-foreground: oklch(0.9635 0.0067 97.35); /* White */

  /* Sidebar Dark Theme */
  --sidebar: oklch(0.21 0.006 100); /* Match bg */
  --sidebar-foreground: oklch(0.9635 0.0067 97.35);
  --sidebar-primary: oklch(0.9635 0.0067 97.35);
  --sidebar-primary-foreground: oklch(0.2 0.02 40);
  --sidebar-accent: oklch(0.65 0.14 39.87);
  --sidebar-accent-foreground: oklch(1 0 0);
  --sidebar-border: oklch(0.35 0.01 40);
  --sidebar-ring: oklch(0.9635 0.0067 97.35);
}

@theme inline {
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: var(--radius);
  --radius-lg: calc(var(--radius) + 4px);
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@layer base {
  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground;
    font-family: 'IBM Plex Sans', 'Fira Sans', system-ui, sans-serif;
    margin: 0;
  }
  code,
  pre,
  .font-mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
  }
}

/* Animations */
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes zoom-in {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.animate-in {
  animation-duration: 0.5s;
  animation-fill-mode: both;
  animation-timing-function: ease-out;
}

.fade-in {
  animation-name: fade-in;
}

.slide-in-from-bottom-4 {
  animation-name: enter;
}

.zoom-in-95 {
  animation-name: zoom-in;
}

/* Flow visualization animations */
@keyframes request-pulse {
  0% {
    stroke-opacity: 1;
    stroke-width: inherit;
    filter: drop-shadow(0 0 2px currentColor);
  }
  30% {
    stroke-opacity: 0.9;
    filter: drop-shadow(0 0 8px currentColor);
  }
  60% {
    stroke-opacity: 0.5;
    stroke-width: calc(inherit * 1.5);
    filter: drop-shadow(0 0 4px currentColor);
  }
  100% {
    stroke-opacity: 0;
    stroke-width: calc(inherit * 2);
    filter: none;
  }
}

/* Traveling dot along path */
@keyframes travel-dot {
  0% {
    offset-distance: 0%;
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    offset-distance: 100%;
    opacity: 0;
  }
}

@keyframes glow-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--glow-color, rgba(16, 185, 129, 0.3));
    transform: scale(1);
  }
  25% {
    box-shadow: 0 0 15px 3px var(--glow-color, rgba(16, 185, 129, 0.5));
    transform: scale(1.02);
  }
  50% {
    box-shadow: 0 0 25px 6px var(--glow-color, rgba(16, 185, 129, 0.4));
    transform: scale(1.01);
  }
  75% {
    box-shadow: 0 0 12px 2px var(--glow-color, rgba(16, 185, 129, 0.35));
  }
}

@keyframes subtle-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes icon-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

@keyframes border-glow {
  0%,
  100% {
    border-color: var(--glow-color, rgba(16, 185, 129, 0.2));
  }
  50% {
    border-color: var(--glow-color, rgba(16, 185, 129, 0.5));
  }
}

.animate-request-pulse {
  animation: request-pulse 2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-glow-pulse {
  animation: glow-pulse 2.5s ease-in-out infinite;
}

.animate-travel-dot {
  animation: travel-dot 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-subtle-float {
  animation: subtle-float 3s ease-in-out infinite;
}

.animate-icon-breathe {
  animation: icon-breathe 2.5s ease-in-out infinite;
}

.animate-border-glow {
  animation: border-glow 2s ease-in-out infinite;
}

/* Fix Radix ScrollArea viewport overflow issue */
/* Radix uses inline styles with display: table which causes content to expand beyond container */
[data-radix-scroll-area-viewport] > div {
  display: block !important;
  min-width: 0 !important;
}

/* Thin scrollbar utility for horizontal tab overflow */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.scrollbar-thin::-webkit-scrollbar {
  height: 4px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

.scrollbar-editor {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  scrollbar-gutter: stable;
}

.scrollbar-editor::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.scrollbar-editor::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-editor::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid transparent;
  border-radius: 9999px;
  background-clip: content-box;
  min-height: 32px;
}

.scrollbar-editor::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
  background-clip: content-box;
}

.scrollbar-editor::-webkit-scrollbar-corner {
  background: transparent;
}

@keyframes scan {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(100%);
  }
}

.animate-scan {
  animation: scan 8s linear infinite;
}

@keyframes slide-in-from-right {
  from {
    transform: translateX(10px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slide-in-from-left {
  from {
    transform: translateX(-10px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.slide-in-from-right-4 {
  animation: slide-in-from-right 0.5s ease-out;
}

.slide-in-from-left-2 {
  animation: slide-in-from-left 0.4s ease-out;
}

.slide-in-from-bottom-2 {
  animation: enter 0.3s ease-out;
}
