@import url("https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap");
@import "tailwindcss";
@plugin "tailwindcss-animate";

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

@theme {
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco;

  --animate-neon: neon 3s ease-in-out infinite;
}

html,
body {
  background-color: var(--background);
  @media (prefers-color-scheme: dark) {
    color-scheme: dark;
  }
}

.loading-icon-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.loading-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulse-border {
  0% {
    border-color: hsla(47.9, 95.8%, 53.1%, 0.3);
  }
  50% {
    border-color: hsla(47.9, 95.8%, 53.1%, 0.9);
  }
  100% {
    border-color: hsla(47.9, 95.8%, 53.1%, 0.3);
  }
}

@keyframes borderTrail {
  0% {
    offset-distance: 0%;
    opacity: 0.5;
  }
  50% {
    opacity: 0.8;
  }
  100% {
    offset-distance: 100%;
    opacity: 0.5;
  }
}

.animate-pulse-border {
  animation: pulse-border 1.5s infinite ease-in-out;
  border: 1px solid rgba(99, 102, 241, 0.7);
}

@layer base {
  :root {
    --background: hsl(0 0% 100%);
    --foreground: hsl(20 14.3% 4.1%);
    --card: hsl(0 0% 100%);
    --card-foreground: hsl(20 14.3% 4.1%);
    --popover: hsl(0 0% 100%);
    --popover-foreground: hsl(20 14.3% 4.1%);
    --primary: hsl(47.9 95.8% 53.1%);
    --primary-foreground: hsl(26 83.3% 14.1%);
    --secondary: hsl(40 14% 92%);
    --secondary-foreground: hsl(24 9.8% 10%);
    --muted: hsl(40 14% 92%);
    --muted-foreground: hsl(25 5.3% 44.7%);
    --accent: hsl(40 14% 92%);
    --accent-foreground: hsl(24 9.8% 10%);
    --destructive: hsl(0 100% 60%);
    --destructive-foreground: hsl(60 9.1% 97.8%);
    --border: hsl(43 15% 92%);
    --input: hsl(43 15% 92%);
    --ring: hsl(20 14.3% 4.1%);
    --radius: 0.45rem;
    --chart-1: hsl(12 76% 61%);
    --chart-2: hsl(173 58% 39%);
    --chart-3: hsl(197 37% 24%);
    --chart-4: hsl(43 74% 66%);
    --chart-5: hsl(27 87% 67%);
    --sidebar: hsl(0 0% 100%);
    --sidebar-foreground: hsl(240 5.3% 26.1%);
    --sidebar-primary: hsl(240 5.9% 10%);
    --sidebar-primary-foreground: hsl(0 0% 98%);
    --sidebar-accent: hsl(40 10% 85%);
    --sidebar-accent-foreground: hsl(240 5.9% 10%);
    --sidebar-border: hsl(43 15% 92%);
    --sidebar-ring: hsl(217.2 91.2% 59.8%);
  }

  .dark {
    --background: hsl(20 14.3% 4.1%);
    --foreground: hsl(60 9.1% 97.8%);
    --card: hsl(20 14.3% 4.1%);
    --card-foreground: hsl(60 9.1% 97.8%);
    --popover: hsl(20 14.3% 4.1%);
    --popover-foreground: hsl(60 9.1% 97.8%);
    --primary: #ffa600;
    --primary-foreground: hsl(26 83.3% 14.1%);
    --secondary: hsl(12 6.5% 15.1%);
    --secondary-foreground: hsl(60 9.1% 97.8%);
    --muted: hsl(12 6.5% 15.1%);
    --muted-foreground: hsl(24 5.4% 63.9%);
    --accent: hsl(12 6.5% 15.1%);
    --accent-foreground: hsl(60 9.1% 97.8%);
    --destructive: hsl(0 100% 50%);
    --destructive-foreground: hsl(60 9.1% 97.8%);
    --border: hsl(12 6.5% 15.1%);
    --input: hsl(12 6.5% 15.1%);
    --ring: hsl(35.5 91.7% 32.9%);
    --chart-1: hsl(220 70% 50%);
    --chart-2: hsl(160 60% 45%);
    --chart-3: hsl(30 80% 55%);
    --chart-4: hsl(280 65% 60%);
    --chart-5: hsl(340 75% 55%);
    --sidebar: hsl(20 14.3% 4.1%);
    --sidebar-foreground: hsl(240 4.8% 95.9%);
    --sidebar-primary: hsl(224.3 76.3% 48%);
    --sidebar-primary-foreground: hsl(0 0% 100%);
    --sidebar-accent: hsl(240 3.7% 15.9%);
    --sidebar-accent-foreground: hsl(240 4.8% 95.9%);
    --sidebar-border: hsl(240 3.7% 15.9%);
    --sidebar-ring: hsl(217.2 91.2% 59.8%);
  }
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --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);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
  }

  .card-with-trail {
    position: relative;
    overflow: visible;
  }

  .card-with-trail::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: var(--muted-foreground);

    opacity: 0.3;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    transition: opacity 0.3s ease;
  }

  .card-with-trail:hover::before {
    opacity: 0.5;
  }

  .trail {
    width: 40px;
    height: 15px;
    position: absolute;
    background: radial-gradient(
      100% 100% at right,
      var(--foreground),
      transparent 80%
    );
    offset-path: border-box;
    offset-anchor: 100% 50%;
    animation: borderTrail 9s infinite linear;
    z-index: 1;
    filter: blur(2px);
    mix-blend-mode: soft-light;
  }
}

.sticky-column {
  position: sticky !important;
  right: 0;
  z-index: 1;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.05);
}

/* Virtualized table optimizations */
.virtualized-table-container {
  contain: layout style paint;
  will-change: scroll-position;
  overflow-x: auto;
  min-width: 100%;
}

/* Table container for proper overflow handling */
.table-container {
  overflow-x: auto;
  overflow-y: visible;
  min-width: 100%;
}

.table-container table {
  min-width: max-content;
}

.virtualized-table-row {
  contain: layout style paint;
  will-change: transform;
}

/* Performance optimizations for large datasets */
.data-table-wrapper {
  contain: layout style;
}

/* Smooth scrolling for virtualized content */
.virtualized-scroll-container {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

/* Reduce layout thrashing during virtualization */
.virtual-table-body {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Virtualized table layout fixes */
.virtualized-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.virtualized-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--background);
}

/* Ensure stable table header layout for measurement */
table {
  table-layout: auto;
  width: 100%;
  min-width: 100%;
}

/* Tailwind utilities for table layout */
.table-fixed {
  table-layout: auto !important;
  min-width: 100%;
}

.w-full {
  width: 100% !important;
}

.min-h-\[45px\] {
  min-height: 45px !important;
}

.h-full {
  height: 100% !important;
}

.border-r {
  border-right: 1px solid var(--border) !important;
}

.min-w-max {
  min-width: max-content !important;
}

th {
  position: relative;
  white-space: nowrap;
  overflow: visible;
  text-overflow: ellipsis;
  padding: 0.75rem !important;
  min-width: fit-content;
}

/* Ensure string columns get proper width */
th[data-column-type="string"],
th[data-column-type="varchar"],
th[data-column-type="text"] {
  min-width: 200px;
}

/* Ensure date columns get proper width */
th[data-column-type="date"],
th[data-column-type="datetime"],
th[data-column-type="timestamp"] {
  min-width: 150px;
}

/* Ensure proper cell alignment in virtualized rows */
.virtualized-row {
  display: flex;
  width: 100%;
  min-height: 45px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.virtualized-row:hover {
  background-color: var(--muted);
}

.virtualized-cell {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Fix table header alignment */
.table-header-fixed {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--background);
  border-bottom: 1px solid var(--border);
}

/* Ensure virtualized content doesn't interfere with header */
.virtualized-body-container {
  position: relative;
  width: 100%;
}

/* Prevent layout shift during virtualization */
.virtual-table-container {
  contain: layout style paint;
  will-change: scroll-position;
}

/* Text overflow utilities */
.text-wrap-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.overflow-wrap-anywhere {
  overflow-wrap: anywhere;
}
