/* NS Store - Buy Buttons Only Patch
   Scope: product/list buy buttons + product detail buy box/dark mode.
   Does NOT target header, top menu, account menu, or cart header. */

/* 1) Product detail: the button exists in HTML but form#buy_block has .hidden and the button wrapper has .unvisible. */
body#product form#buy_block,
body.product form#buy_block,
body#product form#buy_block.hidden,
body.product form#buy_block.hidden {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  overflow: visible !important;
}

body#product form#buy_block .unvisible,
body.product form#buy_block .unvisible,
body#product #add_to_cart,
body.product #add_to_cart,
body#product #add_to_cart.buttons_bottom_block,
body.product #add_to_cart.buttons_bottom_block {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: static !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  clip: auto !important;
}

body#product #add_to_cart button,
body.product #add_to_cart button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px !important;
  border-radius: 8px !important;
  border: 1px solid #5c9f32 !important;
  background: #6BAA3A !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  text-transform: none !important;
  box-shadow: none !important;
}

body#product #add_to_cart button:hover,
body.product #add_to_cart button:hover {
  background: #5a9430 !important;
  border-color: #5a9430 !important;
  color: #ffffff !important;
}

/* 2) Product list / related products: keep default Leo/PrestaShop classes, only make the cart area visible and usable. */
.product-container .functional-buttons,
.product-block .functional-buttons {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  overflow: visible !important;
}

.product-container .functional-buttons .cart,
.product-block .functional-buttons .cart {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  min-height: 1px;
}

.product-container .functional-buttons .cart .ajax_add_to_cart_button,
.product-block .functional-buttons .cart .ajax_add_to_cart_button,
.product-container .functional-buttons .cart .ns-buy-visible,
.product-block .functional-buttons .cart .ns-buy-visible {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px !important;
  border-radius: 7px !important;
  border: 1px solid #5c9f32 !important;
  background: #6BAA3A !important;
  color: #fff !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  text-transform: none !important;
}

.product-container .functional-buttons .cart .ajax_add_to_cart_button span,
.product-block .functional-buttons .cart .ajax_add_to_cart_button span,
.product-container .functional-buttons .cart .ns-buy-visible span,
.product-block .functional-buttons .cart .ns-buy-visible span {
  color: #fff !important;
}

.product-container .functional-buttons .view .button,
.product-block .functional-buttons .view .button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px !important;
  border-radius: 7px !important;
  text-transform: none !important;
}

/* Prevent old hover overlays from covering product name/buttons in related products. */
.product-container .right-block,
.product-block .right-block,
.product-container .product-meta,
.product-block .product-meta {
  position: relative;
  z-index: 2;
  overflow: visible !important;
}

/* 3) Product detail dark mode - only product content, not header. */
body.dark-mode#product #columns,
body.dark-mode.product #columns,
body.darkmode--activated#product #columns,
body.darkmode--activated.product #columns {
  background: #0f1720 !important;
  color: #c9d1d9 !important;
}

body.dark-mode#product .primary_block,
body.dark-mode.product .primary_block,
body.darkmode--activated#product .primary_block,
body.darkmode--activated.product .primary_block {
  background: transparent !important;
}

body.dark-mode#product .pb-left-column,
body.dark-mode#product .pb-center-column,
body.dark-mode#product .pb-right-column,
body.dark-mode#product .container-left,
body.dark-mode#product #image-block,
body.dark-mode#product #views_block,
body.dark-mode#product .box-info-product,
body.dark-mode.product .pb-left-column,
body.dark-mode.product .pb-center-column,
body.dark-mode.product .pb-right-column,
body.dark-mode.product .container-left,
body.dark-mode.product #image-block,
body.dark-mode.product #views_block,
body.dark-mode.product .box-info-product {
  background: #111a24 !important;
  border-color: #263241 !important;
  color: #c9d1d9 !important;
}

body.dark-mode#product .pb-center-column h1,
body.dark-mode.product .pb-center-column h1,
body.darkmode--activated#product .pb-center-column h1,
body.darkmode--activated.product .pb-center-column h1 {
  color: #f0f6ff !important;
}

body.dark-mode#product #product_reference,
body.dark-mode#product #product_condition,
body.dark-mode#product #short_description_content,
body.dark-mode#product .rte,
body.dark-mode.product #product_reference,
body.dark-mode.product #product_condition,
body.dark-mode.product #short_description_content,
body.dark-mode.product .rte {
  color: #c9d1d9 !important;
  background: transparent !important;
}

body.dark-mode#product #product_reference label,
body.dark-mode#product #product_condition label,
body.dark-mode.product #product_reference label,
body.dark-mode.product #product_condition label {
  color: #f0f6ff !important;
}

/* 4) Related products dark mode. */
body.dark-mode#product .page-product-box,
body.dark-mode.product .page-product-box,
body.dark-mode#product .products_block,
body.dark-mode.product .products_block,
body.darkmode--activated#product .page-product-box,
body.darkmode--activated.product .page-product-box {
  background: #111a24 !important;
  border-color: #263241 !important;
  color: #c9d1d9 !important;
}

body.dark-mode#product .page-subheading,
body.dark-mode.product .page-subheading,
body.dark-mode#product .productscategory_h3,
body.dark-mode.product .productscategory_h3,
body.darkmode--activated#product .page-subheading,
body.darkmode--activated.product .page-subheading {
  background: #111a24 !important;
  color: #f0f6ff !important;
  border-color: #263241 !important;
}

body.dark-mode#product .product-container,
body.dark-mode.product .product-container,
body.dark-mode#product .product-block,
body.dark-mode.product .product-block,
body.darkmode--activated#product .product-container,
body.darkmode--activated.product .product-container {
  background: #0f1720 !important;
  border-color: #263241 !important;
}

body.dark-mode#product .product-name,
body.dark-mode.product .product-name,
body.dark-mode#product .product-desc,
body.dark-mode.product .product-desc,
body.darkmode--activated#product .product-name,
body.darkmode--activated.product .product-name,
body.darkmode--activated#product .product-desc,
body.darkmode--activated.product .product-desc {
  color: #f0f6ff !important;
  background: transparent !important;
}

body.dark-mode#product .product-desc,
body.dark-mode.product .product-desc,
body.darkmode--activated#product .product-desc,
body.darkmode--activated.product .product-desc {
  color: #9aa7b6 !important;
}

/* 5) Mobile: keep buttons visible and stacked. */
@media (max-width: 767px) {
  body#product #add_to_cart button,
  body.product #add_to_cart button {
    width: 100% !important;
    min-height: 46px;
  }

  .product-container .functional-buttons,
  .product-block .functional-buttons {
    display: flex !important;
    gap: 8px;
    align-items: stretch;
    justify-content: space-between;
    padding: 8px 10px !important;
  }

  .product-container .functional-buttons .cart,
  .product-container .functional-buttons .view,
  .product-block .functional-buttons .cart,
  .product-block .functional-buttons .view {
    flex: 1 1 50%;
  }

  .product-container .functional-buttons .cart .ajax_add_to_cart_button,
  .product-container .functional-buttons .view .button,
  .product-block .functional-buttons .cart .ajax_add_to_cart_button,
  .product-block .functional-buttons .view .button {
    width: 100% !important;
  }
}
