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

/* Definition of the design system. All colors, gradients, fonts, etc should be defined here. 
All colors MUST be HSL.
*/

@layer base {
  :root {
    /* ThrillWiki light theme - bright and vibrant */
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;

    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;

    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;

    /* Blue and purple thrill-inspired colors */
    --primary: 258 90% 66%; /* Deep vibrant purple */
    --primary-foreground: 0 0% 98%;
    --primary-glow: 258 100% 80%;

    --secondary: 216 87% 55%; /* Rich royal blue */
    --secondary-foreground: 0 0% 98%;

    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;

    --accent: 216 87% 55%; /* Bright blue for action */
    --accent-foreground: 0 0% 98%;

    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 98%;

    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 258 90% 66%;

    /* Theme park gradients */
    --gradient-primary: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--primary-glow)));
    --gradient-secondary: linear-gradient(135deg, hsl(var(--secondary)), hsl(var(--accent)));
    --gradient-hero: linear-gradient(135deg, hsl(258 90% 66%), hsl(216 87% 55%), hsl(210 100% 65%));
    --gradient-card: linear-gradient(145deg, hsl(0 0% 98%), hsl(240 4.8% 95.9%));

    /* Thrill shadows and effects */
    --shadow-glow: 0 0 40px hsl(var(--primary) / 0.4);
    --shadow-card: 0 10px 30px -10px hsl(var(--primary) / 0.3);
    --shadow-intense: 0 25px 50px -12px hsl(var(--primary) / 0.5);

    /* Animation variables */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);

    --radius: 0.5rem;

    --sidebar-background: 0 0% 98%;
    --sidebar-foreground: 240 5.3% 26.1%;
    --sidebar-primary: 240 5.9% 10%;
    --sidebar-primary-foreground: 0 0% 98%;
    --sidebar-accent: 240 4.8% 95.9%;
    --sidebar-accent-foreground: 240 5.9% 10%;
    --sidebar-border: 220 13% 91%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }

  .dark {
    /* Dark mode uses vibrant colors on dark backgrounds */
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;

    --card: 240 8% 7%;
    --card-foreground: 0 0% 98%;

    --popover: 240 8% 7%;
    --popover-foreground: 0 0% 98%;

    --primary: 258 90% 66%; /* Deep vibrant purple */
    --primary-foreground: 0 0% 98%;
    --primary-glow: 258 100% 80%;

    --secondary: 216 87% 55%; /* Rich royal blue */
    --secondary-foreground: 0 0% 98%;

    --muted: 240 5% 20%;
    --muted-foreground: 240 5% 64%;

    --accent: 216 87% 55%; /* Bright blue for action */
    --accent-foreground: 0 0% 98%;

    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 98%;

    --border: 240 6% 15%;
    --input: 240 6% 15%;
    --ring: 258 90% 66%;
    
    --gradient-card: linear-gradient(145deg, hsl(240 10% 5%), hsl(240 8% 7%));
    
    --sidebar-background: 240 5.9% 10%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-primary: 224.3 76.3% 48%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply bg-background text-foreground;
  }
}

/* Suppress ALL animations during initial queue render */
[data-initial-load="true"] * {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
}

/* Custom Uppy Photo Upload Styling */
@layer components {
  /* Uppy Dashboard customization to match theme */
  .uppy-Dashboard {
    @apply bg-card text-card-foreground border border-border rounded-lg;
    box-shadow: var(--shadow-card);
  }

  .uppy-Dashboard-inner {
    @apply bg-transparent;
  }

  .uppy-Dashboard-dropFilesHereHint {
    @apply text-muted-foreground;
  }

  .uppy-Dashboard-browse {
    @apply text-primary hover:text-primary-glow transition-colors duration-300;
  }

  .uppy-Dashboard-AddFiles {
    @apply bg-gradient-to-r from-primary to-secondary text-primary-foreground;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius);
    transition: var(--transition-smooth);
  }

  .uppy-Dashboard-AddFiles:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
  }

  .uppy-Dashboard-AddFiles-info {
    @apply text-primary-foreground;
  }

  .uppy-Dashboard-Item {
    @apply bg-card border border-border rounded-lg;
  }

  .uppy-Dashboard-Item-preview {
    @apply rounded-lg overflow-hidden;
  }

  .uppy-Dashboard-Item-progress {
    @apply bg-muted;
  }

  .uppy-Dashboard-Item-progressIndicator {
    @apply bg-primary;
  }

  .uppy-Dashboard-Item-action--remove {
    @apply text-destructive hover:text-destructive-foreground hover:bg-destructive;
    transition: var(--transition-smooth);
  }

  .uppy-Dashboard-Item-action--edit {
    @apply text-accent hover:text-accent-foreground hover:bg-accent;
    transition: var(--transition-smooth);
  }

  /* Modal overlay styling */
  .uppy-Dashboard--modal {
    z-index: 9999 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
  }

  .uppy-Dashboard--modal .uppy-Dashboard-overlay {
    @apply bg-background/80 backdrop-blur-sm;
    z-index: 9998 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  .uppy-Dashboard--modal .uppy-Dashboard-inner {
    @apply bg-card border border-border rounded-xl;
    box-shadow: var(--shadow-intense);
    max-width: 90vw;
    max-height: 90vh;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 10000 !important;
  }

  /* Ensure all uppy content stays contained */
  .uppy-Dashboard--modal * {
    position: relative !important;
  }

  .uppy-Dashboard--modal .uppy-Dashboard-AddFiles,
  .uppy-Dashboard--modal .uppy-Dashboard-dropFilesHereHint {
    position: static !important;
  }

  /* Status bar customization */
  .uppy-StatusBar {
    @apply bg-muted border-t border-border;
  }

  .uppy-StatusBar-progress {
    @apply bg-primary;
  }

  .uppy-StatusBar-actions {
    @apply gap-2;
  }

  .uppy-StatusBar-actionBtn {
    @apply bg-primary text-primary-foreground hover:bg-primary/90;
    border: none;
    border-radius: var(--radius);
    transition: var(--transition-smooth);
  }

  .uppy-StatusBar-actionBtn:hover {
    transform: translateY(-1px);
  }

  /* Image editor customization */
  .uppy-ImageEditor {
    @apply bg-card text-card-foreground;
  }

  .uppy-ImageEditor-controls {
    @apply bg-muted border-t border-border;
  }

  .uppy-ImageEditor-controls button {
    @apply text-foreground hover:text-primary;
    transition: var(--transition-smooth);
  }

  /* Custom upload trigger styling */
  .photo-upload-trigger {
    @apply relative overflow-hidden;
    background: var(--gradient-primary);
    transition: var(--transition-smooth);
  }

  .photo-upload-trigger:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
  }

  .photo-upload-trigger::before {
    content: '';
    @apply absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent;
    transform: translateX(-100%);
    transition: transform 0.6s ease;
  }

  .photo-upload-trigger:hover::before {
    transform: translateX(100%);
  }

  /* Upload preview grid */
  .upload-preview-grid {
    @apply grid gap-4;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .upload-preview-item {
    @apply relative aspect-square rounded-lg overflow-hidden border border-border;
    background: var(--gradient-card);
    transition: var(--transition-smooth);
  }

  .upload-preview-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-card);
  }

  .upload-preview-item img {
    @apply w-full h-full object-cover;
  }

  .upload-preview-overlay {
    @apply absolute inset-0 bg-black/40 opacity-0 hover:opacity-100 flex items-center justify-center;
    transition: var(--transition-smooth);
  }

  /* Loading states */
  .upload-loading {
    @apply relative;
  }

  .upload-loading::after {
    content: '';
    @apply absolute inset-0 bg-primary/10 rounded-lg;
    animation: pulse 2s infinite;
  }

  /* Mobile optimizations */
  @media (max-width: 640px) {
    .uppy-Dashboard--modal .uppy-Dashboard-inner {
      @apply m-4 max-h-[80vh];
    }
    
    .upload-preview-grid {
      grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
      @apply gap-2;
    }
  }

  /* Dark mode specific adjustments */
  .dark .uppy-Dashboard {
    border-color: hsl(var(--border));
  }

  .dark .uppy-Dashboard-Item {
    background-color: hsl(var(--card));
    border-color: hsl(var(--border));
  }
}

/* Smooth queue transitions */
.queue-fade-enter {
  animation: queueFadeIn 300ms ease-in-out;
}

.queue-fade-exit {
  animation: queueFadeOut 200ms ease-in-out;
}

@keyframes queueFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes queueFadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Performance optimizations for queue items */
.queue-item-container {
  contain: layout style paint;
  will-change: transform, opacity;
  content-visibility: auto;
  contain-intrinsic-size: 0 200px;
}

/* Enhanced list view animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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