/* ==========================================================================
   Happy Layers - przycisk "koszyk +" na kartach oraz szuflada koszyka
   Motyw ciemny = domyślny, jasny = html[data-theme="light"]
   ========================================================================== */

.hlp-atc,
.hlp-sc {
  --hlp-sc-bg: #151e2b;
  --hlp-sc-surface: #1e293b;
  --hlp-sc-surface-2: #263449;
  --hlp-sc-border: #334155;
  --hlp-sc-text: #f1f5f9;
  --hlp-sc-muted: #a3b1c6;
  --hlp-sc-accent: #58bd8e;
  --hlp-sc-accent-hover: #6ee7b7;
  --hlp-sc-accent-ink: #08261a;
  --hlp-sc-danger: #fca5a5;
  --hlp-sc-track: #334155;
  --hlp-sc-shadow: 0 0 48px rgba(0, 0, 0, 0.55);
  --hlp-sc-backdrop: rgba(2, 6, 14, 0.62);
}
html[data-theme="light"] .hlp-atc,
html[data-theme="light"] .hlp-sc {
  --hlp-sc-bg: #ffffff;
  --hlp-sc-surface: #f1f5f9;
  --hlp-sc-surface-2: #e2e8f0;
  --hlp-sc-border: #cbd5e1;
  --hlp-sc-text: #0f172a;
  --hlp-sc-muted: #475569;
  --hlp-sc-accent: #1e5e4d;
  --hlp-sc-accent-hover: #164a3d;
  --hlp-sc-accent-ink: #ffffff;
  --hlp-sc-danger: #b91c1c;
  --hlp-sc-track: #dbe3ec;
  --hlp-sc-shadow: 0 0 48px rgba(15, 23, 42, 0.22);
  --hlp-sc-backdrop: rgba(15, 23, 42, 0.45);
}

/* ---------- 1. Przycisk na karcie produktu ---------- */
ul.products li.product,
.woocommerce ul.products li.product {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  overflow: visible !important;
}

/* Wyrównanie wysokości tytułów w siatce */
ul.products li.product .woocommerce-loop-product__title,
ul.products li.product h2.woocommerce-loop-product__title,
ul.products li.product .kadence-loop-product-title,
ul.products li.product .woocommerce-loop-product__title a,
ul.products li.product h2.woocommerce-loop-product__title a,
ul.products li.product .woocommerce-LoopProduct-link-title {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  word-break: break-word;
}

ul.products li.product .woocommerce-loop-product__title,
ul.products li.product h2.woocommerce-loop-product__title {
  height: 2.8em !important;
  max-height: 2.8em !important;
  min-height: 2.8em !important;
  line-height: 1.4 !important;
  margin-bottom: 8px !important;
}

/* Miejsce na przycisk w rogu karty */
ul.products li.product .product-details,
.woocommerce ul.products li.product .product-details {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  position: relative !important;
  padding-bottom: 58px !important;
}

ul.products li.product .product-action-wrap {
  position: absolute !important;
  right: 12px !important;
  bottom: 12px !important;
  left: auto !important;
  top: auto !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
  background: none !important;
  z-index: 5 !important;
}

/* Gwarancja widoczności przycisku - Kadence lub WooCommerce nie mogą go ukryć */
.woocommerce ul.products li.product a.hlp-atc,
.woocommerce ul.products li.product a.hlp-atc.added,
.woocommerce ul.products.woo-archive-btn-button li.product .button.hlp-atc,
.woocommerce ul.products.woo-archive-btn-button li.product .button.hlp-atc.added,
.woocommerce ul.products li.product .product-action-wrap a.button.added,
.woocommerce ul.products li.product .product-action-wrap a.button.hlp-atc,
ul.products li.product a.hlp-atc,
ul.products li.product a.hlp-atc.added,
ul.products li.product a.hlp-atc[style*="display: none"],
ul.products li.product a.hlp-atc[style*="display:none"] {
  position: relative !important;
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  align-items: center;
  justify-content: center;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  overflow: visible !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: var(--hlp-sc-accent) !important;
  color: var(--hlp-sc-accent-ink) !important;
  font-size: 0 !important;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  text-decoration: none;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.18s, box-shadow 0.18s;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto !important;
}
ul.products li.product a.hlp-atc:hover {
  background: var(--hlp-sc-accent-hover) !important;
  color: var(--hlp-sc-accent-ink) !important;
  transform: scale(1.08);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.34);
}
ul.products li.product a.hlp-atc:active { transform: scale(0.94); }
ul.products li.product a.hlp-atc:focus-visible {
  outline: 3px solid var(--hlp-sc-text);
  outline-offset: 3px;
}
.hlp-atc svg { display: block; flex: none; }
.hlp-atc .hlp-atc__spin,
.hlp-atc .hlp-atc__tick { position: absolute; inset: 0; margin: auto; opacity: 0; }
.hlp-atc.loading { pointer-events: none; }
.hlp-atc.loading .hlp-atc__icon { opacity: 0; }
.hlp-atc.loading .hlp-atc__spin { opacity: 1; animation: hlp-atc-spin 0.8s linear infinite; }
.hlp-atc.added .hlp-atc__icon { opacity: 0; }
.hlp-atc.added .hlp-atc__tick { opacity: 1; animation: hlp-atc-pop 0.32s cubic-bezier(0.22, 1, 0.36, 1); }
/* Standardowy link WooCommerce "Zobacz koszyk" po dodaniu - zastępuje go szuflada */
ul.products li.product a.added_to_cart { display: none !important; }
@keyframes hlp-atc-spin { to { transform: rotate(360deg); } }
@keyframes hlp-atc-pop { from { transform: scale(0.5); } to { transform: scale(1); } }

/* ---------- 2. Szuflada ---------- */
html.hlp-sc-open { overflow: hidden; }
.hlp-sc {
  position: fixed;
  inset: 0;
  z-index: 100000;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.3s;
  font-family: inherit;
}
.hlp-sc.is-open {
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.hlp-sc__backdrop {
  position: absolute;
  inset: 0;
  background: var(--hlp-sc-backdrop);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.hlp-sc.is-open .hlp-sc__backdrop { opacity: 1; }

.hlp-sc__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  background: var(--hlp-sc-bg);
  color: var(--hlp-sc-text);
  box-shadow: var(--hlp-sc-shadow);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  outline: none;
}
.hlp-sc.is-open .hlp-sc__panel { transform: translateX(0); }
@media (max-width: 767px) {
  .hlp-sc__panel { width: 100vw; }
}

.hlp-sc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 16px 20px;
  border-bottom: 1px solid var(--hlp-sc-border);
}
.hlp-sc__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--hlp-sc-text);
}
.hlp-sc__count {
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--hlp-sc-accent);
  color: var(--hlp-sc-accent-ink);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.hlp-sc__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--hlp-sc-border);
  border-radius: 50%;
  background: var(--hlp-sc-surface);
  color: var(--hlp-sc-text);
  cursor: pointer;
  transition: background-color 0.18s, transform 0.18s;
}
.hlp-sc__close:hover { background: var(--hlp-sc-surface-2); }
.hlp-sc__close:active { transform: scale(0.94); }

.hlp-sc__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 20px 20px;
  transition: opacity 0.18s;
}
.hlp-sc.is-busy .hlp-sc__body { opacity: 0.55; pointer-events: none; }

/* Pozycje koszyka */
.hlp-sc__items { margin: 0; padding: 0; list-style: none; }
.hlp-sc__item {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr 32px;
  gap: 12px;
  margin: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--hlp-sc-border);
}
.hlp-sc__thumb { display: block; width: 72px; height: 72px; border-radius: 12px; overflow: hidden; background: var(--hlp-sc-surface); }
.hlp-sc__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hlp-sc__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hlp-sc__name {
  color: var(--hlp-sc-text);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
}
a.hlp-sc__name:hover { color: var(--hlp-sc-accent); text-decoration: underline; }
.hlp-sc__meta, .hlp-sc__unit { color: var(--hlp-sc-muted); font-size: 0.8125rem; line-height: 1.4; }
.hlp-sc__unit .amount, .hlp-sc__unit small { font-size: inherit; }
.hlp-sc__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.hlp-sc__line { color: var(--hlp-sc-text); font-size: 1rem; font-weight: 700; white-space: nowrap; }
.hlp-sc__line small, .hlp-sc__sum-val small, .hlp-sc__rec-price small { font-size: 0.75rem; font-weight: 500; color: var(--hlp-sc-muted); }

.hlp-sc__qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--hlp-sc-border);
  border-radius: 9999px;
  background: var(--hlp-sc-surface);
}
.hlp-sc__step {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--hlp-sc-text);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.18s, transform 0.18s;
}
.hlp-sc__step:hover:not(:disabled) { background: var(--hlp-sc-surface-2); }
.hlp-sc__step:active:not(:disabled) { transform: scale(0.9); }
.hlp-sc__step:disabled { opacity: 0.4; cursor: not-allowed; }
.hlp-sc__qty-val { min-width: 28px; text-align: center; font-size: 0.9375rem; font-weight: 600; color: var(--hlp-sc-text); }

.hlp-sc__remove {
  align-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--hlp-sc-muted);
  cursor: pointer;
  transition: color 0.18s, background-color 0.18s;
}
.hlp-sc__remove:hover { color: var(--hlp-sc-danger); background: var(--hlp-sc-surface); }

/* Pasujące produkty */
.hlp-sc__recs { margin-top: 24px; }
.hlp-sc__recs-title { margin: 0 0 12px; font-size: 1rem; font-weight: 700; color: var(--hlp-sc-text); }
.hlp-sc__rec-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.hlp-sc__rec {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--hlp-sc-border);
  border-radius: 14px;
  background: var(--hlp-sc-surface);
}
.hlp-sc__rec-thumb { display: block; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--hlp-sc-bg); }
.hlp-sc__rec-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hlp-sc__rec-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hlp-sc__rec-name {
  color: var(--hlp-sc-text);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hlp-sc__rec-name:hover { color: var(--hlp-sc-accent); }
.hlp-sc__rec-price { color: var(--hlp-sc-text); font-size: 0.875rem; font-weight: 700; }
.hlp-sc__rec-price del { color: var(--hlp-sc-muted); font-weight: 400; }
.hlp-sc__rec-price ins { text-decoration: none; }
.hlp-sc__rec-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--hlp-sc-accent);
  border-radius: 9999px;
  background: transparent;
  color: var(--hlp-sc-accent);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s, color 0.18s, transform 0.18s;
}
.hlp-sc__rec-add:hover { background: var(--hlp-sc-accent); color: var(--hlp-sc-accent-ink); }
.hlp-sc__rec-add:active { transform: scale(0.95); }
.hlp-sc__rec-add.is-loading { opacity: 0.6; pointer-events: none; }

/* Stopka: dostawa, suma, przyciski */
.hlp-sc__foot {
  flex: none;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hlp-sc-border);
  background: var(--hlp-sc-bg);
}
.hlp-sc__foot:empty { display: none; }
.hlp-sc__ship { margin-bottom: 14px; }
.hlp-sc__ship-text { margin: 0 0 8px; font-size: 0.875rem; line-height: 1.35; color: var(--hlp-sc-text); }
.hlp-sc__ship-text strong { font-weight: 700; }
.hlp-sc__ship-track { height: 8px; border-radius: 9999px; overflow: hidden; background: var(--hlp-sc-track); }
.hlp-sc__ship-fill { display: block; height: 100%; border-radius: inherit; background: var(--hlp-sc-accent); transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1); }
.hlp-sc__sum { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; color: var(--hlp-sc-muted); font-size: 0.9375rem; }
.hlp-sc__sum-val { color: var(--hlp-sc-text); font-size: 1.25rem; font-weight: 700; }

.hlp-sc__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 9999px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.18s, transform 0.18s, color 0.18s;
}
.hlp-sc__btn--primary { background: var(--hlp-sc-accent); color: var(--hlp-sc-accent-ink); }
.hlp-sc__btn--primary:hover { background: var(--hlp-sc-accent-hover); color: var(--hlp-sc-accent-ink); }
.hlp-sc__btn--primary:active { transform: scale(0.98); }
.hlp-sc__btn--link { margin-top: 4px; min-height: 44px; color: var(--hlp-sc-text); font-weight: 600; font-size: 0.9375rem; text-decoration: underline; text-underline-offset: 3px; }
.hlp-sc__btn--link:hover { color: var(--hlp-sc-accent); }

.hlp-sc__empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px 8px; text-align: center; color: var(--hlp-sc-muted); }
.hlp-sc__empty-title { margin: 8px 0 0; font-size: 1.125rem; font-weight: 700; color: var(--hlp-sc-text); }
.hlp-sc__empty-text { margin: 0 0 16px; font-size: 0.9375rem; }
.hlp-sc__empty .hlp-sc__btn { width: 100%; max-width: 280px; }

.hlp-sc button:focus-visible,
.hlp-sc a:focus-visible {
  outline: 3px solid var(--hlp-sc-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .hlp-sc, .hlp-sc__backdrop, .hlp-sc__panel, .hlp-sc__ship-fill { transition: none !important; }
  .hlp-atc.loading .hlp-atc__spin, .hlp-atc.added .hlp-atc__tick { animation: none !important; }
}
