/**
 * Modern Product Section Styles
 * Professional design for "SẢN PHẨM CỦA CHÚNG TÔI" section
 * Compatible with existing 3TK.com.vn styles
 */

/* CSS Custom Properties for consistent theming */
:root {
  --primary-color: #ff6b35;
  --primary-dark: #e55a2b;
  --primary-light: #ff7f4f;
  --accent-color: #118f3e;
  --text-primary: #cc5200; 
  --text-secondary: #cc5200;
  --text-muted: #cc5200;
  --bg-white: #ffffff;
  --bg-light: #f8f9fa;
  --bg-gradient: linear-gradient(135deg, #fff5f2 0%, #ffe8e0 100%);
  --border-light: #e9ecef;
  --border-color: #dee2e6;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 25px rgba(0,0,0,0.15);
  --shadow-hover: 0 8px 20px rgba(255, 107, 53, 0.2);
  --border-radius-sm: 6px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --spacing-xs: 0.375rem;
  --spacing-sm: 0.75rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
}

/* Modern Our Products Section */
.our-product-modern {
  padding: clamp(2rem, 5vw, 3rem) 0;
  background: var(--bg-gradient);
  position: relative;
  overflow: hidden;
}

.our-product-modern::before {
  content: '';
  position: absolute;
  top: -10%;
  left: -10%;
  right: -10%;
  bottom: -10%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(255, 107, 53, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(17, 143, 62, 0.04) 0%, transparent 50%);
  pointer-events: none;
  animation: backgroundFloat 20s ease-in-out infinite;
}

@keyframes backgroundFloat {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.01);
  }
}

.our-product-modern .container {
  position: relative;
  z-index: 1;
}

/* Modern Title Section */
.our-product-title-modern {
  text-align: center;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.our-product-title-modern .main-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
  position: relative;
  display: inline-block;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.our-product-title-modern .main-title::after {
  content: '';
  position: absolute;
  bottom: -0.375rem;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(2.5rem, 6vw, 4rem);
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--accent-color) 100%);
  border-radius: 2px;
}

.our-product-title-modern .note {
  font-size: clamp(0.875rem, 2vw, 1rem);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  font-weight: 400;
}

/* Modern Product Grid - Fixed 3x2 Layout */
.product-grid-modern {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(1rem, 2.5vw, 1.5rem);
  padding: 0;
  margin: 0;
  list-style: none;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

/* Modern Product Card */
.product-card-modern {
  background: var(--bg-white);
  border-radius: var(--border-radius-lg);
  padding: 0;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-slow);
  border: 1px solid var(--border-light);
  height: 100%;
  display: flex;
  flex-direction: column;
  transform: translateY(0) scale(1);
  will-change: transform, box-shadow, border-color;
  max-width: 320px;
  margin: 0 auto;
  backface-visibility: hidden;
  perspective: 1000px;
}

.product-card-modern::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.03) 0%, rgba(17, 143, 62, 0.03) 100%);
  opacity: 0;
  transition: opacity var(--transition-slow);
  z-index: 1;
  pointer-events: none;
  will-change: opacity;
}

.product-card-modern:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary-light);
}

.product-card-modern:hover::before {
  opacity: 1;
}

/* Product Image Container */
.product-image-modern {
  position: relative;
  width: 100%;
  height: 160px;
  overflow: hidden;
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  display: block;
  text-decoration: none;
}

.product-image-modern img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
  will-change: transform;
  backface-visibility: hidden;
}

.product-card-modern:hover .product-image-modern img {
  transform: scale(1.08);
}

/* Product Content */
.product-content-modern {
  padding: var(--spacing-sm);
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.product-name-modern {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
  text-decoration: none;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2; /* Standard property for compatibility */
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color var(--transition-fast);
  text-align: center;
}

.product-name-modern:hover {
  color: var(--primary-color);
}

/* Product Description - Hidden by default, shown on hover */
.product-description-modern {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: var(--spacing-xs);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2; /* Standard property for compatibility */
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0;
  max-height: 0;
  transform: translateY(10px);
  transition: all var(--transition-slow);
  will-change: opacity, max-height, transform;
}

.product-card-modern:hover .product-description-modern {
  opacity: 1;
  max-height: 2.8rem;
  transform: translateY(0);
}

/* Subcategories */
.subcategories-modern {
  margin-bottom: var(--spacing-sm);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transform: translateY(15px);
  transition: all var(--transition-slow);
  will-change: opacity, max-height, transform;
}

.product-card-modern:hover .subcategories-modern {
  opacity: 1;
  max-height: 5rem;
  transform: translateY(0);
}

.subcategory-tag-modern {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--primary-color);
  background: rgba(255, 107, 53, 0.1);
  padding: 0.2rem 0.4rem;
  border-radius: var(--border-radius-sm);
  margin: 0.1rem 0.2rem 0.1rem 0;
  text-decoration: none;
  transition: all var(--transition-bounce);
  border: 1px solid transparent;
  will-change: transform, background-color, color;
  backface-visibility: hidden;
}

.subcategory-tag-modern:hover {
  background: var(--primary-color);
  color: var(--bg-white);
  border-color: var(--primary-color);
  transform: translateY(-2px) scale(1.05);
}

/* Action Button */
.product-action-modern {
  margin-top: auto;
  padding-top: var(--spacing-xs);
}

.view-all-btn-modern {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-color);
  text-decoration: none;
  padding: 0.6rem 1rem;
  border: 2px solid var(--primary-color);
  border-radius: var(--border-radius-md);
  background: transparent;
  transition: all var(--transition-slow);
  width: 100%;
  justify-content: center;
  position: relative;
  overflow: hidden;
  will-change: transform, background-color, color;
  backface-visibility: hidden;
}

.view-all-btn-modern::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--primary-color);
  transition: left var(--transition-slow);
  z-index: -1;
  will-change: left;
}

.view-all-btn-modern:hover {
  color: var(--bg-white);
  transform: translateY(-1px) scale(1.02);
  box-shadow: var(--shadow-md);
}

.view-all-btn-modern:hover::before {
  left: 0;
}

.view-all-btn-modern i {
  font-size: 0.7rem;
  transition: transform var(--transition-bounce);
  will-change: transform;
}

.view-all-btn-modern:hover i {
  transform: translateX(3px) scale(1.1);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .product-grid-modern {
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(0.75rem, 2vw, 1.25rem);
    max-width: 900px;
  }
}

@media (max-width: 768px) {
  .our-product-modern {
    padding: clamp(1.5rem, 4vw, 2.5rem) 0;
  }
  
  .product-grid-modern {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    max-width: 600px;
  }
  
  .product-image-modern {
    height: 140px;
  }
  
  .product-content-modern {
    padding: var(--spacing-xs);
  }
  
  .product-name-modern {
    font-size: 0.9rem;
  }
  
  /* Show description on mobile without hover */
  .product-description-modern {
    opacity: 1;
    max-height: 2.8rem;
  }
  
  .subcategories-modern {
    opacity: 1;
    max-height: 5rem;
  }
}

@media (max-width: 576px) {
  .product-grid-modern {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
    max-width: 320px;
  }
  
  .product-image-modern {
    height: 180px;
  }
  
  .product-card-modern {
    max-width: none;
  }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus States for Keyboard Navigation */
.product-card-modern:focus-within {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.product-name-modern:focus,
.view-all-btn-modern:focus,
.subcategory-tag-modern:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .product-card-modern {
    border: 2px solid var(--text-primary);
  }
  
  .product-name-modern {
    color: var(--text-primary);
    font-weight: 700;
  }
  
  .view-all-btn-modern {
    border-width: 3px;
  }
}

/* Loading State Animation */
.product-card-modern.loading {
  background: linear-gradient(90deg, var(--bg-light) 25%, #fff 50%, var(--bg-light) 75%);
  background-size: 200% 100%;
  animation: loading 2s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Print Styles */
@media print {
  .our-product-modern {
    background: none !important;
    box-shadow: none !important;
  }
  
  .product-card-modern {
    break-inside: avoid;
    border: 1px solid #000;
    margin-bottom: 1rem;
  }
  
  .product-card-modern:hover {
    transform: none;
    box-shadow: none;
  }
}

/* Error State */
.product-card-modern.error {
  border-color: #dc3545;
  background: rgba(220, 53, 69, 0.05);
}

.product-card-modern.error .product-name-modern {
  color: #dc3545;
}

/* Success State */
.product-card-modern.success {
  border-color: var(--primary-color);
  background: rgba(17, 143, 62, 0.05);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #ff6600;
    --text-secondary: #e9ecef;
    --text-muted: #adb5bd;
    --bg-white: #2c3e50;
    --bg-light: #34495e;
    --bg-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --border-light: #495057;
    --border-color: #6c757d;
  }
  
  .product-card-modern {
    background: var(--bg-white);
    border-color: var(--border-light);
  }
}

/* Override old styles to prevent conflicts */
.our-product-modern .list-category-home,
.our-product-modern .item,
.our-product-modern .content-our-product {
  display: initial !important;
  flex-wrap: initial !important;
  overflow: initial !important;
}

/* Ensure new styles take precedence */
.our-product-modern {
  position: relative !important;
  z-index: 1 !important;
}

/* Loading animations for better UX */
.product-card-modern.loading .product-image-modern::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent 25%, 
    rgba(255,255,255,0.5) 50%, 
    transparent 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite ease-in-out;
}

@keyframes shimmer {
  0% { 
    background-position: -200% 0;
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% { 
    background-position: 200% 0;
    opacity: 0;
  }
}

/* Smooth entry animation */
.our-product-modern {
  animation: sectionFadeIn 0.8s ease-out both;
}

@keyframes sectionFadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Title animation */
.our-product-title-modern .main-title {
  animation: titleSlideIn 0.6s ease-out both;
  animation-delay: 0.2s;
}

.our-product-title-modern .note {
  animation: titleSlideIn 0.6s ease-out both;
  animation-delay: 0.4s;
}

@keyframes titleSlideIn {
  0% {
    opacity: 0;
    transform: translateY(15px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Enhanced focus indicators */
.product-card-modern:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 3px;
}

/* Smooth transitions for all interactive elements */
.subcategory-tag-modern,
.view-all-btn-modern,
.product-name-modern,
.product-image-modern {
  transition: all var(--transition-normal);
}

/* Enhanced hover effects */
.product-card-modern:hover .subcategory-tag-modern {
  transform: translateY(-1px);
}

/* Staggered Animation for Cards */
.product-card-modern {
  animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.product-card-modern:nth-child(1) { animation-delay: 0.1s; }
.product-card-modern:nth-child(2) { animation-delay: 0.2s; }
.product-card-modern:nth-child(3) { animation-delay: 0.3s; }
.product-card-modern:nth-child(4) { animation-delay: 0.4s; }
.product-card-modern:nth-child(5) { animation-delay: 0.5s; }
.product-card-modern:nth-child(6) { animation-delay: 0.6s; }

@keyframes slideInUp {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Smooth Focus Animation */
.product-card-modern:focus-within {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-lg);
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  transition: all var(--transition-slow);
}

/* Enhanced Hover State for Better Performance */
.product-card-modern:hover .product-name-modern {
  color: var(--primary-color);
  transform: translateY(-1px);
  transition: all var(--transition-normal);
}

/* Micro-interactions for better UX */
.product-card-modern:active {
  transform: translateY(-2px) scale(0.98);
  transition: all var(--transition-fast);
}

.subcategory-tag-modern:active {
  transform: translateY(0) scale(0.95);
  transition: all var(--transition-fast);
}

.view-all-btn-modern:active {
  transform: translateY(0) scale(0.98);
  transition: all var(--transition-fast);
}

/* Mobile touch improvements */
@media (hover: none) and (pointer: coarse) {
  .product-description-modern,
  .subcategories-modern {
    opacity: 1 !important;
    max-height: none !important;
    transform: translateY(0) !important;
  }
  
  .product-card-modern:hover {
    transform: none;
  }
  
  .product-card-modern:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
  
  .subcategory-tag-modern:active,
  .view-all-btn-modern:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .product-card-modern,
  .product-image-modern img,
  .subcategory-tag-modern,
  .view-all-btn-modern,
  .product-description-modern,
  .subcategories-modern {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
  
  .product-card-modern {
    animation: fadeIn 0.3s ease-in-out both;
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

/* Print optimization */
@media print {
  .our-product-modern {
    background: white !important;
    padding: 2rem 0 !important;
  }
  
  .product-grid-modern {
    display: block !important;
    columns: 2;
    column-gap: 2rem;
  }
  
  .product-card-modern {
    break-inside: avoid;
    margin-bottom: 1rem;
    box-shadow: none !important;
    border: 1px solid #000 !important;
    transform: none !important;
  }
}

/* High contrast mode enhancements */
@media (prefers-contrast: high) {
  .our-product-modern::before {
    display: none;
  }
  
  .product-card-modern::before {
    display: none;
  }
  
  .subcategory-tag-modern {
    border: 2px solid currentColor;
  }
}
