/**
 * Xi Woo Templates Frontend Styles - Safe & Minimal
 * Ultra-specific selectors to avoid conflicts with themes/plugins
 * Only styles essential components, lets everything else inherit naturally
 */

/* Hide WooCommerce notices in custom catalog */
.xi-custom-catalog-wrapper .woocommerce-notices-wrapper {
  display: none !important;
}

/* Base Component Container - Ultra Specific */
.woocommerce .xi-woo-component[data-hook],
.woocommerce-page .xi-woo-component[data-hook] {
  margin: 1em 0;
  clear: both;
  box-sizing: border-box;
}

/* Device-specific visibility - Desktop (screens larger than 768px) */
@media (min-width: 769px) {
  .xi-woo-component.xi-hide-desktop,
  .woocommerce .xi-woo-component.xi-hide-desktop,
  .woocommerce-page .xi-woo-component.xi-hide-desktop {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }
}

/* Device-specific visibility - Mobile (screens 768px and smaller) */
@media (max-width: 768px) {
  .xi-woo-component.xi-hide-mobile,
  .woocommerce .xi-woo-component.xi-hide-mobile,
  .woocommerce-page .xi-woo-component.xi-hide-mobile {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }
}

/* Reset any potential inherited styles that could break our components */
.woocommerce .xi-woo-component[data-hook] *,
.woocommerce-page .xi-woo-component[data-hook] * {
  box-sizing: border-box;
}

/* Component Types - Only Basic Spacing */
.woocommerce .xi-woo-component[data-hook].xi-type-text {
  line-height: 1.6;
}

/* Minimal Hook-specific positioning - Only where needed */
.woocommerce .xi-woo-component[data-hook="before-shop-loop"],
.woocommerce .xi-woo-component[data-hook="before-main-content"] {
  margin-bottom: 2em;
}

.woocommerce .xi-woo-component[data-hook="after-shop-loop"],
.woocommerce .xi-woo-component[data-hook="after-main-content"] {
  margin-top: 2em;
}

.woocommerce .xi-woo-component[data-hook="before-single-product-summary"] {
  margin-bottom: 1.5em;
}

.woocommerce .xi-woo-component[data-hook="after-single-product-summary"] {
  margin-top: 1.5em;
}

/* Text Component Styling - Only Direct Children, Very Specific */
.woocommerce .xi-woo-component[data-hook].xi-type-text > p:first-child {
  margin-top: 0;
}

.woocommerce .xi-woo-component[data-hook].xi-type-text > p:last-child {
  margin-bottom: 0;
}

.woocommerce .xi-woo-component[data-hook].xi-type-text > h1,
.woocommerce .xi-woo-component[data-hook].xi-type-text > h2,
.woocommerce .xi-woo-component[data-hook].xi-type-text > h3,
.woocommerce .xi-woo-component[data-hook].xi-type-text > h4,
.woocommerce .xi-woo-component[data-hook].xi-type-text > h5,
.woocommerce .xi-woo-component[data-hook].xi-type-text > h6 {
  margin-top: 0;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

.woocommerce .xi-woo-component[data-hook].xi-type-text > p {
  margin-bottom: 1em;
}

.woocommerce .xi-woo-component[data-hook].xi-type-text > img {
  max-width: 100%;
  height: auto;
}

/* Custom Button Styling - ONLY for elements with our specific class */
.woocommerce .xi-woo-component[data-hook] .xi-woo-button {
  display: inline-block !important;
  padding: 0.75em 1.5em !important;
  background: #0073aa !important;
  color: white !important;
  text-decoration: none !important;
  border-radius: 4px !important;
  border: none !important;
  cursor: pointer !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
  margin: 0.5em 0.5em 0.5em 0 !important;
  font-family: inherit !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-woo-button:hover {
  background: #005a87 !important;
  color: white !important;
  text-decoration: none !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-woo-button.xi-secondary {
  background: #f8f9fa !important;
  color: #495057 !important;
  border: 1px solid #dee2e6 !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-woo-button.xi-secondary:hover {
  background: #e9ecef !important;
  color: #495057 !important;
}

/* Alert/Notice Styling - ONLY for our specific alerts */
.woocommerce .xi-woo-component[data-hook] .xi-woo-alert {
  padding: 1em 1.25em !important;
  margin-bottom: 1em !important;
  border-radius: 6px !important;
  border-left: 4px solid #0073aa !important;
  background: #f8f9fa !important;
  font-family: inherit !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-woo-alert.xi-success {
  border-left-color: #28a745 !important;
  background: #d4edda !important;
  color: #155724 !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-woo-alert.xi-warning {
  border-left-color: #ffc107 !important;
  background: #fff3cd !important;
  color: #856404 !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-woo-alert.xi-error {
  border-left-color: #dc3545 !important;
  background: #f8d7da !important;
  color: #721c24 !important;
}

/* Card Style - ONLY for our specific cards */
.woocommerce .xi-woo-component[data-hook] .xi-woo-card {
  background: #fff !important;
  border: 1px solid #e9ecef !important;
  border-radius: 8px !important;
  padding: 1.5em !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
  margin-bottom: 1em !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-woo-card > h3:first-child {
  margin-top: 0 !important;
  margin-bottom: 1em !important;
  color: #212529 !important;
}

/* Utility Classes - Extremely Specific */
.woocommerce .xi-woo-component[data-hook] .xi-text-center {
  text-align: center !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-text-left {
  text-align: left !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-text-right {
  text-align: right !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-mb-0 {
  margin-bottom: 0 !important;
}
.woocommerce .xi-woo-component[data-hook] .xi-mb-1 {
  margin-bottom: 0.5em !important;
}
.woocommerce .xi-woo-component[data-hook] .xi-mb-2 {
  margin-bottom: 1em !important;
}
.woocommerce .xi-woo-component[data-hook] .xi-mb-3 {
  margin-bottom: 1.5em !important;
}

.woocommerce .xi-woo-component[data-hook] .xi-mt-0 {
  margin-top: 0 !important;
}
.woocommerce .xi-woo-component[data-hook] .xi-mt-1 {
  margin-top: 0.5em !important;
}
.woocommerce .xi-woo-component[data-hook] .xi-mt-2 {
  margin-top: 1em !important;
}
.woocommerce .xi-woo-component[data-hook] .xi-mt-3 {
  margin-top: 1.5em !important;
}

/* Responsive Design - Only for Mobile */
@media (max-width: 768px) {
  .woocommerce .xi-woo-component[data-hook] {
    margin: 1em 0;
  }

  .woocommerce .xi-woo-component[data-hook] .xi-woo-card {
    padding: 1em !important;
  }

  .woocommerce .xi-woo-component[data-hook] .xi-woo-button {
    padding: 0.6em 1.2em !important;
    font-size: 0.9em !important;
  }
}

@media (max-width: 480px) {
  .woocommerce .xi-woo-component[data-hook] {
    margin: 0.75em 0;
  }

  .woocommerce .xi-woo-component[data-hook] .xi-woo-alert {
    padding: 0.75em 1em !important;
  }

  /* Ensure full width on small screens */
  .xi-woo-catalog-layout-container {
    padding: 0 5px;
  }

  .xi-woo-catalog-layout {
    max-width: 100% !important;
  }

  .xi-woo-catalog-sidebar {
    width: calc(100vw - 10px) !important;
    max-width: 100% !important;
    margin: 0 !important;
    /* padding: 10px !important; */
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .woocommerce .xi-woo-component[data-hook] *,
  .woocommerce .xi-woo-component[data-hook] *::before,
  .woocommerce .xi-woo-component[data-hook] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print Styles */
@media print {
  .woocommerce .xi-woo-component[data-hook] {
    break-inside: avoid;
    margin: 0.5em 0;
  }

  .woocommerce .xi-woo-component[data-hook] .xi-woo-button {
    border: 1px solid #000 !important;
    background: transparent !important;
    color: #000 !important;
  }
}

/* Overriding */
#main #content-wrap {
  padding-top: 5px !important;
  padding-bottom: 50px;
}

/* Xi Woo Archive Breadcrumb - Based on provided design */
.xi-woo-archive-breadcrumb {
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s ease;
  margin: 15px 0 20px;
  padding: 0;
}

/* Breadcrumb Item Structure */
.xi-breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
}

/* Brand/Parent Item with Image */
.xi-breadcrumb-item.xi-brand-item {
  background: #f8f9fa;
}

/* Breadcrumb Image */
.xi-breadcrumb-image {
  width: auto;
  height: 12px !important;
  max-width: 20px;
  object-fit: contain;
  border-radius: 2px;
  border: 1px solid #dee2e6;
  transition: all 0.3s ease;
}

/* Breadcrumb Text */
.xi-breadcrumb-label {
  font-weight: 500;
  color: #495057;
  font-size: 14px;
  white-space: nowrap;
}

.xi-breadcrumb-value {
  font-weight: 700;
  color: #212529;
  font-size: 14px;
  white-space: nowrap;
}

/* Current Item (no link) */
.xi-breadcrumb-current {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #e3f2fd;
  border-radius: 6px;
  border: 1px solid #0073aa;
  font-weight: 700;
  color: #0073aa;
  font-size: 14px;
}

/* Separators - Auto-generated */
/* .xi-breadcrumb-item:not(.xi-brand-item)::before {
  content: "→";
  color: #6c757d;
  font-weight: bold;
  margin-right: 8px;
  margin-left: 12px;
} */

/* Hide separator on first non-brand item when it follows brand */
.xi-breadcrumb-item.xi-brand-item + .xi-breadcrumb-item::before {
  margin-left: 12px;
  margin-right: 8px;
}

/* Hover Effects */
.xi-breadcrumb-item:hover {
  background: #e3f2fd;
  border-color: #0073aa;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 115, 170, 0.2);
}

.xi-breadcrumb-item:hover .xi-breadcrumb-value,
.xi-breadcrumb-item:hover .xi-breadcrumb-label {
  color: #0073aa;
}

.xi-breadcrumb-item:hover .xi-breadcrumb-image {
  transform: scale(1.05);
  border-color: #0073aa;
}

/* Mobile Responsive - Show breadcrumb on mobile with adjusted styling */
@media (max-width: 768px) {
  .xi-woo-archive-breadcrumb {
    display: flex;
    gap: 12px;
    margin: 10px 0 15px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .xi-breadcrumb-item {
    padding: 6px 10px;
    font-size: 13px;
  }

  .xi-breadcrumb-image {
    height: 10px;
    max-width: 16px;
  }
}

/*  */
/* Catalog Layout - Always Present */
.xi-woo-catalog-layout-container {
  width: 100%;
  padding: 0 15px;
  box-sizing: border-box;
}

.xi-woo-catalog-layout {
  width: 100%;
  max-width: 85% !important;
  margin: 0 auto !important;
  display: flex !important;
  gap: 20px !important;
  position: relative !important;
}

.xi-woo-catalog-layout.xi-has-sidebar {
  min-height: 80vh !important;
}

.xi-woo-catalog-layout.xi-sidebar-left {
  flex-direction: row !important;
}

.xi-woo-catalog-layout.xi-sidebar-right {
  flex-direction: row-reverse !important;
}

.xi-woo-catalog-main {
  flex: 1 !important;
  min-width: 0 !important;
  /* Reserve space for sidebar to prevent layout shift */
  margin-right: 320px !important;
}

.xi-woo-catalog-layout.xi-sidebar-left .xi-woo-catalog-main {
  margin-right: 0 !important;
  margin-left: 320px !important;
}

.xi-woo-catalog-main #content-wrap.container {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
}

.xi-woo-catalog-sidebar {
  flex-shrink: 0 !important;
  width: 300px;
  position: absolute;
  top: 0;
  right: 0;
  /* padding: 10px !important; */
  box-sizing: border-box !important;
}

.xi-woo-catalog-layout.xi-sidebar-left .xi-woo-catalog-sidebar {
  right: auto;
  left: 0;
}

@media (max-width: 768px) {
  .xi-woo-catalog-layout-container {
    padding: 0 10px;
  }

  .xi-woo-catalog-layout {
    max-width: 100% !important;
    margin: 0 !important;
  }

  .xi-woo-catalog-layout.xi-has-sidebar {
    flex-direction: column !important;
    gap: 15px !important;
  }

  .xi-woo-catalog-main {
    margin-right: 0 !important;
    margin-left: 0 !important;
    order: 2 !important;
    width: 100% !important;
  }

  .xi-woo-catalog-sidebar {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    order: 1 !important;
    left: auto !important;
    right: auto !important;
    margin: 0 !important;
    /* padding: 15px !important; */
    box-sizing: border-box !important;
  }
}

/* Custom Product Grid Styles - Multiple Fallback Selectors */
.xi-custom-product-grid,
.woocommerce ul.products,
.woocommerce-page ul.products,
.woocommerce .products,
.products {
  display: grid !important;
  gap: 22px !important; /* Balanced desktop gap - not too big */
  width: 100% !important;
  margin: 22px 0 !important; /* Balanced desktop margin */
  justify-content: start !important; /* Align cards to start instead of spreading */
  justify-items: start !important; /* Align individual items to start */
}

/* Grid Column Variations */
.xi-custom-product-grid.xi-columns-2 {
  grid-template-columns: repeat(2, 1fr) !important;
}

.xi-custom-product-grid.xi-columns-3 {
  grid-template-columns: repeat(3, 1fr) !important;
}

.xi-custom-product-grid.xi-columns-4 {
  grid-template-columns: repeat(4, 1fr) !important;
}

.xi-custom-product-grid.xi-columns-5 {
  grid-template-columns: repeat(5, 1fr) !important;
}

.xi-custom-product-grid.xi-columns-6,
.woocommerce .products.columns-6,
.woocommerce ul.products.columns-6,
.products.columns-6 {
  grid-template-columns: repeat(6, 1fr) !important;
}

/* Custom Product Card Base - Reduced specificity for customization */
.xi-custom-product-card,
.woocommerce .upsells.products .product,
.woocommerce .related.products .product,
.woocommerce .products.columns-6 .product,
.products.columns-6 .product {
  background: #fff !important;
  border: 1px solid #e9ecef !important;
  border-radius: 8px !important;
  padding: 15px !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.xi-custom-product-card:hover,
.woocommerce .upsells.products .product:hover,
.woocommerce .related.products .product:hover,
.woocommerce .products.columns-6 .product:hover,
.products.columns-6 .product:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Custom Product Card Elements - Reduced specificity for customization */
.xi-product-image {
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 6px;
  /* Force square (1:1) aspect ratio */
  aspect-ratio: 1 / 1;
  position: relative;
}

.xi-product-image a {
  display: block;
  line-height: 0;
  width: 100%;
  height: 100%;
}

.xi-product-image img {
  width: 100%;
  height: 100%;
  /* Crop to fit square container while maintaining aspect ratio */
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease;
}

.xi-custom-product-card:hover .xi-product-image img {
  transform: scale(1.05);
}

.xi-product-title {
  margin: 0 0 10px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.xi-product-title a {
  color: #333;
  text-decoration: none;
  transition: color 0.3s ease;
}

.xi-product-title a:hover {
  color: #0073aa;
}

.xi-product-price {
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: 700;
  color: #0073aa;
}

.xi-product-price .woocommerce-Price-amount {
  color: inherit;
}

.xi-product-price del {
  color: #999;
  font-weight: 400;
  margin-right: 8px;
}

.xi-product-actions {
  margin-top: auto;
}

/* Add to Cart Button - Multiple Fallback Selectors for Update Safety */
.xi-product-actions button.button,
.woocommerce ul.products li.product button.button,
.woocommerce-page ul.products li.product button.button,
.woocommerce .products .product button.button,
.woocommerce-page .products .product button.button,
.products .product button.button,
li.product button.button,
.product-item button.button {
  width: 100% !important;
  padding: 10px 15px !important;
  border-radius: 6px !important;
  font-weight: 500 !important;
  transition: all 0.3s ease !important;
}

.xi-product-actions .button {
  background: #0073aa !important;
  border: none !important;
}

/* ONLY actual buttons get white text - NOTHING ELSE */
.xi-product-actions button.button,
.xi-product-actions input.button {
  color: white !important;
}

/* NUCLEAR OPTION - FORCE EVERYTHING TO DARK COLOR */
.xi-product-actions a.added_to_cart,
.xi-product-actions a.wc-forward,
.xi-product-actions .added_to_cart,
.xi-product-actions a:not(.button),
.xi-product-actions span:not(.button),
.xi-product-actions div:not(.button),
.xi-product-actions *:not(button):not(input[type="submit"]):not(.button) {
  color: #212529 !important;
}

.xi-product-actions .button:hover {
  background: #005a87 !important;
  transform: translateY(-1px) !important;
}

/* Desktop - Ensure minimum 6 columns for upsell products */
@media (min-width: 1201px) {
  /* Target ONLY Upsells/Related products, NOT Archive grids */
  .woocommerce .upsells.products,
  .woocommerce .related.products,
  .woocommerce .products.columns-6 {
    grid-template-columns: repeat(6, 1fr) !important;
    justify-content: start !important;
    justify-items: start !important;
  }

  /* Smaller gap for 6 columns to keep cards compact */
  .woocommerce .upsells.products,
  .woocommerce .related.products,
  .xi-custom-product-grid.xi-columns-6,
  .woocommerce .products.columns-6,
  .products.columns-6 {
    gap: 16px !important;
  }

  /* Compact card styling for 6 columns - no padding for full width */
  .woocommerce .upsells.products .product,
  .woocommerce .related.products .product,
  .xi-custom-product-grid.xi-columns-6 .xi-custom-product-card {
    padding: 0 !important;
  }

  /* Force exact 1/6 width for upsell/related product cards (6 columns) */
  .woocommerce .upsells.products .product,
  .woocommerce .related.products .product,
  .xi-products-grid .xi-product-item {
    max-width: calc(16.666% - 13.33px) !important; /* 1/6 minus gap spacing */
    width: calc(16.666% - 13.33px) !important;
    flex: none !important;
    min-width: 0 !important;
  }

  /* Force exact 1/6 width for 6-column grids */
  .woocommerce .products.columns-6 .product,
  .products.columns-6 .product {
    max-width: calc(16.666% - 13.33px) !important; /* 1/6 minus gap spacing */
    width: calc(16.666% - 13.33px) !important;
    flex: none !important;
    min-width: 0 !important;
  }
}

/* Responsive Grid */
@media (max-width: 1200px) {
  /* WooCommerce upsells/related products step down to 4 columns on tablets */
  .woocommerce .upsells.products,
  .woocommerce .related.products {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* Tablet width constraints - 4 columns */
  .woocommerce .upsells.products .product,
  .woocommerce .related.products .product {
    max-width: calc(25% - 16.5px) !important; /* 1/4 minus gap spacing */
    width: calc(25% - 16.5px) !important;
  }

  .xi-custom-product-grid.xi-columns-6,
  .woocommerce .products.columns-6,
  .products.columns-6 {
    grid-template-columns: repeat(6, 1fr) !important;
  }
  .xi-custom-product-grid.xi-columns-5 {
    grid-template-columns: repeat(5, 1fr) !important;
  }
}

/* Tablet and Mobile - Different approach */
@media (max-width: 768px) {
  /* WooCommerce upsells/related products on mobile */
  .woocommerce .upsells.products,
  .woocommerce .related.products,
  .xi-custom-product-grid.xi-columns-4,
  .xi-custom-product-grid.xi-columns-5,
  .xi-custom-product-grid.xi-columns-6,
  .woocommerce .products.columns-4,
  .woocommerce .products.columns-5,
  .woocommerce .products.columns-6,
  .products.columns-4,
  .products.columns-5,
  .products.columns-6 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Mobile width constraints - 2 columns */
  .woocommerce .upsells.products .product,
  .woocommerce .related.products .product,
  .woocommerce .products.columns-4 .product,
  .woocommerce .products.columns-5 .product,
  .woocommerce .products.columns-6 .product,
  .products.columns-4 .product,
  .products.columns-5 .product,
  .products.columns-6 .product {
    max-width: calc(50% - 11px) !important; /* 1/2 minus gap spacing */
    width: calc(50% - 11px) !important;
  }

  /* Mobile-specific spacing - different logic from desktop */
  .xi-custom-product-grid,
  .woocommerce ul.products.xi-custom-product-grid,
  .woocommerce-page ul.products.xi-custom-product-grid {
    gap: 18px !important; /* Optimized for touch interfaces */
    margin: 20px 0 !important; /* Reduced vertical margin for mobile */
    padding: 0 5px !important; /* Add small horizontal padding */
  }

  /* Mobile product cards need more breathing room */
  .xi-custom-product-card {
    padding: 12px !important; /* Reduced internal padding */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important; /* Enhanced shadow for depth */
  }
}

/* Small phones - Single column with optimized spacing */
@media (max-width: 480px) {
  .xi-custom-product-grid,
  .woocommerce ul.products.xi-custom-product-grid,
  .woocommerce-page ul.products.xi-custom-product-grid,
  .woocommerce .upsells.products,
  .woocommerce .related.products {
    grid-template-columns: 1fr !important;
    gap: 16px !important; /* Optimized single-column spacing */
    margin: 15px 0 !important; /* Further reduced margin */
    padding: 0 8px !important; /* More horizontal padding for small screens */
  }

  /* Small mobile width constraints - 1 column */
  .woocommerce .upsells.products .product,
  .woocommerce .related.products .product,
  .woocommerce .products.columns-4 .product,
  .woocommerce .products.columns-5 .product,
  .woocommerce .products.columns-6 .product,
  .woocommerce .products.columns-7 .product,
  .woocommerce .products.columns-8 .product,
  .products.columns-4 .product,
  .products.columns-5 .product,
  .products.columns-6 .product,
  .products.columns-7 .product,
  .products.columns-8 .product {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Small screen cards - more compact */
  .xi-custom-product-card {
    padding: 10px !important;
    border-radius: 6px !important; /* Smaller radius for mobile */
  }
}

/* Force mobile grid spacing for all product grids */
@media (max-width: 768px) {
  .products,
  ul.products,
  .woocommerce .products,
  .woocommerce ul.products,
  .woocommerce-page .products,
  .woocommerce-page ul.products {
    gap: 20px !important;
  }
}

@media (max-width: 480px) {
  .products,
  ul.products,
  .woocommerce .products,
  .woocommerce ul.products,
  .woocommerce-page .products,
  .woocommerce-page ul.products {
    gap: 0px !important;
  }
}

/* Custom Pagination Styles */
.xi-custom-pagination {
  margin: 30px 0 !important;
  text-align: center !important;
}

.xi-pagination-list {
  display: inline-flex !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 8px !important;
}

.xi-pagination-list li {
  margin: 0 !important;
  padding: 0 !important;
}

.xi-pagination-list a,
.xi-pagination-list span {
  display: block !important;
  padding: 10px 15px !important;
  background: #fff !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 6px !important;
  color: #495057 !important;
  text-decoration: none !important;
  font-weight: 500 !important;
  transition: all 0.3s ease !important;
  min-width: 44px !important;
  text-align: center !important;
}

.xi-pagination-list a:hover {
  background: #0073aa !important;
  color: white !important;
  border-color: #0073aa !important;
  transform: translateY(-1px) !important;
}

/* Current page styling */
.xi-pagination-list .current {
  background: #0073aa !important;
  color: white !important;
  border-color: #0073aa !important;
  cursor: default !important;
}

/* Previous/Next button styling */
.xi-pagination-list .prev,
.xi-pagination-list .next {
  font-weight: 600 !important;
}

/* Dots styling */
.xi-pagination-list .dots {
  background: transparent !important;
  border: none !important;
  color: #6c757d !important;
  cursor: default !important;
}

.xi-pagination-list .dots:hover {
  background: transparent !important;
  transform: none !important;
}

/* Mobile pagination */
@media (max-width: 480px) {
  .xi-pagination-list {
    gap: 4px !important;
  }

  .xi-pagination-list a,
  .xi-pagination-list span {
    padding: 8px 12px !important;
    font-size: 14px !important;
    min-width: 40px !important;
  }
}

/* AJAX Loading States - Enhanced UX */
.xi-catalog-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.xi-catalog-loading-content {
  background: white;
  padding: 30px 40px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-width: 300px;
}

.xi-catalog-loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #0073aa;
  border-radius: 50%;
  animation: xi-spin 1s linear infinite;
  margin: 0 auto 20px auto;
}

.xi-catalog-loading-text {
  color: #333;
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

@keyframes xi-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ========================================
   Lazy Loading Styles
   ======================================== */

/* Lazy loading placeholder styles */
.xi-lazy {
  background: #f0f0f0;
  background-image: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #f8f8f8 50%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: xi-lazy-shimmer 1.5s ease-in-out infinite;
  min-height: 100px;
  position: relative;
}

/* Shimmer animation for loading state */
@keyframes xi-lazy-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Loaded state */
.xi-lazy-loaded {
  animation: xi-lazy-fade-in 0.3s ease-in-out;
  background: none !important;
}

/* Fade in animation */
@keyframes xi-lazy-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Error state */
.xi-lazy-error {
  background: #ffe6e6;
  border: 1px solid #ffcccc;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cc0000;
  font-size: 14px;
}

.xi-lazy-error::after {
  content: "Image failed to load";
}

/* WooCommerce specific lazy loading */
.woocommerce .products .product img.xi-lazy,
.woocommerce-page .products .product img.xi-lazy {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

/* Product gallery lazy loading */
.woocommerce div.product .woocommerce-product-gallery__image img.xi-lazy {
  width: 100%;
  height: auto;
}

/* Thumbnail lazy loading */
.woocommerce div.product .flex-control-thumbs img.xi-lazy {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

/* Related products lazy loading */
.woocommerce .related.products img.xi-lazy,
.woocommerce .upsells.products img.xi-lazy {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

/* Cart and checkout lazy loading */
.woocommerce table.cart img.xi-lazy,
.woocommerce-checkout table.shop_table img.xi-lazy {
  max-width: 100px;
  height: auto;
}

/* Widget lazy loading */
.widget_product_search img.xi-lazy,
.widget_recently_viewed_products img.xi-lazy,
.widget_top_rated_products img.xi-lazy,
.widget_recent_reviews img.xi-lazy,
.widget_products img.xi-lazy {
  width: 100%;
  height: auto;
}

/* Prevent layout shift with aspect ratio */
img[data-src].xi-lazy {
  display: block;
  width: 100%;
  height: auto;
}

/* Loading state for background images */
.xi-lazy-bg {
  background-color: #f0f0f0;
  background-image: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #f8f8f8 50%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: xi-lazy-shimmer 1.5s ease-in-out infinite;
}

.xi-lazy-bg-loaded {
  animation: none;
  background-image: var(--xi-lazy-bg-image);
}

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .xi-lazy {
    animation: none;
    background: #f0f0f0;
  }

  .xi-lazy-loaded {
    animation: none;
  }

  .xi-lazy-bg {
    animation: none;
  }
}

/* Print styles - load all images for printing */
@media print {
  .xi-lazy {
    background: none !important;
    animation: none !important;
  }
}

/* ========================================
   Progressive Loading & Skeleton Screens
   ======================================== */

/* Skeleton loading cards */
.xi-skeleton-card {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 15px;
  overflow: hidden;
  position: relative;
}

.xi-skeleton-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: xi-skeleton-shimmer 1.5s infinite;
}

@keyframes xi-skeleton-shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Skeleton elements */
.xi-skeleton-image {
  background: #f0f0f0;
  width: 100%;
  height: 200px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.xi-skeleton-title {
  background: #f0f0f0;
  height: 20px;
  width: 80%;
  border-radius: 4px;
  margin-bottom: 10px;
}

.xi-skeleton-price {
  background: #f0f0f0;
  height: 24px;
  width: 60%;
  border-radius: 4px;
  margin-bottom: 15px;
}

.xi-skeleton-button {
  background: #f0f0f0;
  height: 40px;
  width: 100%;
  border-radius: 6px;
}

/* Loading indicator */
.xi-loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.xi-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #0073aa;
  border-radius: 50%;
  animation: xi-spin 1s linear infinite;
  margin-bottom: 15px;
}

.xi-loading-text {
  color: #666;
  font-size: 14px;
  font-weight: 500;
}

/* Error states */
.xi-loading-error {
  background: #fff2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  margin: 20px 0;
}

.xi-loading-error p {
  color: #dc2626;
  margin-bottom: 15px;
}

.xi-retry-btn {
  background: #dc2626 !important;
  color: white !important;
  border: none !important;
  padding: 10px 20px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  font-weight: 500 !important;
}

.xi-retry-btn:hover {
  background: #b91c1c !important;
}

/* Progressive loading triggers (invisible) */
.xi-load-more-trigger,
.xi-prefetch-trigger {
  pointer-events: none;
  user-select: none;
}

/* Pagination info */
.xi-pagination-info {
  text-align: center;
  color: #666;
  font-size: 14px;
  margin: 20px 0;
}

/* Smooth transitions for new content */
.xi-custom-product-card {
  animation: xi-fade-in 0.3s ease-in-out;
}

@keyframes xi-fade-in {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading states for buttons */
.xi-add-to-cart-btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.xi-add-to-cart-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: xi-spin 0.8s linear infinite;
}

/* Hover prefetch indicators (for debugging) */
.xi-category-link[data-prefetch-status="loading"]::after {
  content: "⏳";
  margin-left: 5px;
  opacity: 0.5;
}

.xi-category-link[data-prefetch-status="cached"]::after {
  content: "✓";
  margin-left: 5px;
  color: #28a745;
  opacity: 0.7;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .xi-skeleton-image {
    height: 150px;
  }

  .xi-loading-indicator {
    padding: 30px 15px;
  }

  .xi-loading-spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
  }

  .xi-skeleton-card {
    padding: 12px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .xi-skeleton-card::before,
  .xi-loading-spinner,
  .xi-add-to-cart-btn.loading::after {
    animation: none;
  }

  .xi-skeleton-card::before {
    display: none;
  }

  .xi-custom-product-card {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .xi-skeleton-image,
  .xi-skeleton-title,
  .xi-skeleton-price,
  .xi-skeleton-button {
    background: #333;
  }

  .xi-loading-error {
    background: #fff;
    border: 2px solid #000;
  }
}

/* Print styles for progressive loading */
@media print {
  .xi-skeleton-card,
  .xi-loading-indicator,
  .xi-loading-error,
  .xi-load-more-trigger,
  .xi-prefetch-trigger {
    display: none !important;
  }
}

/* ========================================
   Mobile Sidebar Filter Styles
   ======================================== */

/* Responsive Sidebar Container */
.xi-responsive-sidebar .xi-sidebar-desktop {
  display: block;
}

.xi-responsive-sidebar .xi-sidebar-mobile {
  display: none;
}

/* Mobile Layout - Show mobile, hide desktop on mobile viewports */
@media (max-width: 768px) {
  .xi-responsive-sidebar .xi-sidebar-desktop {
    display: none !important;
  }

  .xi-responsive-sidebar .xi-sidebar-mobile {
    display: block !important;
  }
}

/* Default mobile container - Hidden unless inside responsive container */
.xi-sidebar-mobile {
  display: none;
}

/* Mobile Navigation Base Styles */
.xi-mobile-navigation {
  width: 100%;
  padding: 15px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
}

/* Mobile Loading Spinner */
.xi-mobile-navigation.loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background-image: url("../images/Parts4All-favicon.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: xi-spinner-rotate 1s linear infinite;
  z-index: 10;
}

.xi-mobile-navigation.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  z-index: 9;
}

/* Mobile Loading Text */
.xi-mobile-navigation .xi-mobile-loading-text {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  font-size: 14px;
  color: #333;
  font-weight: 500;
  text-align: center;
  display: none;
}

.xi-mobile-navigation.loading .xi-mobile-loading-text {
  display: block;
}

@keyframes xi-spinner-rotate {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Mobile Search Styles */
.xi-mobile-search {
  position: relative;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
}

.xi-search-input {
  width: 100%;
  padding: 10px 40px 10px 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease;
}

.xi-search-input:focus {
  border-color: #007cba;
}

.xi-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: #999;
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: none;
  transition: background-color 0.2s ease;
}

.xi-search-clear:hover {
  background: #666;
}

/* Mobile Header */
.xi-mobile-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
}

.xi-mobile-back {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 8px 12px;
  margin-right: 15px;
  font-size: 14px;
  font-weight: 500;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s ease;
}

.xi-mobile-back:hover {
  background: #e9ecef;
  color: #212529;
}

.xi-mobile-title {
  font-size: 18px;
  font-weight: 700;
  color: #212529;
}

/* Mobile Level Container */
.xi-mobile-level {
  display: none;
}

.xi-mobile-level.active {
  display: block;
  animation: slideIn 0.3s ease-in-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Mobile Grid Layout */
.xi-mobile-grid {
  display: grid;
  gap: 15px;
  margin-bottom: 20px;
  grid-template-columns: repeat(var(--columns, 3), 1fr);
}

/* Level-specific grids inherit from parent .xi-mobile-grid with --columns */
.xi-level1-grid,
.xi-level2-grid,
.xi-level3-grid {
  /* Inherit grid-template-columns from .xi-mobile-grid with --columns custom property */
}

/* Mobile Tiles */
.xi-mobile-tile {
  background: #fff;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.xi-mobile-tile:hover {
  border-color: #0073aa;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 115, 170, 0.15);
}

.xi-mobile-tile.current {
  border-color: #0073aa;
  background: #f8f9ff;
}

.xi-tile-link {
  display: block;
  text-decoration: none;
  color: inherit;
  width: 100%;
  height: 100%;
  padding: 0;
}

/* Tile Image */
.xi-tile-image {
  width: 100%;
  aspect-ratio: 1;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.xi-tile-image img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Level 1 uses contain */
  transition: transform 0.3s ease;
}

.xi-level2-grid .xi-tile-image img {
  object-fit: cover; /* Level 2 uses cover */
}

.xi-mobile-tile:hover .xi-tile-image img {
  transform: scale(1.05);
}

/* Tile Name */
.xi-tile-name {
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: #212529;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Desktop Level 3 categories specific styling */
.xi-level3-grid .xi-tile-name {
  font-size: 16px;
  text-align: center;
  font-weight: 600;
}

/* Desktop layout level 3 categories */
.xi-category-link .xi-category-content .xi-category-info .xi-category-name {
  font-weight: 600 !important;
  /* text-align: center !important; */
}

/* Desktop sidebar filter level 3 categories (if still needed) */
.xi-sidebar-filter .xi-categories-list .xi-level-3 .xi-category-name {
  font-weight: 600 !important;
  text-align: center !important;
}

.xi-tile-count {
  font-size: 12px;
  font-weight: 400;
  color: #6c757d;
  margin-top: 4px;
  display: block;
}

.xi-tile-arrow {
  font-size: 16px;
  color: #0073aa;
  margin-top: 4px;
  display: block;
}

/* Mobile List Layout (Level 3+) */
.xi-mobile-list {
  width: 100%;
}

.xi-mobile-search {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.xi-mobile-search:focus {
  outline: none;
  border-color: #0073aa;
}

.xi-mobile-list-item {
  display: block;
  padding: 15px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  margin-bottom: 8px;
  text-decoration: none;
  color: #212529;
  background: #fff;
  transition: all 0.2s ease;
}

.xi-mobile-list-item:hover {
  background: #f8f9fa;
  border-color: #0073aa;
}

.xi-mobile-list-item.current {
  background: #f8f9ff;
  border-color: #0073aa;
}

.xi-mobile-list-item .xi-item-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.xi-mobile-list-item .xi-item-count {
  font-size: 12px;
  color: #6c757d;
}

/* Responsive Grid Adjustments */
@media (max-width: 480px) {
  .xi-mobile-grid {
    gap: 10px;
  }

  .xi-level1-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .xi-level2-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .xi-level3-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .xi-tile-name {
    padding: 8px;
    font-size: 14px;
    min-height: 40px;
  }

  /* Ensure consistent mobile tile styling for all levels */
  .xi-mobile-tile .xi-tile-name {
    font-size: 14px !important;
    text-align: center !important;
    font-weight: 600 !important;
    padding: 8px !important;
    min-height: 40px !important;
  }

  .xi-mobile-navigation {
    padding: 10px;
  }
}

@media (max-width: 320px) {
  .xi-level1-grid,
  .xi-level2-grid,
  .xi-level3-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Product Card Actions and Status Indicators */
.xi-product-actions {
  margin-top: 12px;
}

.xi-product-actions .button,
.xi-product-actions .added_to_cart {
  width: 100%;
  text-align: center;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
  box-sizing: border-box;
}

.xi-product-actions .button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Product Status Indicators */
.xi-not-purchasable,
.xi-out-of-stock,
.xi-backorder {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  margin-top: 8px;
}

.xi-not-purchasable {
  background: #6c757d;
  border: 1px solid #6c757d;
}

.xi-out-of-stock {
  background: #dc3545;
  border: 1px solid #dc3545;
}

.xi-backorder {
  background: #fd7e14;
  border: 1px solid #fd7e14;
  margin-bottom: 8px;
}

/* Custom Product Card Layout */
.xi-custom-product-card,
.woocommerce .products.columns-6 .product,
.products.columns-6 .product {
  display: block !important;
}

/* Upsell/Related products use flex for equal height */
.woocommerce .upsells.products .product,
.woocommerce .related.products .product {
  display: flex !important;
  flex-direction: column !important;
}

/* Force equal height for grid containers */
.woocommerce .upsells.products,
.woocommerce .related.products,
.xi-products-grid.xi-custom-product-card-grid {
  display: grid !important;
  align-items: stretch !important;
}

/* Archives use natural height, Upsell/Related should too for consistent spacing */
.woocommerce .upsells.products .product,
.woocommerce .related.products .product,
.xi-products-grid .xi-product-item {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
}

/* Legacy WooCommerce products for compatibility */
.woocommerce .upsells.products .product,
.woocommerce .related.products .product {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
}

.xi-custom-product-card .xi-product-image,
.woocommerce .upsells.products .product .woocommerce-loop-product__link,
.woocommerce .related.products .product .woocommerce-loop-product__link,
.woocommerce .products.columns-6 .product .woocommerce-loop-product__link,
.products.columns-6 .product .woocommerce-loop-product__link {
  margin-bottom: 12px !important;
  flex-shrink: 0 !important; /* Prevent image from shrinking */
}

.xi-custom-product-card .xi-product-title,
.woocommerce .upsells.products .product .woocommerce-loop-product__title,
.woocommerce .related.products .product .woocommerce-loop-product__title,
.woocommerce .products.columns-6 .product .woocommerce-loop-product__title,
.woocommerce .products.columns-7 .product .woocommerce-loop-product__title,
.woocommerce .products.columns-8 .product .woocommerce-loop-product__title,
.products.columns-6 .product .woocommerce-loop-product__title,
.products.columns-7 .product .woocommerce-loop-product__title,
.products.columns-8 .product .woocommerce-loop-product__title {
  flex-grow: 1 !important;
  margin-bottom: 8px !important;
  line-height: 1.3 !important;
  min-height: 2.6em !important; /* Ensure minimum height for 2 lines */
  display: flex !important;
  align-items: flex-start !important;
}

.xi-custom-product-card .xi-product-title a,
.woocommerce .upsells.products .product .woocommerce-loop-product__title,
.woocommerce .related.products .product .woocommerce-loop-product__title,
.woocommerce .products.columns-6 .product .woocommerce-loop-product__title,
.woocommerce .products.columns-7 .product .woocommerce-loop-product__title,
.woocommerce .products.columns-8 .product .woocommerce-loop-product__title,
.products.columns-6 .product .woocommerce-loop-product__title,
.products.columns-7 .product .woocommerce-loop-product__title,
.products.columns-8 .product .woocommerce-loop-product__title {
  text-decoration: none !important;
  color: inherit !important;
}

.xi-custom-product-card .xi-product-title a:hover,
.woocommerce .upsells.products .product .woocommerce-loop-product__title:hover,
.woocommerce .related.products .product .woocommerce-loop-product__title:hover,
.woocommerce
  .products.columns-6
  .product
  .woocommerce-loop-product__title:hover,
.woocommerce
  .products.columns-7
  .product
  .woocommerce-loop-product__title:hover,
.woocommerce
  .products.columns-8
  .product
  .woocommerce-loop-product__title:hover,
.products.columns-6 .product .woocommerce-loop-product__title:hover,
.products.columns-7 .product .woocommerce-loop-product__title:hover,
.products.columns-8 .product .woocommerce-loop-product__title:hover {
  color: #0073aa !important;
}

.xi-custom-product-card .xi-product-price,
.woocommerce .upsells.products .product .price,
.woocommerce .related.products .product .price,
.woocommerce .products.columns-6 .product .price,
.woocommerce .products.columns-7 .product .price,
.woocommerce .products.columns-8 .product .price,
.products.columns-6 .product .price,
.products.columns-7 .product .price,
.products.columns-8 .product .price {
  margin-bottom: 8px !important;
  font-weight: 600 !important;
}

.xi-custom-product-card .xi-product-actions,
.woocommerce .upsells.products .product .add_to_cart_button,
.woocommerce .related.products .product .add_to_cart_button,
.woocommerce .products.columns-6 .product .add_to_cart_button,
.woocommerce .products.columns-7 .product .add_to_cart_button,
.woocommerce .products.columns-8 .product .add_to_cart_button,
.products.columns-6 .product .add_to_cart_button,
.products.columns-7 .product .add_to_cart_button,
.products.columns-8 .product .add_to_cart_button {
  margin-top: auto !important;
  align-self: stretch !important;
}

/* Copy grid mode logic to rows mode */
.xi-product-row-actions .xi-product-actions {
  margin-top: auto;
}

/* ===== PRODUCT OVERLAY SYSTEM ===== */

/* Product card needs relative positioning for overlays */
.xi-custom-product-card {
  position: relative !important;
  overflow: visible !important;
}

/* Base overlay container styles */
.xi-product-overlays {
  position: absolute !important;
  z-index: 10 !important;
  pointer-events: none !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  top: 0 !important;
  left: 0 !important;
  overflow: visible !important;
}

/* Position-specific containers no longer needed - individual images handle positioning */

/* Overlay image styles */
.xi-product-overlay-image {
  display: block !important;
  width: auto !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 4px !important;
  transition: all 0.3s ease !important;
  background: transparent !important;
  object-fit: contain !important;
  flex-shrink: 0 !important; /* Prevent images from shrinking */
  min-width: 15px !important; /* Minimum width to maintain visibility */
}

/* Hover effects for overlays */
.xi-custom-product-card:hover .xi-product-overlay-image {
  transform: scale(1.05) !important;
  box-shadow: none !important;
}

/* RTL support - let WordPress handle direction automatically */

/* Mobile responsive overlays */
@media (max-width: 768px) {
  .xi-product-overlay-image {
    max-width: 30px !important;
    height: auto !important;
  }

  .xi-product-overlays {
    gap: 2px !important;
  }
}

/* Ensure overlays work in Related Products */
.xi-related-products .xi-custom-product-card {
  position: relative !important;
  overflow: visible !important;
}

.xi-related-products .xi-product-overlays {
  z-index: 15 !important;
}

/* Hook Content Styling - Force natural DOM positioning */
.xi-hook-content {
  margin: 8px 0;
  position: static !important;
  float: none !important;
  display: block !important;
  clear: none !important;
  order: unset !important;
  flex-basis: auto !important;
  align-self: auto !important;
}

/* Ensure hook content respects natural flow in product cards */
.woocommerce .related.products .product .xi-hook-content,
.woocommerce .upsells.products .product .xi-hook-content,
.xi-custom-product-card .xi-hook-content {
  position: static !important;
  float: none !important;
  display: block !important;
  clear: none !important;
  order: unset !important;
  flex-basis: auto !important;
  align-self: auto !important;
  width: auto !important;
  height: auto !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  z-index: auto !important;
  direction: ltr !important;
}

/* Specific fixes for individual hook positioning */
.xi-hook-content.xi-hook-before-item,
.xi-hook-content.xi-hook-before-title,
.xi-hook-content.xi-hook-item-title-hook,
.xi-hook-content.xi-hook-after-title,
.xi-hook-content.xi-hook-after-item {
  position: relative !important;
  display: block !important;
  direction: ltr !important;
}

/* Remove flex layout that causes spacing issues - but allow for equal height flex */
.woocommerce .related.products .product,
.woocommerce .upsells.products .product {
  display: flex !important;
  flex-direction: column !important;
}

/* Ensure hooks maintain DOM order within flexbox */
.xi-hook-content.xi-hook-before-item {
  order: -10 !important;
}

.xi-product-image {
  order: 0 !important;
}

.xi-hook-content.xi-hook-before-title {
  order: 1 !important;
}

.xi-hook-content.xi-hook-item-title-hook {
  order: 2 !important;
}

.xi-product-title {
  order: 3 !important;
}

.xi-hook-content.xi-hook-after-title {
  order: 4 !important;
}

.xi-product-price {
  order: 5 !important;
}

.xi-hook-content.xi-hook-after-item {
  order: 6 !important;
}

.xi-product-actions {
  order: 7 !important;
}

.xi-custom-product-card .xi-product-title,
.xi-custom-product-card .xi-product-price {
  margin-bottom: 3px !important;
}

/* Make Custom Product Card component self-contained - override any parent container styling */
.xi-custom-product-card .woocommerce-loop-product__title,
.xi-custom-product-card .price,
.xi-custom-product-card .xi-product-title,
.xi-custom-product-card .xi-product-price {
  margin-bottom: 10px !important;
}

.xi-custom-product-card .woocommerce-loop-product__link {
  margin-bottom: 12px !important;
}

.xi-custom-product-card .add_to_cart_button {
  margin-top: auto !important;
}

/* Ensure custom product card elements are properly structured for equal height */
.xi-products-grid .xi-product-item.xi-custom-product-card > *,
.xi-related-products .xi-product-item.xi-custom-product-card > *,
.xi-upsell-products .xi-product-item.xi-custom-product-card > * {
  flex-shrink: 0 !important;
}

/* FORCE title truncation in Related/Upsell sections - all possible selectors */
.xi-related-products h3,
.xi-upsell-products h3,
.xi-related-products .xi-product-title,
.xi-upsell-products .xi-product-title,
.xi-related-products .woocommerce-loop-product__title,
.xi-upsell-products .woocommerce-loop-product__title,
section.xi-related-products h3,
section.xi-upsell-products h3,
section.xi-related-products .xi-product-title,
section.xi-upsell-products .xi-product-title,
.xi-related-products h3 a,
.xi-upsell-products h3 a,
.xi-related-products .xi-product-title a,
.xi-upsell-products .xi-product-title a {
  height: 3.9em !important;
  max-height: 3.9em !important;
  min-height: 3.9em !important;
  line-height: 1.3 !important;
  margin-bottom: 12px !important;
  overflow: hidden !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  text-overflow: ellipsis !important;
  word-wrap: break-word !important;
}

/* Product Card Hook Images */
.xi-hook-content .xi-hook-image {
  border-radius: 4px;
  transition: opacity 0.3s ease;
}

.xi-hook-content .xi-hook-image:hover {
  opacity: 0.9;
}

/* Image size classes for consistent sizing */
.xi-hook-image.xi-hook-image-small {
  width: 80px !important;
  max-width: 80px !important;
}

.xi-hook-image.xi-hook-image-medium {
  width: 120px !important;
  max-width: 120px !important;
}

.xi-hook-image.xi-hook-image-large {
  width: 160px !important;
  max-width: 160px !important;
}

.xi-hook-image.xi-hook-image-full-width {
  width: 100% !important;
  max-width: 100% !important;
}

/* Image positioning classes */
.xi-hook-image.xi-hook-image-left {
  margin: 0 auto 0 0 !important;
}

.xi-hook-image.xi-hook-image-center {
  margin: 0 auto !important;
}

.xi-hook-image.xi-hook-image-right {
  margin: 0 0 0 auto !important;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .xi-hook-image.xi-hook-image-large {
    width: 120px !important;
    max-width: 120px !important;
  }

  .xi-hook-image.xi-hook-image-custom {
    max-width: 120px !important;
  }
}

/* Removed problematic order rules - hooks now follow HTML order */

/* ========================================
   XI INFINITE LOAD STYLES
   ======================================== */

/* Hide default pagination when infinite load is active */
.xi-hidden-pagination,
.xi-pagination-hidden .xi-custom-pagination,
.xi-pagination-hidden .woocommerce-pagination {
  display: none !important;
}

/* Infinite loader spinner and text */
.xi-infinite-loader {
  text-align: center;
  padding: 30px 0;
  clear: both;
  margin: 20px 0;
}

.xi-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  margin: 0 auto 15px;
}

.xi-spinner-circle {
  width: 100%;
  height: 100%;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #333;
  border-radius: 50%;
  animation: xi-spin 1s linear infinite;
}

@keyframes xi-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.xi-loading-text {
  display: block;
  color: #666;
  font-size: 14px;
  font-weight: 500;
}

/* Show more button wrapper and styling */
.xi-load-more-wrapper {
  text-align: center;
  padding: 30px 0;
  clear: both;
  margin: 20px 0;
}

.xi-load-more-btn {
  display: inline-block;
  padding: 12px 30px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  line-height: 1.4;
}

.xi-load-more-btn:hover:not(:disabled) {
  background: #555;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  color: #fff;
}

.xi-load-more-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.xi-btn-loader {
  display: inline-block;
  font-size: 14px;
}

/* End of products message */
.xi-no-more-products {
  text-align: center;
  padding: 20px 0;
  color: #666;
  font-style: italic;
  font-size: 14px;
}

/* Error message styling */
.xi-load-error {
  text-align: center;
  padding: 20px;
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  margin: 20px 0;
  font-size: 14px;
}

/* Fade in animation for new products */
.products .product {
  animation: xi-fadeIn 0.3s ease;
}

@keyframes xi-fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
  .xi-load-more-btn {
    width: 100%;
    max-width: 300px;
    padding: 15px 30px;
    font-size: 16px;
  }

  .xi-infinite-loader,
  .xi-load-more-wrapper {
    padding: 20px 15px;
  }

  .xi-spinner {
    width: 35px;
    height: 35px;
  }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  .xi-spinner-circle {
    border-color: #555;
    border-top-color: #fff;
  }

  .xi-loading-text,
  .xi-no-more-products {
    color: #ccc;
  }

  .xi-load-more-btn {
    background: #555;
    color: #fff;
  }

  .xi-load-more-btn:hover:not(:disabled) {
    background: #777;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .xi-load-more-btn {
    border: 2px solid currentColor;
  }

  .xi-spinner-circle {
    border-width: 4px;
  }
}
