@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap');

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

@layer base {
  html {
    font-size: 18px;
    scroll-behavior: smooth;
  }

  @media (max-width: 380px) {
    html {
      font-size: 14px;
    }
  }

  @media (min-width: 1280px) {
    html {
      font-size: 20px;
    }
  }

  html {
    scroll-padding-top: 100px;
  }

  body {
    @apply font-sans text-steel-800 antialiased;
    overflow-x: hidden;
    background: #fafafa;
  }

  h1, h2, h3, h4, h5, h6 {
    @apply font-sans tracking-tight;
  }

  ::-webkit-scrollbar {
    width: 10px;
  }

  ::-webkit-scrollbar-track {
    @apply bg-steel-50;
  }

  ::-webkit-scrollbar-thumb {
    @apply bg-steel-400 rounded-full;
  }

  ::-webkit-scrollbar-thumb:hover {
    @apply bg-steel-500;
  }
}

@layer components {
  /* ========================================
     MODERN INDUSTRIAL DESIGN SYSTEM
     ======================================== */

  /* ---- Card Styles ---- */
  .card {
    @apply bg-white rounded-lg overflow-hidden transition-all duration-300;
  }

  .card-hover {
    @apply bg-white rounded-lg overflow-hidden transition-all duration-300;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  }

  .card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  }

  /* ---- Gradient Buttons ---- */
  .btn-primary {
    @apply bg-gradient-to-r from-primary-600 to-primary-500 text-white px-8 py-4 rounded-lg
            font-semibold tracking-wide transition-all duration-200;
    box-shadow: 0 4px 0 #15803d, 0 6px 12px rgba(21, 128, 61, 0.25);
  }

  .btn-primary:hover {
    @apply from-primary-500 to-primary-400;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #15803d, 0 10px 20px rgba(21, 128, 61, 0.3);
  }

  .btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #15803d, 0 2px 6px rgba(21, 128, 61, 0.2);
  }

  .btn-white {
    @apply bg-white text-primary-700 px-5 py-3 rounded-lg
            font-semibold tracking-wide transition-all duration-200 text-sm;
    box-shadow: 0 3px 0 #e5e7eb, 0 4px 8px rgba(0, 0, 0, 0.1);
  }

  .btn-white:hover {
    @apply text-primary-600;
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #e5e7eb, 0 8px 16px rgba(0, 0, 0, 0.12);
  }

  /* ---- Product Card ---- */
  .product-card {
    @apply card-hover cursor-pointer block;
  }

  .product-card-image {
    @apply relative overflow-hidden bg-gradient-to-br from-steel-50 to-steel-100
            aspect-square flex items-center justify-center;
  }

  .product-card-image img {
    @apply w-full h-full object-cover transition-transform duration-500;
  }

  .product-card:hover .product-card-image img {
    transform: scale(1.08);
  }

  /* ---- Section Styles ---- */
  .section {
    @apply py-16 md:py-24;
  }

  .section-dark {
    @apply py-16 md:py-24 bg-primary-900 text-white;
  }

  .section-title {
    @apply text-2xl sm:text-3xl lg:text-4xl font-bold text-steel-900 mb-4
           tracking-tight leading-tight;
  }

  .section-subtitle {
    @apply text-lg md:text-xl text-steel-500 max-w-3xl leading-relaxed;
  }

  .container-custom {
    @apply max-w-7xl mx-auto px-4 sm:px-6 lg:px-8;
  }

  /* ---- Gradient Backgrounds ---- */
  .gradient-bg {
    @apply bg-gradient-to-br from-steel-50 via-white to-steel-50;
  }

  .gradient-mesh {
    background: 
      radial-gradient(at 40% 20%, rgba(63, 139, 109, 0.08) 0px, transparent 50%),
      radial-gradient(at 80% 0%, rgba(227, 92, 24, 0.05) 0px, transparent 50%),
      radial-gradient(at 0% 50%, rgba(63, 139, 109, 0.05) 0px, transparent 50%),
      radial-gradient(at 80% 50%, rgba(227, 92, 24, 0.03) 0px, transparent 50%),
      radial-gradient(at 0% 100%, rgba(63, 139, 109, 0.05) 0px, transparent 50%);
  }

  /* ---- Navbar ---- */
  .navbar {
    @apply sticky top-0 z-50 transition-all duration-300;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  }

  .navbar-scrolled {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  }

  /* ---- Footer ---- */
  .footer {
    @apply bg-white text-steel-600 border-t border-steel-200 pt-16 pb-8;
  }

  .footer-title {
    @apply text-lg font-semibold text-steel-900 mb-6 tracking-wide uppercase;
  }

  /* ---- Nav Links ---- */
  .nav-link {
    @apply px-4 py-2 text-base font-medium text-steel-700 hover:text-accent-500 transition-all duration-200 relative;
  }

  .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    @apply bg-accent-500;
    transition: all 0.3s ease-out;
    transform: translateX(-50%);
  }

  .nav-link:hover::after {
    width: 60%;
  }

  .mobile-nav-link {
    @apply px-4 py-3 text-base font-medium text-steel-700 hover:bg-steel-100 hover:text-accent-500 rounded-lg transition-colors;
  }

  /* ---- Hero Section ---- */
  .hero-gradient {
    background:
      linear-gradient(135deg, #166534 0%, #14532d 100%),
      url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  }

  /* ---- CTA Section ---- */
  .cta-gradient {
    background: linear-gradient(135deg, #166534 0%, #14532d 100%);
  }

  /* ---- Image Frame ---- */
  .image-frame {
    @apply relative overflow-hidden rounded-xl;
  }

  .image-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
    @apply rounded-xl;
    z-index: 1;
    pointer-events: none;
  }

  /* ---- Tables ---- */
  .modern-table {
    @apply w-full border-collapse rounded-xl overflow-hidden shadow-lg;
  }

  .modern-table th {
    @apply bg-steel-800 text-white px-6 py-4 text-left font-semibold uppercase tracking-wider text-sm;
  }

  .modern-table td {
    @apply px-6 py-4 border-b border-steel-200 text-steel-700;
  }

  .modern-table tr:last-child td {
    @apply border-b-0;
  }

  .modern-table tr:hover td {
    @apply bg-steel-50;
  }

  /* ---- Input ---- */
  .input-modern {
    @apply w-full px-5 py-4 rounded-lg border-2 border-steel-200 bg-white
            focus:border-steel-800 focus:ring-0 focus:outline-none
            transition-all duration-200 text-steel-800 placeholder:text-steel-400;
  }

  .input-modern:focus {
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.1);
  }

  /* ---- Link Animation ---- */
  .link-animate {
    @apply relative inline-block;
  }

  .link-animate::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    @apply bg-accent-500;
    transition: width 0.3s ease-out;
  }

  .link-animate:hover::after {
    width: 100%;
  }

  /* ---- Image Zoom ---- */
  .img-zoom {
    @apply overflow-hidden;
  }

  .img-zoom img {
    @apply transition-transform duration-500;
    transform: scale(1);
  }

  .img-zoom:hover img {
    transform: scale(1.08);
  }
}

@layer utilities {
  /* ---- Stagger Animation ---- */
  .stagger-container {
    @apply overflow-hidden;
  }

  .stagger-item {
    @apply opacity-0 translate-y-8;
    transition-property: opacity, transform, box-shadow;
    transition-duration: 0.6s;
    transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  }

  .stagger-item.revealed {
    @apply opacity-100 translate-y-0;
  }

  .stagger-item[data-delay="1"] { transition-delay: 0.1s; }
  .stagger-item[data-delay="2"] { transition-delay: 0.2s; }
  .stagger-item[data-delay="3"] { transition-delay: 0.3s; }
  .stagger-item[data-delay="4"] { transition-delay: 0.4s; }
  .stagger-item[data-delay="5"] { transition-delay: 0.5s; }
  .stagger-item[data-delay="6"] { transition-delay: 0.6s; }
  .stagger-item[data-delay="7"] { transition-delay: 0.7s; }
  .stagger-item[data-delay="8"] { transition-delay: 0.8s; }

  /* ---- Reduced Motion ---- */
  @media (prefers-reduced-motion: reduce) {
    .stagger-item {
      transition: none;
      @apply opacity-100 translate-y-0;
    }
  }
}