@import 'tailwindcss';

@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));

@layer base {
  :root,
  html[data-theme="light"] {
    --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: 217.2 91.2% 59.8%;
    --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: 217.2 91.2% 59.8%;
    --radius: 0.5rem;
  }

  html[data-theme="dark"] {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;
    --card: 222.2 84% 8%;
    --card-foreground: 210 40% 98%;
    --popover: 222.2 84% 8%;
    --popover-foreground: 210 40% 98%;
    --primary: 217.2 91.2% 59.8%;
    --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: 224.3 76.3% 48%;
  }

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

  /* View Transitions API for smooth theme switching (Safari 18+, Chrome 111+) */
  :root {
    view-transition-name: root;
  }
  
  /* Apply to html element as well for better compatibility */
  html {
    view-transition-name: root;
  }
  
  /* Ensure smooth transition between light and dark themes */
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.25s;
  }
  
  /* Customize the transition style */
  ::view-transition-old(root) {
    animation: fade-out 0.25s ease-out;
  }
  
  ::view-transition-new(root) {
    animation: fade-in 0.25s ease-out;
  }
  
  @keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
  }
  
  @keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

@theme {
  --font-family-sans: 'Inter', system-ui, sans-serif;
  
  /* Define custom colors */
  --color-background: hsl(var(--background));
  --color-foreground: hsl(var(--foreground));
  --color-card: hsl(var(--card));
  --color-card-foreground: hsl(var(--card-foreground));
  --color-popover: hsl(var(--popover));
  --color-popover-foreground: hsl(var(--popover-foreground));
  --color-primary: hsl(var(--primary));
  --color-primary-foreground: hsl(var(--primary-foreground));
  --color-secondary: hsl(var(--secondary));
  --color-secondary-foreground: hsl(var(--secondary-foreground));
  --color-muted: hsl(var(--muted));
  --color-muted-foreground: hsl(var(--muted-foreground));
  --color-accent: hsl(var(--accent));
  --color-accent-foreground: hsl(var(--accent-foreground));
  --color-destructive: hsl(var(--destructive));
  --color-destructive-foreground: hsl(var(--destructive-foreground));
  --color-border: hsl(var(--border));
  --color-input: hsl(var(--input));
  --color-ring: hsl(var(--ring));
}

/* Animations for popover */
@keyframes animate-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes animate-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes zoom-in {
  from {
    transform: scale(0.95);
  }
  to {
    transform: scale(1);
  }
}

@keyframes zoom-out {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(0.95);
  }
}

@keyframes slide-in-from-top {
  from {
    transform: translateY(-10px);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slide-in-from-left {
  from {
    transform: translateX(-10px);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slide-in-from-right {
  from {
    transform: translateX(10px);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slide-in-from-bottom {
  from {
    transform: translateY(10px);
  }
  to {
    transform: translateY(0);
  }
}

/* Utility classes for animations */
.animate-in {
  animation: animate-in 200ms ease-out;
}

.animate-out {
  animation: animate-out 200ms ease-in;
}

.fade-in-0 {
  animation: fade-in 200ms ease-out;
}

.fade-out-0 {
  animation: fade-out 200ms ease-in;
}

.zoom-in-95 {
  animation: zoom-in 200ms ease-out;
}

.zoom-out-95 {
  animation: zoom-out 200ms ease-in;
}

.slide-in-from-top-2 {
  animation: slide-in-from-top 200ms ease-out;
}

.slide-in-from-left-2 {
  animation: slide-in-from-left 200ms ease-out;
}

.slide-in-from-right-2 {
  animation: slide-in-from-right 200ms ease-out;
}

.slide-in-from-bottom-2 {
  animation: slide-in-from-bottom 200ms ease-out;
}

@keyframes splash {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.animate-pulse-ring {
  animation: pulse-ring 2s infinite;
}

/* Activity log animations */
@keyframes slide-down {
  from {
    max-height: 0;
    opacity: 0;
  }
  to {
    max-height: 12rem; /* 48 in Tailwind = 12rem */
    opacity: 1;
  }
}

@keyframes slide-up {
  from {
    max-height: 12rem;
    opacity: 1;
  }
  to {
    max-height: 0;
    opacity: 0;
  }
}

.activity-log-container {
  transition: max-height 300ms ease-out, opacity 300ms ease-out;
}

.activity-log-container.show {
  max-height: 12rem;
  height: 12rem; /* Fixed height for proper scrolling */
  opacity: 1;
}

.activity-log-container.hide {
  max-height: 0;
  height: 0;
  opacity: 0;
  overflow: hidden; /* Only hide overflow when collapsed */
}
