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


@layer base {
  :root {
    /* Base */
    --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%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --radius: 1rem;

    /* Template 1: Minimal */
    --template1: 220 14% 96%;
    --template1-foreground: 220 70% 17%;

    /* Template 2: Vibrant */
    --template2: 262 83% 58%;
    --template2-foreground: 0 0% 100%;

    /* Template 3: Elegant */
    --template3: 200 98% 39%;
    --template3-foreground: 0 0% 100%;
  }

  .dark {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 3.9%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 3.9%;
    --popover-foreground: 0 0% 98%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 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% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 240 4.9% 83.9%;

    /* Template 1: Minimal Dark */
    --template1: 220 14% 10%;
    --template1-foreground: 220 14% 96%;

    /* Template 2: Vibrant Dark */
    --template2: 262 50% 30%;
    --template2-foreground: 0 0% 100%;

    /* Template 3: Elegant Dark */
    --template3: 200 70% 20%;
    --template3-foreground: 0 0% 100%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  
  body {
    @apply bg-background text-foreground antialiased;
    font-feature-settings: "rlig" 1, "calt" 1;
  }

  html {
    @apply scroll-smooth;
  }
}

/* Template specific base styles */
.template-minimal {
  --radius: 0.5rem;
}

.template-vibrant {
  --radius: 1rem;
  --primary: 262 83% 58%;
  --primary-foreground: 0 0% 100%;
  --secondary: 262 83% 96%;
  --secondary-foreground: 262 83% 28%;
}

.template-elegant {
  --radius: 0.25rem;
  --primary: 200 98% 39%;
  --primary-foreground: 0 0% 100%;
  --secondary: 200 98% 95%;
  --secondary-foreground: 200 98% 20%;
}

.dark.template-minimal {
  --radius: 0.5rem;
}

.dark.template-vibrant {
  --radius: 1rem;
  --primary: 262 50% 60%;
  --primary-foreground: 0 0% 100%;
  --secondary: 262 50% 30%;
  --secondary-foreground: 0 0% 100%;
}

.dark.template-elegant {
  --radius: 0.25rem;
  --primary: 200 70% 45%;
  --primary-foreground: 0 0% 100%;
  --secondary: 200 70% 20%;
  --secondary-foreground: 0 0% 100%;
}

@layer components {
  /* Glass morphism styles */
  .glass {
    @apply bg-white/10 backdrop-blur-lg border border-white/20;
  }
  
  .dark .glass {
    @apply bg-black/20 backdrop-blur-lg border border-white/10;
  }
  
  /* Message container styles */
  .message-container {
    @apply rounded-lg p-4 mb-4 max-w-[85%] animate-fade-in;
  }
  
  .user-message {
    @apply bg-primary text-primary-foreground ml-auto;
  }
  
  .ai-message {
    @apply bg-secondary text-secondary-foreground mr-auto;
  }
  
  /* Custom scrollbar */
  .custom-scrollbar::-webkit-scrollbar {
    width: 6px;
  }
  
  .custom-scrollbar::-webkit-scrollbar-track {
    @apply bg-transparent;
  }
  
  .custom-scrollbar::-webkit-scrollbar-thumb {
    @apply bg-muted-foreground/30 rounded-full;
  }
  
  .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    @apply bg-muted-foreground/50;
  }
  
  /* Sources container styles */
  .sources-container {
    @apply flex overflow-x-auto py-2 gap-3 pb-1 mt-2 -mx-2 px-2 custom-scrollbar;
    @apply max-w-full relative;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    width: calc(100% + 1rem); /* Compensate for negative margins */
    margin-bottom: 0.5rem;
  }
  
  .source-link {
    @apply px-3 py-1.5 bg-secondary/50 hover:bg-secondary text-secondary-foreground rounded-full text-sm whitespace-nowrap flex-shrink-0 transition-all;
    @apply relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  }
  
  .source-link:hover::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent var(--background) transparent;
    z-index: 52;
  }
  
  .source-link:hover::after {
    content: attr(data-website-title);
    position: absolute;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    height: 110px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    z-index: 51;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: 500;
    color: var(--foreground);
    overflow: hidden;
    white-space: normal;
  }
  
  .source-link:hover::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'%3E%3C/circle%3E%3Cpolyline points='21 15 16 10 5 21'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center 65%;
    background-size: 32px;
    padding-top: 16px;
  }
  
  .dark .source-link {
    @apply bg-muted/50 hover:bg-muted;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  }
  
  .dark .source-link:hover::before {
    border-color: transparent transparent var(--background) transparent;
  }

  /* Add CSS for the preview-below class */
  .source-link.preview-below:hover::before {
    top: auto;
    bottom: -10px;
    border-color: var(--background) transparent transparent transparent;
  }
  
  .source-link.preview-below:hover::after {
    top: auto;
    bottom: -120px;
  }
}


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

.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

@keyframes bounceSlow {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.animate-bounce-slow {
  animation: bounceSlow 2s ease-in-out infinite;
}

/* Add pulse animation */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.9;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.animate-pulse-icon {
  animation: pulse 2s ease-in-out infinite;
}

@layer utilities {
  /* Fade-in animation */
  .animated-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* Typing animation for AI responses */
  .typing-animation::after {
    content: "|";
    animation: blink 1s infinite;
  }
  
  @keyframes blink {
    50% { opacity: 0; }
  }
}

/* Reasoning placeholder animation */
.reasoning-placeholder {
  display: flex;
  align-items: center;
  font-style: italic;
  color: var(--muted-foreground);
  opacity: 0.9;
  padding: 0.5rem 0;
}

.reasoning-placeholder::after {
  content: "...";
  width: 1.25em;
  animation: reasoning-dots 1.4s infinite;
  display: inline-block;
  text-align: left;
  margin-left: 4px;
}

@keyframes reasoning-dots {
  0%, 20% {
    content: ".";
  }
  40%, 60% {
    content: "..";
  }
  80%, 100% {
    content: "...";
  }
}

/* Template-specific reasoning placeholder styles */
.template-vibrant .reasoning-placeholder {
  color: var(--secondary-foreground);
}

.template-elegant .reasoning-placeholder {
  color: var(--secondary-foreground);
  font-weight: 500;
}

