/**
 * Product Cards Improvements
 * Ulepszenia kart produktów - nazwy, ceny, przyciski
 */

/* ===============================================
   KARTA PRODUKTU - Główna struktura
   =============================================== */
.woocommerce ul.products li.product {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  position: relative !important;
}

/* ===============================================
   TYTUŁ PRODUKTU - max 2 linie z ucięciem
   =============================================== */
.woocommerce ul.products li.product .woocommerce-loop-product__title,
.woocommerce ul.products li.product h2.woocommerce-loop-product__title {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.35em !important;
  height: 2.7em !important; /* 2 linie * 1.35 line-height */
  min-height: 2.7em !important;
  max-height: 2.7em !important;
  margin-bottom: 0.75rem !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #012241 !important;
  word-break: break-word !important;
  padding: 0 !important;
  background: transparent !important;
}

@media screen and (max-width: 767px) {
  .woocommerce ul.products li.product .woocommerce-loop-product__title,
  .woocommerce ul.products li.product h2.woocommerce-loop-product__title {
    font-size: 13px !important;
    -webkit-line-clamp: 2 !important;
    height: 2.7em !important;
    min-height: 2.7em !important;
    max-height: 2.7em !important;
    line-height: 1.35em !important;
  }
}

/* ===============================================
   CENA I PRZYCISK - wyrównane w jednym rzędzie
   =============================================== */

/* Kontener na cenę i przycisk */
.woocommerce ul.products li.product {
  padding-bottom: 80px !important; /* Miejsce na footer z ceną + 2 przyciski */
}

/* Footer karty - cena + przycisk */
.woocommerce ul.products li.product .price,
.woocommerce ul.products li.product a.button:not(.added_to_cart),
.woocommerce ul.products li.product button.button,
.woocommerce ul.products li.product .add_to_cart_button {
  position: absolute !important;
  bottom: 0 !important;
}

/* Cena po lewej */
.woocommerce ul.products li.product .price {
  left: 0 !important;
  right: auto !important;
  bottom: 20px !important;
  text-align: left !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 2px !important;
  width: auto !important;
  max-width: 45% !important;
}

/* Przycisk "Dodaj do koszyka" po prawej */
.woocommerce ul.products li.product a.button:not(.added_to_cart),
.woocommerce ul.products li.product button.button,
.woocommerce ul.products li.product .add_to_cart_button {
  right: 0 !important;
  left: auto !important;
  bottom: 15px !important;
  float: none !important;
  margin: 0 !important;
  white-space: nowrap !important;
  padding: 0.6em 1.2em !important;
  font-size: 0.8rem !important;
}

/* ===============================================
   CENY PROMOCYJNE - Nowoczesny wygląd
   =============================================== */

/* Stara cena (przekreślona) */
.woocommerce ul.products li.product .price del {
  display: block !important;
  font-size: 0.75rem !important;
  color: #888 !important;
  text-decoration: line-through !important;
  text-decoration-color: #888 !important;
  text-decoration-thickness: 1px !important;
  font-weight: 400 !important;
  margin: 0 !important;
  order: 1 !important;
  opacity: 0.7 !important;
}

.woocommerce ul.products li.product .price del bdi,
.woocommerce ul.products li.product .price del .woocommerce-Price-amount {
  font-size: 0.75rem !important;
  color: #888 !important;
}

/* Nowa cena (promocyjna) */
.woocommerce ul.products li.product .price ins {
  display: block !important;
  text-decoration: none !important;
  background: none !important;
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: #e31837 !important; /* Czerwony dla promocji */
  order: 2 !important;
}

.woocommerce ul.products li.product .price ins bdi,
.woocommerce ul.products li.product .price ins .woocommerce-Price-amount {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: #e31837 !important;
}

/* Zwykła cena (bez promocji) */
.woocommerce ul.products li.product .price > .woocommerce-Price-amount,
.woocommerce ul.products li.product .price > span > .woocommerce-Price-amount {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: #012241 !important;
}

.woocommerce ul.products li.product .price bdi {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
}

/* ===============================================
   PRODUKTY ZMIENNE - Zakres cen (od - do)
   =============================================== */

/* Kontener ceny dla produktów zmiennych - ukryj separator tekstowy */
.woocommerce ul.products li.product.product-type-variable .price {
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: baseline !important;
  gap: 0.3rem !important;
  max-width: 55% !important;
  overflow: hidden !important;
  font-size: 0 !important; /* Ukryj separator "-" */
  line-height: 0 !important;
}

/* Tekst "od" przed ceną */
.woocommerce ul.products li.product.product-type-variable .price::before {
  content: "od" !important;
  font-size: 0.85rem !important;
  font-weight: 400 !important;
  color: #666 !important;
  display: inline !important;
  line-height: 1.4 !important;
  margin-right: 0.3rem !important;
}

/* Główna cena (pierwsza/niższa) - widoczna */
.woocommerce ul.products li.product.product-type-variable .price .woocommerce-Price-amount:first-of-type {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: #012241 !important;
  white-space: nowrap !important;
  display: inline !important;
  line-height: 1.4 !important;
}

.woocommerce ul.products li.product.product-type-variable .price .woocommerce-Price-amount:first-of-type bdi {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: #012241 !important;
}

/* Ukryj wszystkie pozostałe ceny (druga cena z zakresu) i separatory */
.woocommerce ul.products li.product.product-type-variable .price .woocommerce-Price-amount:not(:first-of-type),
.woocommerce ul.products li.product.product-type-variable .price .woocommerce-Price-amount:not(:first-of-type) bdi,
.woocommerce ul.products li.product.product-type-variable .price > span:not(:first-of-type) {
  display: none !important;
}

/* ===============================================
   ETYKIETY (Nowość, Promocja %)
   =============================================== */

/* Badge promocji (-21%) */
.woocommerce ul.products li.product .onsale,
.woocommerce span.onsale {
  background: linear-gradient(135deg, #e31837 0%, #c41230 100%) !important;
  color: #fff !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  padding: 0.4em 0.8em !important;
  border-radius: 4px !important;
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  left: auto !important;
  z-index: 10 !important;
  min-width: auto !important;
  min-height: auto !important;
  line-height: 1.2 !important;
  box-shadow: 0 2px 8px rgba(227, 24, 55, 0.3) !important;
}

/* Badge "Nowość" */
.woocommerce ul.products li.product .new-badge,
.new-product-badge {
  background: linear-gradient(135deg, #1C5EA8 0%, #164B87 100%) !important;
  color: #fff !important;
  font-size: 0.7rem !important;
  font-weight: 600 !important;
  padding: 0.3em 0.6em !important;
  border-radius: 4px !important;
  position: absolute !important;
  top: 10px !important;
  left: 10px !important;
  z-index: 10 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
}

/* ===============================================
   MOBILE RESPONSIVE
   =============================================== */
@media screen and (max-width: 767px) {
  .woocommerce ul.products li.product {
    padding-bottom: 90px !important; /* Więcej miejsca na cenę + 2 przyciski */
  }
  
  /* Na mobile - cena wycentrowana nad przyciskami */
  .woocommerce ul.products li.product .price {
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: 55px !important; /* Więcej miejsca na przyciski */
    text-align: center !important;
    align-items: center !important;
    max-width: 100% !important;
    width: 100% !important;
    flex-direction: row !important;
    justify-content: center !important;
    gap: 8px !important;
  }
  
  .woocommerce ul.products li.product .price del {
    font-size: 0.7rem !important;
  }
  
  .woocommerce ul.products li.product .price ins,
  .woocommerce ul.products li.product .price ins bdi {
    font-size: 1rem !important;
  }
  
  .woocommerce ul.products li.product .price bdi {
    font-size: 1rem !important;
  }
  
  /* Produkty zmienne na mobile */
  .woocommerce ul.products li.product.product-type-variable .price {
    max-width: 100% !important;
    justify-content: center !important;
  }
  
  /* Przycisk "Dodaj do koszyka" na mobile - wycentrowany na dole */
  .woocommerce ul.products li.product a.button:not(.added_to_cart),
  .woocommerce ul.products li.product button.button,
  .woocommerce ul.products li.product .add_to_cart_button {
    left: 50% !important;
    transform: translateX(-50%) !important;
    right: auto !important;
    bottom: 8px !important;
    font-size: 0.75rem !important;
    padding: 0.5em 1em !important;
  }
}

/* ===============================================
   TABLET - układ jak desktop ale mniejszy
   =============================================== */
@media screen and (min-width: 768px) and (max-width: 991px) {
  .woocommerce ul.products li.product .price {
    font-size: 0.9rem !important;
  }
  
  .woocommerce ul.products li.product a.button,
  .woocommerce ul.products li.product button.button {
    font-size: 0.75rem !important;
    padding: 0.5em 0.8em !important;
  }
}

/* ===============================================
   BESTSELLER BADGE
   =============================================== */
.woocommerce ul.products li.product .bestseller-badge,
.bestseller-badge {
  position: absolute !important;
  bottom: auto !important;
  top: auto !important;
  right: 10px !important;
  background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%) !important;
  color: #000 !important;
  font-size: 0.65rem !important;
  font-weight: 700 !important;
  padding: 0.3em 0.5em !important;
  border-radius: 4px !important;
  text-transform: uppercase !important;
  z-index: 10 !important;
}

/* ===============================================
   HOVER EFFECTS
   =============================================== */
.woocommerce ul.products li.product:hover .woocommerce-loop-product__title {
  color: #1C5EA8 !important;
}

.woocommerce ul.products li.product a.button:hover,
.woocommerce ul.products li.product button.button:hover,
.woocommerce ul.products li.product .add_to_cart_button:hover {
  background: #164B87 !important;
  transform: translateY(-2px) translateX(0) !important;
  box-shadow: 0 4px 12px rgba(32, 91, 171, 0.3) !important;
}

@media screen and (max-width: 767px) {
  .woocommerce ul.products li.product a.button:hover,
  .woocommerce ul.products li.product button.button:hover,
  .woocommerce ul.products li.product .add_to_cart_button:hover {
    transform: translateX(-50%) translateY(-2px) !important;
  }
}

/* ===============================================
   USUNIĘCIE KONFLIKTÓW
   =============================================== */
.woocommerce ul.products li.product .price del span.woocommerce-Price-currencySymbol,
.woocommerce ul.products li.product .price ins span.woocommerce-Price-currencySymbol {
  font-size: inherit !important;
}

/* Ukryj stary styl cen */
.woocommerce ul.products li.product .price del::before,
.woocommerce ul.products li.product .price del::after {
  display: none !important;
}

/* Nadpisanie konfliktujących stylów z style.css */
.woocommerce-loop-product__title {
  height: 2.7em !important;
  min-height: 2.7em !important;
  max-height: 2.7em !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}

@media screen and (max-width: 440px) {
  .woocommerce-loop-product__title {
    height: 2.7em !important;
    min-height: 2.7em !important;
    max-height: 2.7em !important;
  }
}

/* ===============================================
   PRZYCISK "ZOBACZ KOSZYK" PO DODANIU DO KOSZYKA
   Zastępuje przycisk "Dodaj do koszyka" na 10 sekund
   =============================================== */

/* Gdy aktywny tryb "Zobacz koszyk" - ukryj przycisk "Dodaj do koszyka" */
.woocommerce ul.products li.product.show-view-cart-mode a.add_to_cart_button,
.woocommerce ul.products li.product.show-view-cart-mode button.add_to_cart_button,
.woocommerce ul.products li.product.show-view-cart-mode a.button.add_to_cart_button,
.woocommerce ul.products li.product.show-view-cart-mode a.button.product_type_simple,
.woocommerce ul.products li.product.show-view-cart-mode .add_to_cart_button.ajax_add_to_cart {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  display: none !important;
}

/* Domyślnie ukryj 'Zobacz koszyk' - pokaż tylko gdy tryb aktywny */
.woocommerce ul.products li.product a.added_to_cart {
  display: none !important;
}

/* Przycisk "Zobacz koszyk" - w miejscu przycisku "Dodaj do koszyka" */
.woocommerce ul.products li.product.show-view-cart-mode a.added_to_cart,
.woocommerce ul.products li.product.show-view-cart-mode .added_to_cart {
  position: absolute !important;
  right: 0 !important;
  left: auto !important;
  bottom: 15px !important; /* Ta sama pozycja co "Dodaj do koszyka" */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 0.6em 1.2em !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  color: #fff !important;
  background: linear-gradient(135deg, #28a745 0%, #20903b 100%) !important;
  border: none !important;
  border-radius: 4px !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  transition: all 0.3s ease !important;
  z-index: 10 !important;
  margin: 0 !important;
  float: none !important;
  transform: none !important;
  box-shadow: 0 3px 10px rgba(40, 167, 69, 0.35) !important;
  animation: viewCartPulse 0.5s ease-out !important;
}

/* Animacja pojawienia się */
@keyframes viewCartPulse {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.woocommerce ul.products li.product.show-view-cart-mode a.added_to_cart:hover,
.woocommerce ul.products li.product.show-view-cart-mode .added_to_cart:hover {
  background: linear-gradient(135deg, #20903b 0%, #1a7a32 100%) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 5px 15px rgba(40, 167, 69, 0.45) !important;
}

/* Ukrycie ikony przed tekstem */
.woocommerce ul.products li.product.show-view-cart-mode a.added_to_cart::before,
.woocommerce ul.products li.product.show-view-cart-mode .added_to_cart::before {
  display: none !important;
  content: none !important;
}

/* MOBILE - przycisk "Zobacz koszyk" */
@media screen and (max-width: 767px) {
  .woocommerce ul.products li.product.show-view-cart-mode a.added_to_cart,
  .woocommerce ul.products li.product.show-view-cart-mode .added_to_cart {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    bottom: 8px !important; /* Ta sama pozycja co "Dodaj do koszyka" */
    font-size: 0.75rem !important;
    padding: 0.5em 1em !important;
    width: calc(100% - 20px) !important;
    max-width: none !important;
  }
  
  .woocommerce ul.products li.product.show-view-cart-mode a.added_to_cart:hover,
  .woocommerce ul.products li.product.show-view-cart-mode .added_to_cart:hover {
    transform: translateX(-50%) translateY(-2px) !important;
  }
}

/* TABLET */
@media screen and (min-width: 768px) and (max-width: 991px) {
  .woocommerce ul.products li.product.show-view-cart-mode a.added_to_cart,
  .woocommerce ul.products li.product.show-view-cart-mode .added_to_cart {
    font-size: 0.75rem !important;
    padding: 0.5em 1em !important;
    bottom: 15px !important;
  }
}

/* ===============================================
   PRZYCISK "DODAJ DO KOSZYKA" - stan loading
   =============================================== */
.woocommerce ul.products li.product a.button.loading,
.woocommerce ul.products li.product .add_to_cart_button.loading {
  opacity: 0.7 !important;
  pointer-events: none !important;
}

/* Stan po dodaniu - przycisk zmienia wygląd */
.woocommerce ul.products li.product a.button.added,
.woocommerce ul.products li.product .add_to_cart_button.added {
  background: #28a745 !important;
  border-color: #28a745 !important;
}

.woocommerce ul.products li.product a.button.added::after,
.woocommerce ul.products li.product .add_to_cart_button.added::after {
  content: " ✓" !important;
}

/* ===============================================
   WYRÓWNANIE FOOTERA KARTY - zapobiega rozjazdowi
   =============================================== */

/* Kontener na przyciski - flexbox dla wyrównania */
.woocommerce ul.products li.product {
  display: flex !important;
  flex-direction: column !important;
}

/* Zapewnij że elementy footera nie wpływają na siebie */
.woocommerce ul.products li.product .price,
.woocommerce ul.products li.product a.button,
.woocommerce ul.products li.product .add_to_cart_button,
.woocommerce ul.products li.product .added_to_cart {
  flex-shrink: 0 !important;
}
