/* Custom styles for Made in Malaysia B2B Platform */

/* Malaysia flag colors and custom styling */
:root {
  --malaysian-red: #DC143C;
  --malaysian-blue: #003366;
  --malaysian-yellow: #FFD700;
  --malaysian-green: #228B22;
}

/* Ensure proper layout structure */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: var(--malaysian-red);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #b91232;
}

/* Smooth transitions */
* {
  transition: all 0.3s ease;
}

/* Custom gradient backgrounds */
.bg-malaysia-gradient {
  background: linear-gradient(135deg, var(--malaysian-blue) 0%, var(--malaysian-red) 100%);
}

.bg-success-gradient {
  background: linear-gradient(135deg, var(--malaysian-green) 0%, #32a852 100%);
}

/* Custom shadows */
.shadow-malaysia {
  box-shadow: 0 10px 25px rgba(220, 20, 60, 0.15);
}

/* Loading spinner animation */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Custom form styling */
.form-input {
  @apply appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:border-transparent sm:text-sm;
}

.form-input:focus {
  ring-color: var(--malaysian-red);
  border-color: var(--malaysian-red);
}

/* Button hover effects */
.btn-primary {
  @apply bg-red-600 text-white px-4 py-2 rounded-md font-semibold transition-all duration-300;
}

.btn-primary:hover {
  @apply bg-red-700 transform scale-105 shadow-lg;
}

/* Card hover effects */
.card-hover {
  @apply transition-all duration-300 transform hover:scale-105 hover:shadow-xl;
}

/* Pulse animation for notifications */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Toast notifications */
.toast {
  @apply fixed top-4 right-4 z-50 bg-white shadow-lg rounded-lg p-4 border-l-4 border-green-500;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  @apply border-red-500;
}

.toast.warning {
  @apply border-yellow-500;
}

.toast.info {
  @apply border-blue-500;
}

/* Malaysian flag colors utility classes */
.text-malaysia-red { color: var(--malaysian-red); }
.text-malaysia-blue { color: var(--malaysian-blue); }
.text-malaysia-yellow { color: var(--malaysian-yellow); }
.text-malaysia-green { color: var(--malaysian-green); }

.bg-malaysia-red { background-color: var(--malaysian-red); }
.bg-malaysia-blue { background-color: var(--malaysian-blue); }
.bg-malaysia-yellow { background-color: var(--malaysian-yellow); }
.bg-malaysia-green { background-color: var(--malaysian-green); }

.border-malaysia-red { border-color: var(--malaysian-red); }
.border-malaysia-blue { border-color: var(--malaysian-blue); }
.border-malaysia-yellow { border-color: var(--malaysian-yellow); }
.border-malaysia-green { border-color: var(--malaysian-green); }

/* Alternative class names for consistency */
.text-malaysian-red { color: var(--malaysian-red); }
.text-malaysian-blue { color: var(--malaysian-blue); }
.text-malaysian-yellow { color: var(--malaysian-yellow); }
.text-malaysian-green { color: var(--malaysian-green); }

.bg-malaysian-red { background-color: var(--malaysian-red); }
.bg-malaysian-blue { background-color: var(--malaysian-blue); }
.bg-malaysian-yellow { background-color: var(--malaysian-yellow); }
.bg-malaysian-green { background-color: var(--malaysian-green); }

.border-malaysian-red { border-color: var(--malaysian-red); }
.border-malaysian-blue { border-color: var(--malaysian-blue); }
.border-malaysian-yellow { border-color: var(--malaysian-yellow); }
.border-malaysian-green { border-color: var(--malaysian-green); }

/* Responsive design improvements */
@media (max-width: 640px) {
  .mobile-padding {
    @apply px-4;
  }
  
  .mobile-text {
    @apply text-sm;
  }
}

/* Focus states for accessibility */
.focus-malaysia:focus {
  @apply outline-none ring-2 ring-offset-2;
  ring-color: var(--malaysian-red);
}

/* Animation for page transitions */
.page-enter {
  opacity: 0;
  transform: translateY(20px);
}

.page-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 300ms, transform 300ms;
}

/* Custom dropdown styling */
.dropdown-menu {
  @apply absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-50 border border-gray-200;
  transform: scale(0.95);
  opacity: 0;
  transition: all 0.1s ease-out;
}

.dropdown-menu.show {
  transform: scale(1);
  opacity: 1;
}

/* Malaysian-themed loading skeleton */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
}

/* Malaysian-themed Homepage Animations */

/* Hero Background Animations */
.hero-background {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  height: auto;
  contain: layout style paint;
}

/* Animation keyframes and utilities */

/* Gradient Mesh Background */
.gradient-mesh {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.mesh-overlay {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 20% 50%, rgba(255, 215, 0, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(220, 20, 60, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(0, 51, 102, 0.1) 0%, transparent 50%);
  animation: mesh-rotate 25s infinite linear;
}

@keyframes mesh-rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Animation keyframes and utilities continue */

/* Animated Lines */
.animated-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.line {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.6), transparent);
  animation: line-move 4s ease-in-out infinite;
  will-change: transform, opacity;
  transform: translateZ(0); /* Force hardware acceleration */
  contain: strict;
}

.line-1 {
  top: 30%;
  width: 300px;
  left: -300px;
  animation-delay: 0s;
}

.line-2 {
  top: 70%;
  width: 400px;
  right: -400px;
  animation-delay: -2s;
  background: linear-gradient(90deg, transparent, rgba(220, 20, 60, 0.4), transparent);
}

.line-3 {
  top: 50%;
  width: 250px;
  left: -250px;
  animation-delay: -1s;
  background: linear-gradient(90deg, transparent, rgba(0, 51, 102, 0.5), transparent);
}

@keyframes line-move {
  0% {
    transform: translateX(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(calc(100vw + 100%));
    opacity: 0;
  }
}

/* Particles System */
.particles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 215, 0, 0.9);
  border-radius: 50%;
  animation: particle-float 12s infinite linear;
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
  will-change: transform, opacity;
  transform: translateZ(0); /* Force hardware acceleration */
  contain: strict;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-delay: -1s; background: rgba(220, 20, 60, 0.8); }
.particle:nth-child(3) { left: 30%; animation-delay: -2s; background: rgba(0, 51, 102, 0.8); }
.particle:nth-child(4) { left: 40%; animation-delay: -3s; }
.particle:nth-child(5) { left: 60%; animation-delay: -4s; background: rgba(34, 139, 34, 0.8); }
.particle:nth-child(6) { left: 70%; animation-delay: -5s; background: rgba(220, 20, 60, 0.8); }
.particle:nth-child(7) { left: 80%; animation-delay: -6s; }
.particle:nth-child(8) { left: 90%; animation-delay: -7s; background: rgba(0, 51, 102, 0.8); }

@keyframes particle-float {
  0% {
    transform: translateY(0px) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: scale(1);
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) scale(0);
    opacity: 0;
  }
}

/* Text Animations */
.animate-fade-in-up {
  animation: fadeInUp 1s ease-out forwards;
  opacity: 0;
  transform: translateY(40px);
}

.animation-delay-200 {
  animation-delay: 0.2s;
}

.animation-delay-400 {
  animation-delay: 0.4s;
}

.animation-delay-600 {
  animation-delay: 0.6s;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Feature Cards Animation */
.feature-card {
  transition: all 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
}

.pulse-shadow {
  animation: pulse-shadow 2s ease-in-out infinite;
}

@keyframes pulse-shadow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(220, 20, 60, 0.4);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(220, 20, 60, 0);
  }
}

/* Feature Cards Enhanced Animation */
.feature-card {
  transition: all 0.3s ease;
  transform: translateY(20px);
  opacity: 0;
}

.feature-card.animate,
.feature-card:hover {
  transform: translateY(-5px);
  opacity: 1;
}

/* Enhanced pulse shadow effect */
.pulse-shadow {
  animation: pulse-shadow 3s ease-in-out infinite;
}

@keyframes pulse-shadow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.4);
    transform: scale(1.05);
  }
}

/* Text color animations */
.group:hover .group-hover\:text-malaysian-red {
  color: var(--malaysian-red) !important;
  transition: color 0.3s ease;
}

.group:hover .group-hover\:text-malaysian-blue {
  color: var(--malaysian-blue) !important;
  transition: color 0.3s ease;
}

.group:hover .group-hover\:text-malaysian-yellow {
  color: var(--malaysian-yellow) !important;
  transition: color 0.3s ease;
}

.group:hover .group-hover\:text-malaysian-green {
  color: var(--malaysian-green) !important;
  transition: color 0.3s ease;
}

/* Homepage Hero Background Animations - Fixed positioning */
.hero-background {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

/* All animation containers positioned absolutely behind content */
.hero-background .floating-shapes,
.hero-background .floating-icons,
.hero-background .animated-lines,
.hero-background .particles-container,
.hero-background .gradient-mesh {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 0 !important;
    overflow: hidden !important;
}

/* Ensure hero content is above animations */
.hero-background > .relative {
    position: relative !important;
    z-index: 10 !important;
}

/* Dark overlay should be above animations but below content */
.hero-background > .absolute.inset-0.bg-black {
    z-index: 5 !important;
}

/* All individual animation elements */
.hero-background .shape,
.hero-background .floating-icon,
.hero-background .line,
.hero-background .particle,
.hero-background .mesh-overlay {
    position: absolute !important;
    z-index: inherit !important;
    will-change: transform, opacity;
    transform: translateZ(0);
    pointer-events: none !important;
}

/* Hero content animations */
.animate-fade-in-up {
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.8s ease-out forwards;
}

.animation-delay-200 {
  animation-delay: 0.2s;
}

.animation-delay-400 {
  animation-delay: 0.4s;
}

.animation-delay-600 {
  animation-delay: 0.6s;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Search container glow effect */
.search-container {
  position: relative;
  transition: all 0.3s ease;
}

.search-container:hover {
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}

/* Button hover animations */
.bg-malaysian-red {
  background-color: var(--malaysian-red);
}

.hover\:bg-red-700:hover {
  background-color: #b91232;
}

.text-malaysian-yellow {
  color: var(--malaysian-yellow);
}

.text-malaysian-blue {
  color: var(--malaysian-blue);
}

/* Ensure hero section takes full height */
.min-h-screen {
  min-height: 100vh;
}

/* Hero section with blurred background image */
.hero-bg-image {
  background-image: url('/images/background.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: scroll;
  position: relative;
}

/* Blurred background image overlay */
.hero-bg-image::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  background-image: url('/images/background.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(3px);
  z-index: 0;
}

/* Enhanced overlay for better text readability over blurred photo */
.hero-bg-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(0, 51, 102, 0.6) 0%, rgba(220, 20, 60, 0.4) 100%);
  z-index: 1;
}

/* Ensure content appears above overlay */
.hero-bg-image > .relative {
  z-index: 10;
}

/* Adjust animation opacity for blurred photo background */
.hero-bg-image .floating-shape {
  opacity: 0.4;
}

.hero-bg-image .particle-1,
.hero-bg-image .particle-2,
.hero-bg-image .particle-3 {
  opacity: 0.7;
  box-shadow: 0 0 20px currentColor;
}

.hero-bg-image .animated-gradient {
  opacity: 0.2;
}

/* Enhanced blur effects for hero section */
.hero-blur-bg {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.hero-content-glass {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Smooth blur animation */
@keyframes blurIn {
  from {
    filter: blur(0px);
  }
  to {
    filter: blur(3px);
  }
}

.animate-blur-in {
  animation: blurIn 2s ease-out forwards;
}

/* Glass morphism effect for search bar */
.search-glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Enhanced Popular Categories Section */
.categories-hero {
  position: relative;
  background: linear-gradient(135deg, var(--malaysian-blue) 0%, #1e40af 50%, var(--malaysian-blue) 100%);
}

.categories-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255, 215, 0, 0.1) 0%, transparent 60%),
              radial-gradient(circle at 70% 80%, rgba(220, 20, 60, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

/* Category card enhancements */
.category-card {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.category-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.category-card .category-icon {
  transition: all 0.3s ease;
}

.category-card:hover .category-icon {
  transform: scale(1.2) rotate(5deg);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Yellow accent line animation */
.accent-line {
  position: relative;
  overflow: hidden;
}

.accent-line::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shine 3s infinite;
}

@keyframes shine {
  0% {
    left: -100%;
  }
  50%, 100% {
    left: 100%;
  }
}

/* Manufacturer Services Section */
.manufacturer-services {
  position: relative;
}

.manufacturer-services .service-card {
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.manufacturer-services .service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.manufacturer-services .floating-icon {
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Service feature animations */
.service-feature {
  opacity: 0;
  transform: translateX(-30px);
  animation: slideInLeft 0.8s ease-out forwards;
}

.service-feature:nth-child(1) { animation-delay: 0.2s; }
.service-feature:nth-child(2) { animation-delay: 0.4s; }
.service-feature:nth-child(3) { animation-delay: 0.6s; }
.service-feature:nth-child(4) { animation-delay: 0.8s; }
.service-feature:nth-child(5) { animation-delay: 1.0s; }

@keyframes slideInLeft {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Enhanced grid hover effects */
.service-grid-item {
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.service-grid-item:hover {
  transform: scale(1.05) translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}