/**
 * Frontend Styles
 *
 * @package Aoprema_Product_Widget
 */

/* Widget Container */
.aoprema-product-widget {
  position: relative;
  width: 100%;
}

@media (max-width: 768px) {
  .aoprema-product-widget {
    padding: 0 15px;
  }
}

/* View Controls Container */
.aoprema-view-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 15px;
  flex-wrap: wrap;
}

/* View Toggle */
.aoprema-view-toggle {
  display: flex;
  gap: 5px;
  align-items: center;
}

.aoprema-view-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 8px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #666;
  border-radius: 4px;
}

.aoprema-view-toggle button:hover {
  background: #e9e9e9;
  color: #333;
}

.aoprema-view-toggle button.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

.aoprema-view-toggle button svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* Sort Control */
.aoprema-sort-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.aoprema-sort-label {
  font-size: 14px;
  color: #666;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
}

.aoprema-sort-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 150px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 35px;
}

.aoprema-sort-select:hover {
  border-color: #999;
}

.aoprema-sort-select:focus {
  outline: none;
  border-color: #333;
  box-shadow: 0 0 0 2px rgba(51, 51, 51, 0.1);
}

@media (max-width: 768px) {
  .aoprema-view-controls {
    margin-bottom: 15px;
    flex-direction: column;
    align-items: stretch;
  }

  .aoprema-view-toggle {
    justify-content: flex-end;
  }

  .aoprema-sort-control {
    justify-content: space-between;
  }

  .aoprema-sort-select {
    flex: 1;
    min-width: auto;
  }
}

/* Products Wrapper */
.aoprema-products-wrapper {
  position: relative;
}

/* Products Grid */
.aoprema-products.aoprema-products-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(4, 1fr);
}

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

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

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

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

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

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

/* Responsive Grid */
@media (max-width: 1024px) {
  .aoprema-products.aoprema-products-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

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

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

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

@media (max-width: 768px) {
  .aoprema-products.aoprema-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

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

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

@media (max-width: 480px) {
  /* Grid view: keep 2 columns on very small screens */
  .aoprema-products.aoprema-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* Only go single column if explicitly set */
  .aoprema-products-columns-mobile-1.aoprema-products-grid {
    grid-template-columns: repeat(1, 1fr);
  }
}

/* Products List */
.aoprema-products.aoprema-products-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 20px;
  /* Override grid styles */
  grid-template-columns: none !important;
}

.aoprema-products-list .aoprema-product-card,
.aoprema-product-card.aoprema-product-list-item {
  display: flex !important;
  flex-direction: row !important;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
}

.aoprema-products-list .aoprema-product-card .aoprema-product-image,
.aoprema-product-card.aoprema-product-list-item .aoprema-product-image {
  flex: 0 0 200px;
  max-width: 200px;
}

.aoprema-products-list .aoprema-product-card .aoprema-product-content,
.aoprema-product-card.aoprema-product-list-item .aoprema-product-content {
  flex: 1;
  align-items: flex-start;
  text-align: left;
}

/* List view on tablet */
@media (max-width: 768px) {
  .aoprema-products-list .aoprema-product-card .aoprema-product-image,
  .aoprema-product-card.aoprema-product-list-item .aoprema-product-image {
    flex: 0 0 150px;
    max-width: 150px;
  }
}

/* List view on mobile - image takes 50% width and full height */
@media (max-width: 480px) {
  .aoprema-products-list .aoprema-product-card,
  .aoprema-product-card.aoprema-product-list-item {
    flex-direction: row !important;
    gap: 0;
    align-items: stretch;
  }

  .aoprema-products-list .aoprema-product-card .aoprema-product-image,
  .aoprema-product-card.aoprema-product-list-item .aoprema-product-image {
    flex: 0 0 50%;
    max-width: 50%;
    display: flex;
  }

  .aoprema-products-list .aoprema-product-card .aoprema-product-image a,
  .aoprema-product-card.aoprema-product-list-item .aoprema-product-image a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 10px;
  }

  .aoprema-products-list .aoprema-product-card .aoprema-product-image img,
  .aoprema-product-card.aoprema-product-list-item .aoprema-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .aoprema-products-list .aoprema-product-card .aoprema-product-content,
  .aoprema-product-card.aoprema-product-list-item .aoprema-product-content {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .aoprema-products-list .aoprema-product-card .aoprema-product-title,
  .aoprema-product-card.aoprema-product-list-item .aoprema-product-title {
    font-size: 14px;
    margin-bottom: 5px;
  }

  .aoprema-products-list .aoprema-product-card .aoprema-product-price,
  .aoprema-product-card.aoprema-product-list-item .aoprema-product-price {
    font-size: 15px;
    margin-bottom: 8px;
  }

  .aoprema-products-list .aoprema-product-card .aoprema-product-button-wrapper,
  .aoprema-product-card.aoprema-product-list-item
    .aoprema-product-button-wrapper {
    padding-top: 8px;
    margin-top: auto;
  }
}

/* Product Card - Grid Mode */
.aoprema-products-grid .aoprema-product-card {
  display: flex !important;
  flex-direction: column !important;
}

/* Override list-item class when in grid mode */
.aoprema-products-grid .aoprema-product-card.aoprema-product-list-item {
  display: flex !important;
  flex-direction: column !important;
}

.aoprema-products-grid .aoprema-product-card .aoprema-product-image {
  flex: none !important;
  max-width: 100% !important;
}

/* Product Card - Base Styles */
.aoprema-product-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  height: 100%;
  padding: 10px;
}

.aoprema-product-card.aoprema-hover-effect:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* Product Image */
.aoprema-product-image {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.aoprema-product-image a {
  display: block;
}

.aoprema-product-image img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

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

/* Sale Badge */
.aoprema-sale-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #ff4444;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  z-index: 1;
}

/* Product Content */
.aoprema-product-content {
  padding: 15px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Product Title */
.aoprema-product-title {
  margin: 0 0 10px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.aoprema-product-sku {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.3;
  color: #6b6b6b;
}

.aoprema-product-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
}

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

/* Product Price */
.aoprema-product-price {
  margin: 0 0 10px 0;
  font-size: 18px;
  font-weight: 700;
  color: #333;
}

.aoprema-product-price del {
  color: #999;
  font-size: 14px;
  font-weight: 400;
  margin-right: 5px;
}

.aoprema-product-price ins {
  text-decoration: none;
}

/* Product Rating */
.aoprema-product-rating {
  margin: 0 0 10px 0;
}

.aoprema-product-rating .star-rating {
  margin: 0;
}

/* Product Description - Hidden in grid, shown in list */
.aoprema-product-description {
  margin: 0 0 15px 0;
  color: #666;
  font-size: 14px;
  line-height: 1.6;
  display: none;
}

.aoprema-products-list .aoprema-product-description,
.aoprema-product-list-item .aoprema-product-description {
  display: block;
}

/* Product Button Wrapper */
.aoprema-product-button-wrapper {
  margin-top: auto;
  padding-top: 15px;
  text-align: center;
  width: 100%;
}

.aoprema-product-button-wrapper .button,
.aoprema-product-button-wrapper .add_to_cart_button {
  display: inline-block;
  padding: 10px 20px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.aoprema-product-button-wrapper .button:hover,
.aoprema-product-button-wrapper .add_to_cart_button:hover {
  background: #555;
  color: #fff;
}

.aoprema-product-button-wrapper .button.loading,
.aoprema-product-button-wrapper .add_to_cart_button.loading {
  opacity: 0.7;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .aoprema-product-button-wrapper .button,
  .aoprema-product-button-wrapper .add_to_cart_button {
    font-size: 14px;
    padding: 8px 16px;
  }
}

/* No Products */
.aoprema-no-products {
  text-align: center;
  padding: 40px 20px;
  color: #666;
  font-size: 16px;
}

/* Pagination */
.aoprema-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid #e0e0e0;
  flex-wrap: wrap;
}

.aoprema-pagination-prev-next {
  justify-content: space-between;
  max-width: 100%;
}

.aoprema-pagination a,
.aoprema-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  background: #fff;
}

.aoprema-pagination a:hover {
  background: #333;
  color: #fff;
  border-color: #333;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.aoprema-pagination .current,
.aoprema-pagination span.current {
  background: #333;
  color: #fff;
  border-color: #333;
  cursor: default;
  font-weight: 600;
}

.aoprema-pagination .dots,
.aoprema-pagination span.dots {
  border: none;
  background: transparent;
  cursor: default;
  color: #999;
  padding: 0;
  min-width: auto;
}

.aoprema-pagination ul {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.aoprema-pagination ul li {
  margin: 0;
  display: inline-flex;
  list-style: none;
}

.aoprema-pagination ul li a,
.aoprema-pagination ul li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* WordPress page-numbers pagination styles */
.aoprema-pagination .page-numbers,
.aoprema-product-widget .page-numbers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.aoprema-pagination .page-numbers li,
.aoprema-product-widget .page-numbers li {
  list-style: none;
  margin: 0;
  padding: 0;
  display: inline-flex;
}

.aoprema-pagination .page-numbers li::before,
.aoprema-product-widget .page-numbers li::before,
.aoprema-pagination .page-numbers li::marker,
.aoprema-product-widget .page-numbers li::marker {
  display: none;
  content: none;
}

.aoprema-pagination .page-numbers a,
.aoprema-pagination .page-numbers span,
.aoprema-product-widget .page-numbers a,
.aoprema-product-widget .page-numbers span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  background: #fff;
  line-height: 1;
}

.aoprema-pagination .page-numbers a:hover,
.aoprema-product-widget .page-numbers a:hover {
  background: #333;
  color: #fff;
  border-color: #333;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.aoprema-pagination .page-numbers .current,
.aoprema-pagination .page-numbers span.current,
.aoprema-product-widget .page-numbers .current,
.aoprema-product-widget .page-numbers span.current {
  background: #333;
  color: #fff;
  border-color: #333;
  cursor: default;
  font-weight: 600;
}

.aoprema-pagination .page-numbers .dots,
.aoprema-pagination .page-numbers span.dots,
.aoprema-product-widget .page-numbers .dots,
.aoprema-product-widget .page-numbers span.dots {
  border: none;
  background: transparent;
  cursor: default;
  color: #999;
  padding: 0 4px;
  min-width: auto;
  font-weight: normal;
}

.aoprema-pagination .page-numbers .next,
.aoprema-pagination .page-numbers a.next,
.aoprema-product-widget .page-numbers .next,
.aoprema-product-widget .page-numbers a.next {
  padding: 8px 16px;
  min-width: auto;
  font-weight: 600;
}

.aoprema-pagination .page-numbers .prev,
.aoprema-pagination .page-numbers a.prev,
.aoprema-product-widget .page-numbers .prev,
.aoprema-product-widget .page-numbers a.prev {
  padding: 8px 16px;
  min-width: auto;
  font-weight: 600;
}

@media (max-width: 768px) {
  .aoprema-pagination {
    margin-top: 30px;
    padding-top: 20px;
    gap: 6px;
  }

  .aoprema-pagination a,
  .aoprema-pagination span {
    min-width: 36px;
    height: 36px;
    padding: 6px 10px;
    font-size: 13px;
  }

  .aoprema-pagination ul {
    gap: 4px;
  }

  .aoprema-pagination .page-numbers,
  .aoprema-product-widget .page-numbers {
    gap: 4px;
  }

  .aoprema-pagination .page-numbers a,
  .aoprema-pagination .page-numbers span,
  .aoprema-product-widget .page-numbers a,
  .aoprema-product-widget .page-numbers span {
    min-width: 36px;
    height: 36px;
    padding: 6px 10px;
    font-size: 13px;
  }

  .aoprema-pagination .page-numbers .next,
  .aoprema-pagination .page-numbers a.next,
  .aoprema-product-widget .page-numbers .next,
  .aoprema-product-widget .page-numbers a.next,
  .aoprema-pagination .page-numbers .prev,
  .aoprema-pagination .page-numbers a.prev,
  .aoprema-product-widget .page-numbers .prev,
  .aoprema-product-widget .page-numbers a.prev {
    padding: 6px 12px;
    font-size: 13px;
  }
}

/* Load More Button */
.aoprema-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 30px auto 0;
  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;
}

.aoprema-load-more:hover {
  background: #555;
}

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

/* Loading Spinner */
.aoprema-loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: aoprema-spin 0.8s linear infinite;
}

/* Loading State */
.aoprema-products-wrapper.loading {
  position: relative;
  min-height: 200px;
}

.aoprema-products-wrapper.loading .aoprema-products {
  opacity: 0.3;
  pointer-events: none;
}

.aoprema-products-wrapper.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #333;
  border-radius: 50%;
  animation: aoprema-spin 1s linear infinite;
  z-index: 10;
}

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

/* Error Message */
.aoprema-error {
  padding: 15px;
  background: #ffebee;
  color: #c62828;
  border-radius: 4px;
  margin: 20px 0;
}


.aoprema-pagination .page-numbers, .aoprema-product-widget .page-numbers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
}
/* Leanpay catalog badge ("0% obresti, 0 stroškov | leanpay") inside product cards.
   wc-leanpay keeps text + logo side by side and lets the text break anywhere
   (overflow-wrap:anywhere), so in a narrow card (phones, 2-column grid ≈ 80–115 px of
   content) the text collapsed to one letter per line and the badge grew ~240 px tall.
   When the card is narrow, stack text above the logo and wrap only between words. */
.aoprema-product-button-wrapper {
  container-type: inline-size;
}

@container (max-width: 240px) {
  .aoprema-product-button-wrapper .leanpay_catalog_txt {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .aoprema-product-button-wrapper .leanpay_catalog_txt-part--text {
    justify-content: center;
    border-right: 0;
    border-bottom: 1px solid var(--leanpay-catalog-border, color-mix(in srgb, var(--leanpay-catalog-color, #EB5A7A) 10%, transparent));
  }

  .aoprema-product-button-wrapper .leanpay_catalog_txt-label {
    text-align: center;
    overflow-wrap: normal;
    word-break: normal;
    text-wrap: balance;
    line-height: 1.25;
  }
}

/* Phones: slimmer inner padding so the 2-column cards keep usable width
   (card padding itself is the Elementor "Padding" control, mobile value). */
@media (max-width: 480px) {
  .aoprema-products-grid .aoprema-product-content {
    padding: 12px 6px;
  }
}
