/**
 * Product Item Block Styles
 */

/* Main Product Item container */
.product-item {
  list-style: none;
  flex: 0 0 calc(26% - 7.5px);
  padding: 0;

  .stock-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
  }

  .stock-green .stock-dot {
    background-color: var(--color-success);
  }

  .stock-yellow .stock-dot {
    background-color: var(--color-warning);
  }

  .stock-red .stock-dot {
    background-color: var(--color-error);
  }
}

.product-item-card {
  background-color: var(--white);
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid #dddddd;

  span.onsale {
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
  }
  & > a {
    display: flex;
    justify-content: center;
    min-height: 300px;
    position: relative;
    aspect-ratio: 1/1;
    flex-shrink: 0;
  }

  .product-item-info {
    display: flex;
    flex-direction: column;
    position: relative;
    height: 180px;
    margin-top: 0;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + 35px);
    justify-content: flex-start;
    gap: 0;

    h2 {
      margin: 0;
    }
  }

  .product-item-info-bottom {
    display: flex;
    align-items: end;

    @media (width <= 768px) {
      flex-direction: column;
      gap: 0;
    }
  }

  .product-item-title-container {
    margin: 0 0 var(--space-2) 0;

    h2 {
      font-family: var(--font-heading);
      font-weight: 600 !important;
      font-size: 18px;
      line-height: 1.3;
    }
  }

  .product-item-subtitle {
    font-size: var(--text-xs);
    color: var(--secondary-color);
    margin: 0 0 var(--space-1) 0;
    font-weight: 400;
    line-height: 1.4;
    min-height: calc(var(--text-xs) * 1.4);
  }

  .product-item-price-container {
    position: absolute;
    bottom: var(--space-4);
    left: var(--space-4);
    right: var(--space-4);
    display: flex;
    margin: 0;
    padding: 0;
  }

  .product-item-rating {
    display: flex;
    margin-bottom: var(--space-2);
  }

  .button {
    display: flex;
  }

  .stock-status {
    margin-bottom: 0;
  }

  img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition:
      opacity 0.3s ease,
      transform 0.3s ease;
    opacity: 1;
  }
  .button {
    width: 100%;
    margin-top: auto;
    display: none;
  }
  &:has(.product-item-image-hover) {
    img.product-item-image-hover {
      opacity: 0;
    }
    &:hover .product-item-image-hover {
      opacity: 1;
    }
    &:hover img:not(.product-item-image-hover) {
      opacity: 0;
    }
  }
}

/* Star Rating Styles */
.product-item-rating {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.product-item-stars {
  display: flex;
  gap: 3px;
  align-items: center;
}

.product-item-star {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.product-item-star.filled {
  fill: #ffd700;
  stroke: #ffd700;
}

.product-item-star.empty {
  fill: none;
  stroke: #d3d3d3;
}

.product-item-rating-text {
  font-size: var(--text-sm);
  color: var(--primary-color);
  font-weight: 500;
  line-height: 1;
}
.product-item-title-container {
  margin: 0;

  h2 {
    font-family: var(--font-heading);
    font-weight: 600 !important;
    font-size: 20px;
    line-height: 1.3;
  }
}
.product-item-title-container > * {
  font-size: 20px;
}

.product-item-price-container {
  margin-top: auto;
}
.product-item-price {
  font-size: var(--text-2xl);
  color: var(--accent-color);
  font-weight: 700;
  font-family: vaR(--font-heading);
}
/* Product Item Prop styles */
.product-item-primary {
}

.product-item-secondary {
}

.product-item-small {
}

.product-item-medium {
}

.product-item-large {
}

.product-item.horizontal {
  padding: 0;
  .product-item-card {
    flex-direction: row;
    width: 100%;
    & > a {
      min-height: 160px;
    }
  }
  .product-item-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    padding-left: var(--space-4);
  }
}

/* Responsive styles */
@media (width > 1024px) {
  .product-item {
    flex: 0 0 calc(26% - 7.5px);
  }
}

@media (width <= 1024px) {
  .product-item {
    flex: 0 0 calc(27% - 7px);
  }
}
@media (width <= 768px) {
  .product-item {
    flex: 0 0 calc(40% - 7px);
  }

  .product-item-card .product-item-info {
    height: auto;
    min-height: 160px;
    padding: var(--space-3);
    padding-bottom: calc(var(--space-3) + 35px);
  }

  .product-item-card .product-item-title-container h2 {
    font-size: 16px;
    line-height: 1.3;
  }

  .product-item-card .product-item-subtitle {
    font-size: 11px;
  }

  .product-item-card .product-item-price {
    font-size: var(--text-lg);
  }
}

@media (width <= 480px) {
  .product-item {
    flex: 0 0 calc(50% - 7px);
  }

  .product-item-card .product-item-info {
    height: auto;
    min-height: 150px;
    padding: var(--space-2);
    padding-bottom: calc(var(--space-2) + 32px);
  }

  .product-item-card .product-item-title-container h2 {
    font-size: 16px;
    line-height: 1.25;
  }

  .product-item-card .product-item-subtitle {
    font-size: 10px;
  }

  .product-item-card .product-item-price {
    font-size: var(--text-base);
  }

  .product-item-card .product-item-rating {
    gap: 2px;
  }

  .product-item-card .product-item-star {
    width: 12px;
    height: 12px;
  }

  .product-item-card .product-item-rating-text {
    font-size: 11px;
  }
}
