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

@layer base {
  :root {
    --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: 222.2 47.4% 11.2%;
    --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% 36.9%; /* Darkened for better contrast */

    --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: 222.2 84% 4.9%;

    --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 {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;

    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;

    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;

    --primary: 210 40% 98%;
    --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% 75.1%; /* Lightened for better contrast */

    --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: 212.7 26.8% 83.9%;
    --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;
  }
  
  /* Improved focus outline for accessibility */
  :focus-visible {
    @apply outline-2 outline-offset-2 outline-primary/70 ring-0;
  }

  /* Content loading optimization */
  img, svg, video, canvas, audio, iframe, embed, object {
    @apply block max-w-full;
  }
  
  /* Improved image rendering for certain scenarios */
  img {
    image-rendering: auto;
  }
}

@layer utilities {
  .animate-fade-in {
    animation: fadeIn 0.3s ease-in-out;
  }

  .animate-float {
    animation: float 3s ease-in-out infinite;
  }
  
  .animate-in {
    animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
    will-change: transform, opacity;
  }
  
  .fade-in {
    animation: fadeIn 0.5s;
  }
  
  .slide-in-from-top {
    animation: slideInFromTop 0.3s forwards;
  }
  
  .slide-in-from-bottom {
    animation: slideInFromBottom 0.3s forwards;
  }
  
  /* Content visibility optimizations */
  .content-visibility-auto {
    content-visibility: auto;
  }
  
  .backface-hidden {
    backface-visibility: hidden;
  }
  
  .will-change-opacity {
    will-change: opacity;
  }
  
  .will-change-transform {
    will-change: transform;
  }
  
  .hardware-accelerated {
    transform: translateZ(0);
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  @keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
  }
  
  @keyframes slideInFromTop {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  
  @keyframes slideInFromBottom {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
}

@layer components {
  .nav-link {
    @apply relative inline-flex items-center text-sm font-medium transition-colors hover:text-foreground/80;
  }
  
  .nav-link.active {
    @apply text-foreground after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:bg-foreground;
  }
  
  .hover-card {
    @apply transition-all duration-200 hover:shadow-md;
  }
  
  /* Performance optimized card hover */
  .perf-card {
    @apply transition-shadow duration-200;
  }
  
  .perf-card:hover {
    @apply shadow-md;
  }
  
  /* Improved button loading state */
  .btn-loading {
    @apply relative overflow-hidden;
  }
  
  .btn-loading:before {
    content: "";
    @apply absolute inset-0 bg-primary/10 animate-pulse;
  }
}

/* Web Vitals optimizations */
@media screen and (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Print styles for better print functionality */
@media print {
  body {
    background: white;
    color: black;
  }
  
  .no-print {
    display: none !important;
  }
  
  a {
    text-decoration: underline;
    color: blue;
  }
  
  .page-break {
    page-break-after: always;
  }
}
