/**
 * Product Listing Widget Styles
 *
 * @package WooProductListingElementor
 */

/* CSS Variables for easy customization */
:root {
  --wpel-primary-color: #ffb20e;
  --wpel-border-color: #e0e0e0;
  --wpel-text-color: #333;
  --wpel-light-bg: #f9f9f9;
  --wpel-hover-bg: #f5f5f5;
  --wpel-transition: all 0.3s ease;
  --wpel-border-radius: 8px;
  --wpel-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --wpel-gap: 20px;
}

/* Main Widget Container */
.wpel-product-listing {
  width: 100%;
  margin: 0 auto;
  font-family: inherit;
}

/* Breadcrumbs */
.wpel-breadcrumbs {
  margin-bottom: var(--wpel-gap);
  padding: 10px 0;
  border-bottom: 1px solid var(--wpel-border-color);
}

.wpel-breadcrumbs__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.wpel-breadcrumbs__list li:not(:last-child)::after {
  content: "/";
  margin-left: 8px;
  color: #999;
}

.wpel-breadcrumbs__list a {
  color: var(--wpel-primary-color);
  text-decoration: none;
  transition: var(--wpel-transition);
}

.wpel-breadcrumbs__list a:hover {
  text-decoration: underline;
}

/* Filter Bar */
.wpel-filter-bar {
  margin-bottom: var(--wpel-gap);
  padding: 15px;
  background: var(--wpel-light-bg);
  border: 1px solid var(--wpel-border-color);
  border-radius: var(--wpel-border-radius);
}

.wpel-filter-bar__content {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
}

.wpel-filter-item {
  display: flex;
  align-items: start;
  gap: 8px;
}

.wpel-filter-item label {
  font-weight: 500;
  margin: 0;
  font-size: 14px;
}

.wpel-sort-select {
  padding: 8px 12px;
  border: 1px solid var(--wpel-border-color);
  border-radius: 4px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  transition: var(--wpel-transition);
}

.wpel-sort-select:hover,
.wpel-sort-select:focus {
  border-color: var(--wpel-primary-color);
  outline: none;
}

.wpel-filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--wpel-border-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--wpel-transition);
}

.wpel-filter-toggle-btn:hover {
  background: var(--wpel-hover-bg);
  border-color: var(--wpel-primary-color);
}

.wpel-filter-toggle-icon {
  transition: transform 0.3s ease;
}

.wpel-filter-toggle-btn[aria-expanded="true"] .wpel-filter-toggle-icon {
  transform: rotate(180deg);
}

/* Filters Panel */
.wpel-filters-panel {
  margin-top: 15px;
  padding: 20px;
  background: white;
  border: 1px solid var(--wpel-border-color);
  border-radius: var(--wpel-border-radius);
}

.wpel-filters-panel[hidden] {
  display: none;
}

.wpel-filter-group {
  margin-bottom: 20px;
}

.wpel-filter-group:last-of-type {
  margin-bottom: 15px;
}

.wpel-filter-group__title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--wpel-text-color);
}

.wpel-price-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wpel-price-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--wpel-border-color);
  border-radius: 4px;
  font-size: 14px;
}

.wpel-price-input:focus {
  border-color: var(--wpel-primary-color);
  outline: none;
}

.wpel-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

.wpel-checkbox-label input[type="checkbox"] {
  cursor: pointer;
}

.wpel-filter-actions {
  display: flex;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--wpel-border-color);
}

.wpel-apply-filters-btn,
.wpel-clear-filters-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--wpel-transition);
}

.wpel-apply-filters-btn {
  background: var(--wpel-primary-color);
  color: white;
}

.wpel-apply-filters-btn:hover {
  background: #e6a00d;
}

.wpel-clear-filters-btn {
  background: #f5f5f5;
  color: var(--wpel-text-color);
  border: 1px solid var(--wpel-border-color);
}

.wpel-clear-filters-btn:hover {
  background: #e8e8e8;
}

/* Content Wrapper */
.wpel-content-wrapper {
  display: flex;
  gap: var(--wpel-gap);
}

/* Sidebar */
.wpel-sidebar {
  width: 25%;
  flex-shrink: 0;
}

/* Mobile Categories Toggle - Hidden on Desktop */
.wpel-mobile-categories-toggle {
  display: none;
}

.wpel-categories-panel {
  display: block;
}

.wpel-sidebar__title {
  margin: 0 0 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--wpel-primary-color);
  font-size: 18px;
  font-weight: 600;
}

.wpel-category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wpel-category-item {
  margin-bottom: 5px;
}

.wpel-category-item--depth-1 {
  padding-left: 20px;
}

.wpel-category-item--depth-2 {
  padding-left: 40px;
}

.wpel-category-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  color: var(--wpel-text-color);
  text-decoration: none;
  border-radius: 4px;
  transition: var(--wpel-transition);
  font-size: 14px;
}

.wpel-category-link:hover {
  background: var(--wpel-hover-bg);
  color: var(--wpel-primary-color);
}

.wpel-category-item--active > .wpel-category-link {
  background: var(--wpel-primary-color);
  color: white;
  font-weight: 500;
}

.wpel-category-count {
  opacity: 0.7;
  font-size: 12px;
}

.wpel-category-list--children {
  list-style: none;
  margin: 5px 0 0;
  padding: 0;
}

/* Products Area */
.wpel-products-area {
  flex: 1;
  min-width: 0;
}

/* Products Grid */
.wpel-products-grid {
  display: grid;
  gap: var(--wpel-gap);
  margin-bottom: var(--wpel-gap);
}

.wpel-products-grid--columns-2 {
  grid-template-columns: repeat(2, 1fr);
}

.wpel-products-grid--columns-3 {
  grid-template-columns: repeat(3, 1fr);
}

.wpel-products-grid--columns-4 {
  grid-template-columns: repeat(4, 1fr);
}

.wpel-products-grid--columns-5 {
  grid-template-columns: repeat(5, 1fr);
}

.wpel-products-grid--columns-6 {
  grid-template-columns: repeat(6, 1fr);
}

/* Loading State */
.wpel-products-grid.wpel-loading {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.wpel-products-grid.wpel-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid var(--wpel-border-color);
  border-top-color: var(--wpel-primary-color);
  border-radius: 50%;
  animation: wpel-spin 1s linear infinite;
}

@keyframes wpel-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Product Card */
.wpel-product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid var(--wpel-border-color);
  border-radius: var(--wpel-border-radius);
  overflow: hidden;
  transition: var(--wpel-transition);
}

.wpel-product-card:hover {
  box-shadow: var(--wpel-box-shadow);
  transform: translateY(-2px);
}

.wpel-product-card__image {
  position: relative;
  overflow: hidden;
  background: var(--wpel-light-bg);
}

.wpel-product-card__image img {
  width: 100%;
  height: auto;
  display: block;
  transition: var(--wpel-transition);
}

.wpel-product-card:hover .wpel-product-card__image img {
  transform: scale(1.05);
}

.wpel-product-card__content {
  padding: 15px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.wpel-product-card__badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 4px;
  z-index: 1;
}

.wpel-product-card__badge--sale {
  background: #e74c3c;
  color: white;
}

.wpel-product-card__title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
}

.wpel-product-card__title a {
  color: var(--wpel-text-color);
  text-decoration: none;
  transition: var(--wpel-transition);
}

.wpel-product-card__title a:hover {
  color: var(--wpel-primary-color);
}

.wpel-product-card__rating {
  margin-bottom: 10px;
  font-size: 14px;
}

.wpel-product-card__rating .star-rating {
  font-size: 14px;
}

.wpel-product-card__price {
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: 600;
  color: var(--wpel-text-color);
}

.wpel-product-card__price del {
  opacity: 0.5;
  font-size: 14px;
  font-weight: normal;
  margin-right: 8px;
}

.wpel-product-card__price ins {
  text-decoration: none;
  color: #27ae60;
}

.wpel-product-card__actions {
  margin-top: auto;
}

.wpel-product-card__button {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: var(--wpel-primary-color);
  color: white;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--wpel-transition);
}

.wpel-product-card__button:hover {
  background: #e6a00d;
  color: white;
}

.wpel-product-card__button.added {
  background: #27ae60;
}

/* No Products */
.wpel-no-products {
  padding: 40px 20px;
  text-align: center;
  font-size: 16px;
  color: #999;
  border: 2px dashed var(--wpel-border-color);
  border-radius: var(--wpel-border-radius);
}

/* Error */
.wpel-error {
  padding: 20px;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: var(--wpel-border-radius);
  color: #c33;
  text-align: center;
}

/* Pagination */
.wpel-pagination {
  display: flex;
  justify-content: center;
  margin-top: var(--wpel-gap);
}

.wpel-pagination__list {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
  justify-content: center;
}

.wpel-pagination__item--dots {
  padding: 8px 4px;
  color: #999;
}

.wpel-pagination__link {
  display: block;
  padding: 10px 15px;
  background: white;
  color: var(--wpel-text-color);
  text-decoration: none;
  border: 1px solid var(--wpel-border-color);
  border-radius: 4px;
  font-size: 14px;
  transition: var(--wpel-transition);
  min-width: 40px;
  text-align: center;
}

.wpel-pagination__link:hover {
  background: var(--wpel-hover-bg);
  border-color: var(--wpel-primary-color);
  color: var(--wpel-primary-color);
}

.wpel-pagination__link--current {
  background: var(--wpel-primary-color);
  color: white;
  border-color: var(--wpel-primary-color);
  font-weight: 600;
}

.wpel-pagination__link--current:hover {
  background: var(--wpel-primary-color);
  color: white;
}

.wpel-pagination__list--prev-next {
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
}

.wpel-pagination__item--info {
  padding: 10px 15px;
  font-size: 14px;
  color: #666;
}

/* Load More Button */
.wpel-load-more {
  display: block;
  margin: var(--wpel-gap) auto 0;
  padding: 12px 30px;
  background: var(--wpel-primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--wpel-transition);
}

.wpel-load-more:hover {
  background: #e6a00d;
}

.wpel-load-more:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Infinite Scroll Trigger */
.wpel-infinite-scroll-trigger {
  padding: 20px;
  text-align: center;
}

.wpel-loading {
  display: inline-block;
  color: #999;
  font-size: 14px;
}

/* Tablet Styles */
@media (max-width: 1024px) {
  .wpel-content-wrapper {
    flex-direction: column;
  }

  .wpel-sidebar {
    width: 100%;
    /* order: 2; */
    margin-top: var(--wpel-gap);
  }

  .wpel-products-area {
    /* order: 1; */
  }

  .wpel-products-grid[data-columns-tablet="1"] {
    grid-template-columns: repeat(1, 1fr);
  }

  .wpel-products-grid[data-columns-tablet="2"] {
    grid-template-columns: repeat(2, 1fr);
  }

  .wpel-products-grid[data-columns-tablet="3"] {
    grid-template-columns: repeat(3, 1fr);
  }

  .wpel-products-grid[data-columns-tablet="4"] {
    grid-template-columns: repeat(4, 1fr);
  }

  .wpel-category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .wpel-category-item {
    margin-bottom: 0;
  }

  .wpel-category-item--depth-1,
  .wpel-category-item--depth-2 {
    padding-left: 0;
  }
}

/* Mobile Styles */
@media (max-width: 768px) {
  :root {
    --wpel-gap: 15px;
  }

  .wpel-filter-bar__content {
    flex-direction: column;
    align-items: stretch;
  }

  .wpel-filter-item {
    width: 100%;
  }

  .wpel-sort-select {
    width: 100%;
  }

  .wpel-filters-panel {
    padding: 15px;
  }

  .wpel-filter-actions {
    flex-direction: column;
  }

  .wpel-apply-filters-btn,
  .wpel-clear-filters-btn {
    width: 100%;
  }

  /* Mobile Sidebar Styles */
  .wpel-sidebar {
    width: 100% !important;
    margin-bottom: 20px;
  }

  .wpel-mobile-categories-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 15px;
    background: var(--wpel-primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wpel-transition);
  }

  .wpel-mobile-categories-toggle:hover {
    background: #e6a00d;
  }

  .wpel-toggle-icon {
    transition: transform 0.3s ease;
  }

  .wpel-mobile-categories-toggle[aria-expanded="true"] .wpel-toggle-icon {
    transform: rotate(180deg);
  }

  .wpel-categories-panel {
    display: none;
    margin-top: 10px;
    padding: 15px;
    background: white;
    border: 1px solid var(--wpel-border-color);
    border-radius: 4px;
  }

  .wpel-categories-panel.is-open {
    display: block;
  }

  .wpel-sidebar__title {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .wpel-category-link {
    padding: 12px 10px;
    font-size: 15px;
  }

  .wpel-category-item {
    margin-bottom: 3px;
  }

  .wpel-category-item--depth-1 {
    padding-left: 15px;
  }

  .wpel-category-item--depth-2 {
    padding-left: 30px;
  }

  .wpel-products-area {
    width: 100% !important;
  }
  .wpel-products-grid[data-columns-mobile="1"] {
    grid-template-columns: repeat(1, 1fr);
  }

  .wpel-products-grid[data-columns-mobile="2"] {
    grid-template-columns: repeat(2, 1fr);
  }

  .wpel-product-card__title {
    font-size: 14px;
  }

  .wpel-product-card__price {
    font-size: 16px;
  }

  .wpel-pagination__link {
    padding: 8px 12px;
    min-width: 36px;
    font-size: 13px;
  }
}

/* Accessibility */
.wpel-product-listing *:focus-visible {
  outline: 2px solid var(--wpel-primary-color);
  outline-offset: 2px;
}

/* Screen reader only text */
.wpel-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Print Styles */
@media print {
  .wpel-filter-bar,
  .wpel-sidebar,
  .wpel-pagination {
    display: none;
  }

  .wpel-products-area {
    width: 100%;
  }

  .wpel-product-card {
    break-inside: avoid;
  }
}
