/**
 * Kasro shop product card — replaces WoodMart loop item layout when plugin is active.
 */

.kasro-custom-product-cards .kasro-product-card-item,
.kasro-custom-product-cards .products .kasro-product-card-item {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.kasro-custom-product-cards .kasro-product-card-item > .kasro-product-card {
  flex: 1 1 auto;
  width: 100%;
}

/* Equal height in shop grids and WoodMart / Swiper carousels */
.kasro-custom-product-cards .products,
.kasro-custom-product-cards ul.products {
  align-items: stretch;
}

.kasro-custom-product-cards .swiper-wrapper {
  align-items: stretch !important;
}

.kasro-custom-product-cards .swiper-slide,
.kasro-custom-product-cards .wd-carousel-item {
  display: flex !important;
  flex-direction: column;
  height: auto !important;
  box-sizing: border-box;
}

.kasro-custom-product-cards .swiper-slide > .kasro-product-card-item,
.kasro-custom-product-cards .swiper-slide > .product,
.kasro-custom-product-cards .wd-carousel-item > .kasro-product-card-item,
.kasro-custom-product-cards .wd-carousel-item > .product,
.kasro-custom-product-cards .wd-products-element .product {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
}

/* WoodMart carousels / homepage sections */
.kasro-custom-product-cards .wd-carousel-item .kasro-product-card-item,
.kasro-custom-product-cards .wd-products-element .kasro-product-card-item {
  width: 100%;
  max-width: 100%;
}

.kasro-custom-product-cards .kasro-product-card-item .product-wrapper {
  display: none !important;
}

/* Never hide WoodMart category/term loop cards */
.kasro-custom-product-cards .product-category .product-wrapper,
.kasro-custom-product-cards .product_cat .product-wrapper,
.kasro-custom-product-cards .wd-cat .product-wrapper,
.kasro-custom-product-cards .category-grid-item .product-wrapper,
.kasro-custom-product-cards li.product-category .product-wrapper,
.kasro-custom-product-cards li.product_cat .product-wrapper {
  display: block !important;
}

.kasro-product-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  container-type: inline-size;
  container-name: kasro-card;
  --kasro-card-image-max: 300px;
  --kasro-card-media-pt: 16px;
  --kasro-card-media-pb: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kasro-product-card:hover {
  border-color: #BD0A10;
}

.kasro-product-card__media {
  position: relative;
  padding: var(--kasro-card-media-pt) 16px var(--kasro-card-media-pb);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.kasro-product-card__image-box {
  width: min(100%, var(--kasro-card-image-max));
  max-width: var(--kasro-card-image-max);
  height: auto;
  aspect-ratio: 1;
  max-height: var(--kasro-card-image-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  box-sizing: border-box;
}

.kasro-product-card__image-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-decoration: none;
  background: transparent !important;
}

.kasro-product-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid #8b1a1a;
  background: #fff;
  color: #8b1a1a;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-transform: none;
}

.kasro-product-card__badge-icon {
  flex-shrink: 0;
  display: block;
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.kasro-product-card__image-link img,
.kasro-product-card__image,
.kasro-product-card__image-box img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  object-position: center;
}

/* WoodMart / theme often forces cover or fixed height on loop images */
.kasro-custom-product-cards .kasro-product-card__image-box,
.kasro-custom-product-cards .kasro-product-card__media,
.kasro-custom-product-cards .kasro-product-card__image-link {
  background: transparent !important;
  background-color: transparent !important;
}

.kasro-custom-product-cards .kasro-product-card__image-box img {
  min-width: 0;
  min-height: 0;
  border-radius: 0;
}

.kasro-product-card__divider {
  height: 1px;
  margin: 0 16px;
  background: #e5e7eb;
}

.kasro-product-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 16px 18px;
  gap: 14px;
}

.kasro-product-card__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: #111827;
  flex: 1 1 auto;
  min-height: calc(15px * 1.35 * 2);
}

.kasro-product-card__title a {
  color: inherit;
  text-decoration: none;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.kasro-product-card__title a:hover {
  color: #8b1a1a;
}

.kasro-product-card__footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.kasro-product-card__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  line-height: 1.2;
}

.kasro-product-card__price-from {
  font-size: 13px;
  font-weight: 400;
  color: #9ca3af;
}

.kasro-product-card__price-amount {
  font-size: 18px;
  font-weight: 700;
  color: #8b1a1a;
}

.kasro-product-card__price-amount .woocommerce-Price-amount,
.kasro-product-card__price-amount bdi {
  color: inherit;
  font-weight: inherit;
}

.kasro-product-card__price-amount del {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: #9ca3af;
}

.kasro-product-card__price-amount ins {
  text-decoration: none;
}

.kasro-product-card__actions {
  flex-shrink: 0;
}

.kasro-product-card__add-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: #8b1a1a !important;
  color: #fff !important;
  text-decoration: none !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: background 0.2s ease;
}

.kasro-product-card__add-btn:hover,
.kasro-product-card__add-btn:focus {
  background: #7f1d1d !important;
  color: #fff !important;
}

.kasro-product-card__add-btn.loading {
  opacity: 0.75;
  pointer-events: none;
}

.kasro-product-card__add-icon {
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}

.kasro-product-card__add-btn .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Narrow cards / more columns per row — shrink image area ~20–30% */
@container kasro-card (max-width: 340px) {
  .kasro-product-card {
    --kasro-card-image-max: 240px;
    --kasro-card-media-pt: 12px;
    --kasro-card-media-pb: 8px;
  }
}

@container kasro-card (max-width: 280px) {
  .kasro-product-card {
    --kasro-card-image-max: 210px;
    --kasro-card-media-pt: 10px;
    --kasro-card-media-pb: 6px;
  }
}

/* WooCommerce / WoodMart explicit column counts */
.kasro-custom-product-cards .columns-4 .kasro-product-card,
.kasro-custom-product-cards ul.products.columns-4 .kasro-product-card,
.kasro-custom-product-cards .grid-columns-4 .kasro-product-card {
  --kasro-card-image-max: 240px;
}

.kasro-custom-product-cards .columns-5 .kasro-product-card,
.kasro-custom-product-cards ul.products.columns-5 .kasro-product-card,
.kasro-custom-product-cards .grid-columns-5 .kasro-product-card {
  --kasro-card-image-max: 225px;
}

.kasro-custom-product-cards .columns-6 .kasro-product-card,
.kasro-custom-product-cards ul.products.columns-6 .kasro-product-card,
.kasro-custom-product-cards .grid-columns-6 .kasro-product-card,
.kasro-custom-product-cards [style*='--wd-col-lg:6'] .kasro-product-card,
.kasro-custom-product-cards [style*='--wd-col-lg: 6'] .kasro-product-card {
  --kasro-card-image-max: 210px;
  --kasro-card-media-pt: 10px;
  --kasro-card-media-pb: 6px;
}

/* Tone down WoodMart hover overlays when our card is active */
.kasro-custom-product-cards .kasro-product-card-item .wd-buttons,
.kasro-custom-product-cards .kasro-product-card-item .wd-add-btn,
.kasro-custom-product-cards .kasro-product-card-item .product-element-top .wd-buttons {
  display: none !important;
}
