@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --background: 260 20% 10%; /* Deep dark blue-purple base */
    --foreground: 0 0% 98%; /* Near-white text */

    --card: 260 20% 13%; /* Slightly lighter than background for cards */
    --card-foreground: 0 0% 98%;

    --popover: 260 20% 10%;
    --popover-foreground: 0 0% 98%;

    --primary: 259 50% 74%; /* Purple accent (#9b87f5) */
    --primary-foreground: 0 0% 10%; /* Darker text for primary buttons */

    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;

    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%; /* Lighter gray for muted text */

    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;

    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;

    --border: 240 3.7% 20%; /* Slightly lighter border */
    --input: 240 3.7% 20%;
    --ring: 259 50% 74%;

    --radius: 0.75rem;

    /* Finance-specific brand colors */
    --finance-purple: 155 135 245;
    --finance-blue: 30 174 219;
    --finance-dark-purple: 26 31 44;
  }

  .dark {
    /* Keep dark mode variables consistent with the new base */
    --background: 260 20% 10%;
    --foreground: 0 0% 98%;
    --card: 260 20% 13%;
    --card-foreground: 0 0% 98%;
    --popover: 260 20% 10%;
    --popover-foreground: 0 0% 98%;
    --primary: 259 50% 74%;
    --primary-foreground: 0 0% 10%;
    --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% 30.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 20%;
    --input: 240 3.7% 20%;
    --ring: 259 50% 74%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground;
    font-feature-settings: "rlig" 1, "calt" 1;
    min-height: 100vh;
    /* Layered Background Elements */
    background-image: radial-gradient(circle at 10% 20%, rgba(155, 135, 245, 0.08) 0%, transparent 35%), /* Top-left purple glow */
      radial-gradient(circle at 90% 80%, rgba(30, 174, 219, 0.07) 0%, transparent 35%), /* Bottom-right blue glow */
      radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.05) 0%, transparent 70%); /* Subtle central dark spot */
    background-attachment: fixed; /* Keep gradients fixed during scroll */
  }
}

@layer components {
  /* Step 1: Base CSS Foundation */
  /* 1. Create the base glow utility class */
  .glow {
    @apply relative overflow-hidden;
  }

  /* 2. Add the main glow effect using ::after pseudo-element */
  .glow::after {
    content: "";
    @apply absolute inset-0 rounded-xl opacity-60 blur-xl;
    background: radial-gradient(circle at top right, rgba(155, 135, 245, 0.3), transparent 70%);
    z-index: -1; /* Ensure it doesn't block clicks */
    pointer-events: none; /* Explicitly disable pointer events */
  }

  /* 3. Add subtle inner highlight using ::before pseudo-element */
  .glow::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      to bottom right,
      rgba(255, 255, 255, 0.1) 0%,
      rgba(255, 255, 255, 0.05) 25%,
      rgba(255, 255, 255, 0) 50%
    );
    opacity: 0.4;
    z-index: 0;
    border-radius: 0.75rem;
    pointer-events: none; /* Explicitly disable pointer events */
  }

  /* Step 2: Glass Card Foundation */
  /* 4. Create the glass-card base that works with glow */
  .glass-card {
    @apply bg-black/10 backdrop-blur-lg border border-white/20 rounded-xl shadow-xl;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    position: relative;
    z-index: 1; /* Ensure content is above glow effects */
  }

  /* Step 3: Enhanced Glow Variations */
  /* 5. Create a glass highlight effect for hover interactions */
  .glass-highlight {
    position: relative;
    overflow: hidden;
  }

  .glass-highlight::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    transform: scale(0);
    transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    z-index: 0;
    pointer-events: none; /* Explicitly disable pointer events */
  }

  .glass-highlight:hover::before {
    transform: scale(1);
  }

  /* Step 5: Color Customization - Simplified to just purple, green, red */
  /* Purple (default) */
  .glow-purple::after {
    background: radial-gradient(circle at top right, rgba(155, 135, 245, 0.4), transparent 70%);
    z-index: -1;
    pointer-events: none;
  }

  /* Green (positive data) */
  .glow-green::after {
    background: radial-gradient(circle at top right, rgba(34, 197, 94, 0.4), transparent 70%);
    z-index: -1;
    pointer-events: none;
  }

  /* Red (negative data) */
  .glow-red::after {
    background: radial-gradient(circle at top right, rgba(239, 68, 68, 0.4), transparent 70%);
    z-index: -1;
    pointer-events: none;
  }

  /* Step 6: Additional Enhancement Effects */
  /* 9. Hover animation for cards */
  .hover-float {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }

  .hover-float:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  }

  /* 10. Hover glow effect for interactive elements */
  .hover-glow {
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
  }

  .hover-glow:hover {
    box-shadow: 0 0 20px rgba(155, 135, 245, 0.3);
  }

  /* 10. Shimmer effect for loading states */
  .card-shimmer {
    position: relative;
    overflow: hidden;
  }

  .card-shimmer::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
      to bottom right,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.05) 50%,
      rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(30deg);
    animation: shimmer 6s linear infinite;
    z-index: 1;
  }

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

  /* Text gradient for headings */
  .text-gradient-heading {
    @apply bg-gradient-to-br from-white to-white/70 bg-clip-text text-transparent;
  }

  /* Frosted noise texture (optional, can be intensive) */
  .frosted-noise {
    position: relative;
  }
  .frosted-noise::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.02; /* Very subtle */
    pointer-events: none;
    z-index: 0;
  }

  /* Animations */
  @keyframes float {
    0%,
    100% {
      transform: translateY(0px) rotate(0deg);
    }
    33% {
      transform: translateY(-10px) rotate(1deg);
    }
    66% {
      transform: translateY(5px) rotate(-1deg);
    }
  }

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

  @keyframes slide-up {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .animate-slide-up {
    animation: slide-up 0.6s ease-out;
  }

  @keyframes fade-in {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .animate-fade-in {
    animation: fade-in 0.8s ease-out forwards;
    opacity: 0;
  }
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  @apply bg-transparent;
}
::-webkit-scrollbar-thumb {
  @apply bg-white/20 rounded-full;
}
::-webkit-scrollbar-thumb:hover {
  @apply bg-white/30;
}
