@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.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;

    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;

    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;

    --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: 200.2 40% 60.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: 200.2 40% 60.9%;
  }
}

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

.react-flow {
  height: 100vh !important;
  width: 100% !important;
  .react-flow__edges {
    z-index: 2000 !important;
  }
  .react-flow__edgelabel-renderer {
    z-index: 2000 !important;
  }
}

/* React Flow Styles */
.react-flow__node {
  @apply border-gray-300 bg-white text-gray-900 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200;
}

.react-flow__edge-path {
  @apply stroke-gray-500 dark:stroke-gray-400;
}

.react-flow__controls {
  @apply border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-800;
}

.react-flow__controls-button {
  @apply border-gray-300 bg-gray-100 text-gray-800 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200;
  svg {
    @apply fill-gray-700 dark:fill-gray-300;
  }
}

.react-flow__minimap {
  @apply border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-800;
}

.react-flow__attribution {
  @apply bg-white text-gray-800 dark:bg-gray-800 dark:text-gray-200;
}

.react-flow__edge-text {
  @apply fill-gray-700 dark:fill-gray-300;
}

.react-flow__node-default,
.react-flow__node-input,
.react-flow__node-output,
.react-flow__node-group {
  @apply shadow-md;
}

/* Improve visibility of selection in light mode */
.react-flow__node.selected,
.react-flow__node:focus,
.react-flow__node:focus-visible {
  @apply rounded-md ring-2 ring-blue-500 dark:ring-blue-400;
}

/* Enhance edge selection visibility */
.react-flow__edge.selected .react-flow__edge-path,
.react-flow__edge:focus .react-flow__edge-path,
.react-flow__edge:focus-visible .react-flow__edge-path {
  @apply stroke-blue-600 dark:stroke-blue-400;
  stroke-width: 5px !important;
  filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.7));
}

/* Custom selected edge class with highest specificity */
.react-flow__edge-path.selected-edge {
  stroke: #2563eb !important; /* Blue-600 */
  stroke-width: 6px !important;
  filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.8)) !important;
}

.dark .react-flow__edge-path.selected-edge {
  stroke: #60a5fa !important; /* Blue-400 */
}

/* Hover states for nodes */
.react-flow__node:hover {
  @apply bg-gray-200 dark:bg-gray-700;
}

/* Ensure text is readable in both modes */
.react-flow__node-default {
  @apply text-sm font-medium;
}

/* Style node handles consistently */
.react-flow__handle {
  @apply h-3 w-3 border-2 border-white dark:border-gray-800;
}

/* Style the background */
.react-flow__background {
  @apply bg-gray-50 dark:bg-gray-900;
}

/* Style the minimap */
.react-flow__minimap-mask {
  @apply fill-gray-200 dark:fill-gray-700;
}

.react-flow__minimap-node {
  @apply fill-gray-400 dark:fill-gray-500;
}

/* Make sure the dark class is applied to the html tag when in dark mode */
html.dark {
  color-scheme: dark;
}
