/**
 * Search Results Page — Pełna unifikacja z layoutem kategorii
 * 
 * PROBLEM:
 * product-cards-fix.css ustawia position:absolute dla .price i .button
 * oraz padding-bottom:80px na li.product. Na stronach kategorii ten układ
 * działa dzięki specyficznej szerokości kart z WooCommerce. Na stronie
 * wyszukiwania te same style powodują nakładanie się tytułów na ceny i przyciski.
 *
 * ROZWIĄZANIE:
 * Dla body.search — pełny reset pozycjonowania absolute na static + CSS Grid
 * dla kontenera + pionowy flow karty (obraz → tytuł → cena → przycisk)
 * z białym tłem, cieniem i zaokrąglonymi rogami (wzorzec z kategorii).
 *
 * SELEKTOR: body.search (WordPress dodaje tę klasę automatycznie na is_search())
 */

/* ===============================================
   GRID KONTENERA PRODUKTÓW
   4 kolumny desktop, 2 kolumny tablet/mobile
   =============================================== */
body.search ul.products,
body.search.woocommerce ul.products,
body.search .woocommerce ul.products {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 1.5em !important;
  list-style: none !important;
  padding: 0 !important;
  width: 100% !important;
}

/* Reset clearfix pseudo-elements które psują grid */
body.search ul.products::before,
body.search ul.products::after,
body.search.woocommerce ul.products::before,
body.search.woocommerce ul.products::after,
body.search .woocommerce ul.products::before,
body.search .woocommerce ul.products::after {
  display: none !important;
  content: none !important;
}

/* ===============================================
   MARGIN-TOP FIX
   style.css: body.archive ul.products { margin-top: 9em }
   Na search jest za dużo — brak filtrów WOOF nad produktami
   =============================================== */
body.search.archive ul.products,
body.search.post-type-archive-product ul.products {
  margin-top: 2rem !important;
}

/* ===============================================
   NAGŁÓWEK STRONY WYSZUKIWANIA
   =============================================== */
body.search .woocommerce-products-header {
  margin-top: 2rem !important;
  padding-top: 1rem !important;
}

body.search .woocommerce-products-header__title.page-title {
  margin-bottom: 1rem !important;
  font-size: 1.5rem !important;
  color: #012241 !important;
  font-weight: 700 !important;
}

/* ===============================================
   KARTA PRODUKTU — pełna struktura
   Biały kontener, zaokrąglone rogi, cień
   Pionowy flow: obraz → tytuł → cena → przycisk
   =============================================== */
body.search ul.products li.product,
body.search.woocommerce ul.products li.product,
body.search .woocommerce ul.products li.product {
  /* Reset z product-cards-fix.css */
  float: none !important;
  width: 100% !important;
  margin: 0 !important;
  clear: none !important;
  padding-bottom: 0 !important; /* Reset padding-bottom: 80px */

  /* Karta */
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  background: #fff !important;
  border-radius: 12px !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06) !important;
  overflow: hidden !important;
  transition: box-shadow 0.3s ease, transform 0.2s ease !important;
  height: 100% !important;
}

body.search ul.products li.product:hover,
body.search.woocommerce ul.products li.product:hover,
body.search .woocommerce ul.products li.product:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1) !important;
  transform: translateY(-3px) !important;
}

/* ===============================================
   LINK WRAPPERA — flex grow, struktura pionowa
   =============================================== */
body.search ul.products li.product > a,
body.search.woocommerce ul.products li.product > a,
body.search .woocommerce ul.products li.product > a {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-decoration: none !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
}

/* ===============================================
   OBRAZEK PRODUKTU
   =============================================== */
body.search ul.products li.product a img,
body.search.woocommerce ul.products li.product a img,
body.search .woocommerce ul.products li.product a img {
  object-fit: contain !important;
  height: 200px !important;
  max-width: 90% !important;
  margin: 0 auto !important;
  padding: 1em !important;
  transition: transform 0.3s ease !important;
}

body.search ul.products li.product:hover a img,
body.search.woocommerce ul.products li.product:hover a img {
  transform: scale(1.05) !important;
}

/* ===============================================
   TYTUŁ PRODUKTU
   Reset height i position — normalny flow
   =============================================== */
body.search ul.products li.product .woocommerce-loop-product__title,
body.search ul.products li.product h2.woocommerce-loop-product__title,
body.search.woocommerce ul.products li.product .woocommerce-loop-product__title,
body.search.woocommerce ul.products li.product h2.woocommerce-loop-product__title,
body.search .woocommerce ul.products li.product .woocommerce-loop-product__title,
body.search .woocommerce ul.products li.product h2.woocommerce-loop-product__title {
  /* Reset wartości z product-cards-fix.css i style.css */
  position: static !important;

  /* Stałe 2 linie — wyrównanie kart */
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.4em !important;
  height: 2.8em !important;      /* 2 * 1.4em */
  min-height: 2.8em !important;
  max-height: 2.8em !important;
  margin: 0 15px 0.6rem 15px !important;
  padding: 0 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #012241 !important;
  word-break: break-word !important;
  background: transparent !important;
  text-align: center !important;
  flex-shrink: 0 !important;
}

body.search ul.products li.product:hover .woocommerce-loop-product__title,
body.search.woocommerce ul.products li.product:hover .woocommerce-loop-product__title,
body.search .woocommerce ul.products li.product:hover .woocommerce-loop-product__title {
  color: #1C5EA8 !important;
}

/* ===============================================
   CENA — reset position:absolute, normalny flow
   =============================================== */
body.search ul.products li.product .price,
body.search.woocommerce ul.products li.product .price,
body.search .woocommerce ul.products li.product .price {
  /* Reset z product-cards-fix.css */
  position: static !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  top: auto !important;
  transform: none !important;
  max-width: 100% !important;
  width: auto !important;

  /* Styl */
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: baseline !important;
  justify-content: center !important;
  gap: 6px !important;
  margin: 0 15px 0.75rem 15px !important;
  padding: 0 !important;
  text-align: center !important;
  min-height: 1.5em !important; /* Wyrównanie cen między kartami */
  flex-shrink: 0 !important;
}

/* Stara cena (przekreślona) */
body.search ul.products li.product .price del,
body.search.woocommerce ul.products li.product .price del,
body.search .woocommerce ul.products li.product .price del {
  display: inline !important;
  font-size: 0.8rem !important;
  color: #999 !important;
  text-decoration: line-through !important;
  font-weight: 400 !important;
  opacity: 0.7 !important;
  order: 1 !important;
}

/* Nowa cena (promocyjna) */
body.search ul.products li.product .price ins,
body.search.woocommerce ul.products li.product .price ins,
body.search .woocommerce ul.products li.product .price ins {
  display: inline !important;
  text-decoration: none !important;
  background: none !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: #e31837 !important;
  order: 2 !important;
}

/* Zwykła cena */
body.search ul.products li.product .price > .woocommerce-Price-amount,
body.search ul.products li.product .price > span > .woocommerce-Price-amount,
body.search.woocommerce ul.products li.product .price > .woocommerce-Price-amount,
body.search .woocommerce ul.products li.product .price > .woocommerce-Price-amount {
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: #012241 !important;
}

body.search ul.products li.product .price bdi,
body.search.woocommerce ul.products li.product .price bdi,
body.search .woocommerce ul.products li.product .price bdi {
  font-size: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
}

/* ===============================================
   PRODUKTY ZMIENNE — cena „od …"
   =============================================== */
body.search ul.products li.product.product-type-variable .price,
body.search.woocommerce ul.products li.product.product-type-variable .price,
body.search .woocommerce ul.products li.product.product-type-variable .price {
  font-size: 0 !important;
  line-height: 0 !important;
}

body.search ul.products li.product.product-type-variable .price::before,
body.search.woocommerce ul.products li.product.product-type-variable .price::before,
body.search .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;
}

body.search ul.products li.product.product-type-variable .price .woocommerce-Price-amount:first-of-type,
body.search.woocommerce ul.products li.product.product-type-variable .price .woocommerce-Price-amount:first-of-type {
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: #012241 !important;
  display: inline !important;
  line-height: 1.4 !important;
}

body.search ul.products li.product.product-type-variable .price .woocommerce-Price-amount:not(:first-of-type),
body.search.woocommerce ul.products li.product.product-type-variable .price .woocommerce-Price-amount:not(:first-of-type) {
  display: none !important;
}

/* ===============================================
   PRZYCISK „DODAJ DO KOSZYKA"
   Reset position:absolute, normalny flow
   =============================================== */
body.search ul.products li.product a.button,
body.search ul.products li.product button.button,
body.search ul.products li.product .add_to_cart_button,
body.search.woocommerce ul.products li.product a.button,
body.search.woocommerce ul.products li.product button.button,
body.search.woocommerce ul.products li.product .add_to_cart_button,
body.search .woocommerce ul.products li.product a.button,
body.search .woocommerce ul.products li.product button.button,
body.search .woocommerce ul.products li.product .add_to_cart_button {
  /* Reset z product-cards-fix.css */
  position: static !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  top: auto !important;
  float: none !important;
  transform: none !important;

  /* Styl — kolor marki */
  display: inline-block !important;
  margin: 0 15px 15px 15px !important;
  margin-top: auto !important; /* Pushes button to bottom of flex card */
  padding: 0.65em 1.4em !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  color: #fff !important;
  background: #1C5EA8 !important;
  border: none !important;
  border-radius: 20px !important;
  text-decoration: none !important;
  text-align: center !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  line-height: 1.4 !important;
}

body.search ul.products li.product a.button:hover,
body.search ul.products li.product button.button:hover,
body.search ul.products li.product .add_to_cart_button:hover,
body.search.woocommerce ul.products li.product a.button:hover,
body.search.woocommerce ul.products li.product button.button:hover,
body.search.woocommerce ul.products li.product .add_to_cart_button:hover,
body.search .woocommerce ul.products li.product a.button:hover,
body.search .woocommerce ul.products li.product button.button:hover,
body.search .woocommerce ul.products li.product .add_to_cart_button:hover {
  background: #164B87 !important;
  box-shadow: 0 4px 12px rgba(28, 94, 168, 0.3) !important;
  transform: translateY(-2px) !important;
}

/* Przycisk „Wybierz opcje" (produkt zmienny) */
body.search ul.products li.product a.button.product_type_variable,
body.search.woocommerce ul.products li.product a.button.product_type_variable,
body.search .woocommerce ul.products li.product a.button.product_type_variable {
  background: transparent !important;
  color: #1C5EA8 !important;
  border: 2px solid #1C5EA8 !important;
}

body.search ul.products li.product a.button.product_type_variable:hover,
body.search.woocommerce ul.products li.product a.button.product_type_variable:hover,
body.search .woocommerce ul.products li.product a.button.product_type_variable:hover {
  background: #1C5EA8 !important;
  color: #fff !important;
}

/* ===============================================
   „ZOBACZ KOSZYK" — po dodaniu produktu
   =============================================== */
body.search ul.products li.product a.added_to_cart,
body.search.woocommerce ul.products li.product a.added_to_cart,
body.search .woocommerce ul.products li.product a.added_to_cart {
  position: static !important;
  display: none !important;
}

body.search ul.products li.product.show-view-cart-mode a.add_to_cart_button,
body.search.woocommerce ul.products li.product.show-view-cart-mode a.add_to_cart_button,
body.search .woocommerce ul.products li.product.show-view-cart-mode a.add_to_cart_button {
  display: none !important;
}

body.search ul.products li.product.show-view-cart-mode a.added_to_cart,
body.search.woocommerce ul.products li.product.show-view-cart-mode a.added_to_cart,
body.search .woocommerce ul.products li.product.show-view-cart-mode a.added_to_cart {
  display: inline-block !important;
  position: static !important;
  margin: 0 15px 15px 15px !important;
  margin-top: auto !important;
  padding: 0.65em 1.4em !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: 20px !important;
  text-decoration: none !important;
  text-align: center !important;
  white-space: nowrap !important;
  transform: none !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
}

/* ===============================================
   BADGE'Y — Nowość, Promocja %, Bestseller
   Te ZACHOWUJĄ position:absolute (overlay na obrazku)
   =============================================== */
body.search ul.products li.product .onsale,
body.search ul.products li.product .itsnew,
body.search ul.products li.product .sales-badge,
body.search ul.products li.product .new-badge,
body.search.woocommerce ul.products li.product .onsale,
body.search.woocommerce ul.products li.product .itsnew,
body.search.woocommerce ul.products li.product .sales-badge,
body.search.woocommerce ul.products li.product .new-badge {
  position: absolute !important;
  z-index: 10 !important;
}

body.search ul.products li.product .bestseller-wrapper,
body.search.woocommerce ul.products li.product .bestseller-wrapper {
  position: absolute !important;
  z-index: 5 !important;
  /* Prawy dolny róg zdjęcia (obrazek ma height:200px) */
  top: 145px !important;
  right: 8px !important;
  left: auto !important;
  bottom: auto !important;
  flex-flow: column !important;
  transform: scale(0.8) !important;
  transform-origin: bottom right !important;
  pointer-events: none !important;
}

/* ===============================================
   .original-computed-price — ukryj jak na archive
   =============================================== */
body.search ul.products li .original-computed-price,
body.search.woocommerce ul.products li .original-computed-price {
  display: none !important;
}

/* ===============================================
   SORTOWANIE I WYNIKI
   =============================================== */
body.search .woocommerce-result-count {
  display: inline-flex !important;
  align-items: center !important;
  font-size: 14px !important;
  color: #333 !important;
  font-weight: 400 !important;
  margin: 0 !important;
  padding: 0.5em 0 !important;
  font-family: 'Poppins', sans-serif !important;
}

body.search .woocommerce-ordering {
  float: right !important;
}

body.search .woocommerce-ordering select {
  -webkit-appearance: none !important;
  appearance: none !important;
  background-color: #1C5EA8 !important;
  color: #fff !important;
  border: none !important;
  border-radius: 25px !important;
  padding: 0.75em 3em 0.75em 1.5em !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  min-width: 220px !important;
  transition: all 0.2s ease !important;
}

body.search .woocommerce-ordering select:hover {
  background-color: #164B87 !important;
}

/* ===============================================
   PAGINACJA
   =============================================== */
body.search .woocommerce nav.woocommerce-pagination ul li a,
body.search.woocommerce nav.woocommerce-pagination ul li a {
  color: #1C5EA8 !important;
  border-color: #1C5EA8 !important;
}

body.search .woocommerce nav.woocommerce-pagination ul li span.current,
body.search.woocommerce nav.woocommerce-pagination ul li span.current {
  background: #1C5EA8 !important;
  color: #fff !important;
  border-color: #1C5EA8 !important;
}

/* ===============================================
   RESPONSIVE — TABLET (≤ 991px)
   =============================================== */
@media screen and (max-width: 991px) {
  body.search ul.products,
  body.search.woocommerce ul.products,
  body.search .woocommerce ul.products {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1em !important;
  }

  body.search.archive ul.products,
  body.search.post-type-archive-product ul.products {
    margin-top: 1.5rem !important;
  }

  body.search ul.products li.product,
  body.search.woocommerce ul.products li.product {
    width: 100% !important;
  }
}

/* ===============================================
   RESPONSIVE — MOBILE (≤ 576px)
   =============================================== */
@media screen and (max-width: 576px) {
  body.search ul.products,
  body.search.woocommerce ul.products,
  body.search .woocommerce ul.products {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75em !important;
  }

  body.search ul.products li.product a img,
  body.search.woocommerce ul.products li.product a img {
    height: 140px !important;
    padding: 0.75em !important;
  }

  body.search ul.products li.product .woocommerce-loop-product__title,
  body.search.woocommerce ul.products li.product .woocommerce-loop-product__title {
    font-size: 11px !important;
    margin: 0 10px 0.5rem 10px !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    line-height: 1.4em !important;
    height: 2.8em !important;
    min-height: 2.8em !important;
    max-height: 2.8em !important;
  }

  body.search ul.products li.product .price,
  body.search.woocommerce ul.products li.product .price {
    margin: 0 10px 0.5rem 10px !important;
  }

  body.search ul.products li.product .price ins,
  body.search ul.products li.product .price > .woocommerce-Price-amount,
  body.search.woocommerce ul.products li.product .price ins,
  body.search.woocommerce ul.products li.product .price > .woocommerce-Price-amount {
    font-size: 1rem !important;
  }

  body.search ul.products li.product .price del,
  body.search.woocommerce ul.products li.product .price del {
    font-size: 0.7rem !important;
  }

  body.search ul.products li.product a.button,
  body.search ul.products li.product button.button,
  body.search ul.products li.product .add_to_cart_button,
  body.search.woocommerce ul.products li.product a.button,
  body.search.woocommerce ul.products li.product button.button,
  body.search.woocommerce ul.products li.product .add_to_cart_button {
    margin: 0 10px 10px 10px !important;
    margin-top: auto !important;
    padding: 0.5em 1em !important;
    font-size: 0.75rem !important;
  }

  body.search.archive ul.products,
  body.search.post-type-archive-product ul.products {
    margin-top: 1rem !important;
  }

  /* Bestseller badge — prawy dolny róg zdjęcia, mniejszy na mobile */
  body.search ul.products li.product .bestseller-wrapper,
  body.search.woocommerce ul.products li.product .bestseller-wrapper {
    top: 90px !important;
    right: 5px !important;
    transform: scale(0.65) !important;
  }
}
