@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 {
    --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% 46.9%;

    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;

    --destructive: 0 84.2% 45.2%;
    --destructive-foreground: 0 0% 100%;

    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 84% 4.9%;

    /* Banking UI Colors - WCAG AA compliant contrast ratios */
    --bank-green: 142 85% 16%;
    --bank-green-foreground: 0 0% 100%;
    --bank-green-muted: 142 50% 85%;
    --bank-blue: 210 100% 40%;
    --bank-blue-foreground: 0 0% 100%;
    --bank-light-green: 142 50% 95%;
    --bank-gray: 210 10% 96%;
    --bank-text-dark: 220 10% 20%;
    --bank-red: 0 84% 45%;
    --bank-red-foreground: 0 0% 100%;

    --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% 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: 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%;
  }
}

/* Mobile-First Typography and Responsive Design */
@layer base {
  html {
    font-size: 16px; /* Base size for desktop */
  }
  
  /* Smaller base font size for mobile */
  @media (max-width: 640px) {
    html {
      font-size: 14px;
    }
  }
  
  * {
    @apply border-border;
  }

  body {
    @apply bg-background text-foreground;
    /* Improve mobile text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  
  /* Touch-friendly improvements */
  button, 
  [role="button"], 
  input, 
  select, 
  textarea {
    @apply min-h-[44px]; /* Minimum touch target size */
  }
}

/* Performance optimizations to prevent forced reflows */
@layer components {
  .carousel-optimized {
    will-change: transform;
    contain: layout style paint;
    transform: translateZ(0); /* Force hardware acceleration */
    backface-visibility: hidden;
  }
  
  .carousel-optimized .carousel .slider-wrapper,
  .carousel-optimized .carousel .slider {
    will-change: transform;
    contain: layout style;
    transform: translateZ(0);
    backface-visibility: hidden;
  }
  
  .carousel-optimized .carousel .slide {
    will-change: auto;
    contain: layout style paint;
    transform: translateZ(0);
  }

  /* Additional performance optimizations */
  .carousel-optimized * {
    box-sizing: border-box;
  }

  /* Prevent layout shifts in dynamic content */
  .carousel-optimized .carousel-status,
  .carousel-optimized .control-arrow {
    contain: layout;
  }

  /* Image optimization hints */
  img[loading="lazy"] {
    content-visibility: auto;
    contain-intrinsic-size: 416px 312px;
  }

  /* Specific size hints for different image contexts */
  .aspect-video img {
    contain-intrinsic-size: 416px 234px;
  }

  .h-32 img, 
  img.h-32 {
    contain-intrinsic-size: 384px 128px;
  }

  .h-16 img,
  img.h-16 {
    contain-intrinsic-size: 64px 64px;
  }

  /* Fix touch target size for Lovable badge close button */
  #lovable-badge-close {
    min-width: 24px !important;
    min-height: 24px !important;
    padding: 4px !important;
  }

  /* Hide carousel indicators to fix ARIA role issues */
  .carousel .control-dots {
    display: none !important;
  }
  
  /* Mobile Optimization Classes */
  .mobile-container {
    @apply px-4 sm:px-6 lg:px-8;
  }
  
  .mobile-text {
    @apply text-sm sm:text-base lg:text-lg;
  }
  
  .mobile-heading {
    @apply text-lg sm:text-xl lg:text-2xl;
  }
  
  .mobile-hero-heading {
    @apply text-2xl sm:text-3xl lg:text-4xl xl:text-5xl;
  }
  
  .mobile-card {
    @apply p-4 sm:p-6 lg:p-8;
  }
  
  .mobile-button {
    @apply py-3 px-4 text-base font-medium;
  }
  
  /* Mobile-specific improvements */
  @media (max-width: 640px) {
    .mobile-scroll {
      overflow-x: auto;
      scrollbar-width: none;
      -ms-overflow-style: none;
    }
    
    .mobile-scroll::-webkit-scrollbar {
      display: none;
    }
    
    /* Better mobile carousel */
    .carousel .slider-wrapper {
      border-radius: 12px;
      overflow: hidden;
    }
    
    /* Improve mobile form elements */
    input, 
    textarea, 
    select {
      font-size: 16px !important; /* Prevent zoom on iOS */
    }
    
    /* Mobile navigation improvements */
    .mobile-nav {
      @apply fixed inset-x-0 top-0 z-50 bg-white shadow-lg;
    }
  }
  
  /* Tablet optimizations */
  @media (min-width: 641px) and (max-width: 1024px) {
    .tablet-grid {
      @apply grid-cols-2;
    }
  }
}