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

/* ========================================
   CSS Variables
   ======================================== */
:root {
  /* Base colors - slightly warmer dark tones */
  --color-dark-950: #08090d;
  --color-dark-900: #0d0e14;
  --color-dark-800: #14161e;
  --color-dark-700: #1c1e28;
  --color-dark-600: #252732;
  --color-dark-500: #2e313d;

  /* Soft cyan (primary) - gentler on eyes */
  --color-neon-500: #22d3ee;
  --color-neon-400: #67e8f9;
  --color-neon-600: #06b6d4;

  /* Soft violet accent */
  --color-accent-500: #8b5cf6;
  --color-accent-600: #7c3aed;
  --color-accent-700: #6d28d9;

  /* Soft pink highlight - used sparingly */
  --color-pink-500: #f472b6;

  /* Glow colors - reduced intensity */
  --glow-neon: 0 0 8px rgba(34, 211, 238, 0.4), 0 0 16px rgba(34, 211, 238, 0.2);
  --glow-neon-lg: 0 0 12px rgba(34, 211, 238, 0.5), 0 0 24px rgba(34, 211, 238, 0.3);
  --glow-purple: 0 0 8px rgba(139, 92, 246, 0.4), 0 0 16px rgba(139, 92, 246, 0.2);
  --glow-pink: 0 0 8px rgba(244, 114, 182, 0.4), 0 0 16px rgba(244, 114, 182, 0.2);

  /* Text glow - subtle */
  --text-glow-neon: 0 0 8px rgba(34, 211, 238, 0.5), 0 0 16px rgba(34, 211, 238, 0.25);
  --text-glow-purple: 0 0 8px rgba(139, 92, 246, 0.5), 0 0 16px rgba(139, 92, 246, 0.25);
}

/* ========================================
   Base Styles
   ======================================== */
html {
  scroll-behavior: smooth;
}

body {
  @apply bg-dark-900 text-gray-100 min-h-screen antialiased;
  font-family: 'Inter', system-ui, sans-serif;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.015) 1px, transparent 1px);
  background-size: 50px 50px;
  background-attachment: fixed;
}

/* Noise overlay - can be added to any element */
.noise-overlay::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.03;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Autofill styles - override browser defaults */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px #14161e inset !important;
  -webkit-text-fill-color: #fff !important;
  caret-color: #fff;
  transition: background-color 5000s ease-in-out 0s;
}

/* ========================================
   Selection Styles
   ======================================== */
::selection {
  background: rgba(34, 211, 238, 0.25);
  color: #fff;
}

::-moz-selection {
  background: rgba(34, 211, 238, 0.25);
  color: #fff;
}

/* ========================================
   Custom Scrollbar (Neon Style)
   ======================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-dark-800);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--color-neon-500), var(--color-accent-500));
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--color-neon-400), var(--color-accent-600));
}

::-webkit-scrollbar-corner {
  background: var(--color-dark-800);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-neon-500) var(--color-dark-800);
}

/* Custom scrollbar class for specific elements */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

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

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--color-dark-500);
  border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--color-neon-500);
}

/* ========================================
   Glitch Effect
   ======================================== */
.glitch {
  position: relative;
  animation: glitch-skew 1s infinite linear alternate-reverse;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  left: 2px;
  text-shadow: -2px 0 rgba(139, 92, 246, 0.7);
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: -2px 0 rgba(34, 211, 238, 0.7), 2px 2px rgba(139, 92, 246, 0.7);
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
  0% { clip: rect(31px, 9999px, 94px, 0); transform: skew(0.85deg); }
  5% { clip: rect(70px, 9999px, 71px, 0); transform: skew(0.07deg); }
  10% { clip: rect(29px, 9999px, 24px, 0); transform: skew(0.22deg); }
  15% { clip: rect(69px, 9999px, 63px, 0); transform: skew(0.52deg); }
  20% { clip: rect(13px, 9999px, 71px, 0); transform: skew(0.72deg); }
  25% { clip: rect(39px, 9999px, 89px, 0); transform: skew(0.24deg); }
  30% { clip: rect(87px, 9999px, 98px, 0); transform: skew(0.63deg); }
  35% { clip: rect(63px, 9999px, 16px, 0); transform: skew(0.15deg); }
  40% { clip: rect(92px, 9999px, 4px, 0); transform: skew(0.83deg); }
  45% { clip: rect(67px, 9999px, 72px, 0); transform: skew(0.19deg); }
  50% { clip: rect(43px, 9999px, 21px, 0); transform: skew(0.74deg); }
  55% { clip: rect(75px, 9999px, 54px, 0); transform: skew(0.28deg); }
  60% { clip: rect(17px, 9999px, 86px, 0); transform: skew(0.91deg); }
  65% { clip: rect(51px, 9999px, 32px, 0); transform: skew(0.46deg); }
  70% { clip: rect(29px, 9999px, 69px, 0); transform: skew(0.38deg); }
  75% { clip: rect(84px, 9999px, 11px, 0); transform: skew(0.67deg); }
  80% { clip: rect(38px, 9999px, 82px, 0); transform: skew(0.12deg); }
  85% { clip: rect(61px, 9999px, 47px, 0); transform: skew(0.54deg); }
  90% { clip: rect(22px, 9999px, 91px, 0); transform: skew(0.33deg); }
  95% { clip: rect(79px, 9999px, 28px, 0); transform: skew(0.79deg); }
  100% { clip: rect(56px, 9999px, 65px, 0); transform: skew(0.41deg); }
}

@keyframes glitch-anim2 {
  0% { clip: rect(65px, 9999px, 100px, 0); transform: skew(0.63deg); }
  5% { clip: rect(52px, 9999px, 74px, 0); transform: skew(0.29deg); }
  10% { clip: rect(79px, 9999px, 85px, 0); transform: skew(0.84deg); }
  15% { clip: rect(43px, 9999px, 27px, 0); transform: skew(0.17deg); }
  20% { clip: rect(16px, 9999px, 92px, 0); transform: skew(0.56deg); }
  25% { clip: rect(88px, 9999px, 36px, 0); transform: skew(0.39deg); }
  30% { clip: rect(32px, 9999px, 68px, 0); transform: skew(0.71deg); }
  35% { clip: rect(71px, 9999px, 13px, 0); transform: skew(0.23deg); }
  40% { clip: rect(24px, 9999px, 57px, 0); transform: skew(0.92deg); }
  45% { clip: rect(83px, 9999px, 41px, 0); transform: skew(0.48deg); }
  50% { clip: rect(19px, 9999px, 79px, 0); transform: skew(0.35deg); }
  55% { clip: rect(67px, 9999px, 23px, 0); transform: skew(0.76deg); }
  60% { clip: rect(45px, 9999px, 96px, 0); transform: skew(0.14deg); }
  65% { clip: rect(91px, 9999px, 51px, 0); transform: skew(0.58deg); }
  70% { clip: rect(28px, 9999px, 83px, 0); transform: skew(0.87deg); }
  75% { clip: rect(76px, 9999px, 19px, 0); transform: skew(0.26deg); }
  80% { clip: rect(53px, 9999px, 67px, 0); transform: skew(0.69deg); }
  85% { clip: rect(14px, 9999px, 89px, 0); transform: skew(0.43deg); }
  90% { clip: rect(62px, 9999px, 34px, 0); transform: skew(0.81deg); }
  95% { clip: rect(37px, 9999px, 76px, 0); transform: skew(0.52deg); }
  100% { clip: rect(86px, 9999px, 48px, 0); transform: skew(0.31deg); }
}

@keyframes glitch-skew {
  0% { transform: skew(-2deg); }
  10% { transform: skew(1deg); }
  20% { transform: skew(-1deg); }
  30% { transform: skew(0deg); }
  40% { transform: skew(2deg); }
  50% { transform: skew(-1deg); }
  60% { transform: skew(1deg); }
  70% { transform: skew(0deg); }
  80% { transform: skew(-2deg); }
  90% { transform: skew(1deg); }
  100% { transform: skew(0deg); }
}

/* Simpler glitch for hover states */
.glitch-hover:hover {
  animation: glitch-simple 0.3s ease;
}

@keyframes glitch-simple {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
}

/* ========================================
   Neon Glow Effects
   ======================================== */
.neon-glow {
  box-shadow: var(--glow-neon);
}

.neon-glow-lg {
  box-shadow: var(--glow-neon-lg);
}

.neon-glow-purple {
  box-shadow: var(--glow-purple);
}

.neon-glow-pink {
  box-shadow: var(--glow-pink);
}

.neon-text {
  text-shadow: var(--text-glow-neon);
}

.neon-text-purple {
  text-shadow: var(--text-glow-purple);
}

/* Animated glow */
.neon-glow-pulse {
  animation: neon-pulse 2s ease-in-out infinite;
}

@keyframes neon-pulse {
  0%, 100% {
    box-shadow: 0 0 6px rgba(34, 211, 238, 0.4), 0 0 12px rgba(34, 211, 238, 0.2);
  }
  50% {
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.5), 0 0 20px rgba(34, 211, 238, 0.3);
  }
}

/* ========================================
   Glass Effect (Glassmorphism)
   ======================================== */
.glass {
  background: rgba(18, 18, 26, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-dark {
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.glass-neon {
  background: rgba(20, 22, 30, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(34, 211, 238, 0.15);
  box-shadow: inset 0 0 20px rgba(34, 211, 238, 0.03);
}

/* ========================================
   Gradient Utilities
   ======================================== */
.gradient-neon {
  background: linear-gradient(135deg, #22d3ee, #8b5cf6);
}

.gradient-neon-text {
  background: linear-gradient(135deg, #22d3ee, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-pink-purple {
  background: linear-gradient(135deg, #f472b6, #8b5cf6);
}

.gradient-dark {
  background: linear-gradient(180deg, var(--color-dark-900), var(--color-dark-950));
}

/* Animated gradient border */
.gradient-border {
  position: relative;
  background: var(--color-dark-800);
  border-radius: 12px;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(90deg, #22d3ee, #8b5cf6, #f472b6, #22d3ee);
  background-size: 300% 300%;
  border-radius: 14px;
  z-index: -1;
  animation: gradient-flow 3s linear infinite;
}

@keyframes gradient-flow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ========================================
   Shimmer Effect
   ======================================== */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% { left: 100%; }
}

/* ========================================
   Component Layer
   ======================================== */
@layer components {
  /* Buttons */
  .btn {
    @apply px-4 py-2 rounded-lg font-medium transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed;
  }

  .btn-primary {
    @apply bg-neon-500 hover:bg-neon-400 text-dark-900 font-semibold;
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.25);
  }

  .btn-primary:hover {
    box-shadow: 0 0 14px rgba(34, 211, 238, 0.4);
  }

  .btn-secondary {
    @apply bg-dark-600 hover:bg-dark-500 text-white border border-dark-500;
  }

  .btn-danger {
    @apply bg-red-600 hover:bg-red-700 text-white;
  }

  .btn-ghost {
    @apply bg-transparent hover:bg-dark-700 text-gray-300 hover:text-white;
  }

  .btn-neon {
    @apply relative bg-transparent border-2 border-neon-500 text-neon-500 font-semibold overflow-hidden;
    transition: all 0.3s ease;
  }

  .btn-neon:hover {
    @apply text-dark-900;
    background: var(--color-neon-500);
    box-shadow: 0 0 14px rgba(34, 211, 238, 0.4);
  }

  /* Inputs */
  .input {
    @apply w-full px-4 py-3 bg-dark-800 border border-dark-600 rounded-lg text-white placeholder-gray-500 transition-all duration-200;
  }

  .input:focus {
    @apply outline-none border-neon-500;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1), 0 0 8px rgba(34, 211, 238, 0.15);
  }

  /* Cards */
  .card {
    @apply bg-dark-800 rounded-xl p-6 border border-dark-600;
  }

  .card-glass {
    @apply rounded-xl p-6;
    background: rgba(20, 22, 30, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .card-hover {
    @apply transition-all duration-300;
  }

  .card-hover:hover {
    @apply -translate-y-1;
    box-shadow: 0 10px 40px rgba(34, 211, 238, 0.08);
    border-color: rgba(34, 211, 238, 0.25);
  }

  /* Links */
  .link {
    @apply text-neon-500 hover:text-neon-400 transition-colors;
  }

  /* Badges */
  .badge {
    @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
  }

  .badge-neon {
    @apply bg-neon-500/20 text-neon-400 border border-neon-500/30;
  }

  .badge-purple {
    @apply bg-accent-500/20 text-accent-400 border border-accent-500/30;
  }

  .badge-pink {
    @apply bg-pink-500/20 text-pink-400 border border-pink-500/30;
  }

  /* Dividers */
  .divider {
    @apply border-t border-dark-600;
  }

  .divider-glow {
    @apply border-t border-neon-500/30;
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.15);
  }
}

/* ========================================
   Utility Animations
   ======================================== */
.hover-lift {
  @apply transition-transform duration-300;
}

.hover-lift:hover {
  @apply -translate-y-1;
}

.hover-glow {
  @apply transition-shadow duration-300;
}

.hover-glow:hover {
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.25);
}

.hover-border-glow {
  @apply transition-all duration-300;
}

.hover-border-glow:hover {
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
}

/* Stagger children animations */
.stagger-children > * {
  @apply animate-slide-in-up;
  animation-fill-mode: both;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }

/* ========================================
   Skeleton Loading
   ======================================== */
.skeleton {
  @apply relative overflow-hidden bg-dark-700 rounded;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.05),
    transparent
  );
  animation: skeleton-pulse 1.5s infinite;
}

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

/* ========================================
   Focus States (Accessibility)
   ======================================== */
.focus-ring {
  @apply focus:outline-none focus:ring-2 focus:ring-neon-500 focus:ring-offset-2 focus:ring-offset-dark-900;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
