/* ── Upsell list wrapper ─────────────────────────────────────────────────── */
.empolas-upsell {
  margin-top: 14px;
}

.empolas-upsell__list {
  display: grid;
  gap: 12px;
}

/* ── Tile ────────────────────────────────────────────────────────────────── */
.empolas-upsell__item {
  position: relative;
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 14px;
  background: #fff;
  color: #111827;
  overflow: hidden;
  cursor: pointer;
  /* Eliminate 300 ms tap-delay on iOS/Android */
  touch-action: manipulation;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  /* Remove browser default outline – replaced with :focus-visible below */
  outline: none;
}

.empolas-upsell__item::before,
.empolas-upsell__item::after { content: none !important; }

/* Hover / focus visual feedback */
.empolas-upsell__item:hover,
.empolas-upsell__item:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(0,0,0,.18);
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

/* Accessible focus ring (keyboard navigation) */
.empolas-upsell__item:focus-visible {
  outline: 3px solid #92c72f;
  outline-offset: 2px;
}

/* ── Tile header bar ─────────────────────────────────────────────────────── */
.empolas-upsell__header {
  padding: 8px 12px;
  background: var(--empolas-header-bg, #1e40af);
  color: #fff;
  font-weight: 700;
  letter-spacing: .2px;
}

/* ── Tile body grid: thumbnail | content ─────────────────────────────────── */
.empolas-upsell__body {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  /* stretch so the content column fills the row height;
     this lets .empolas-upsell__more-wrap sit at the bottom */
  align-items: stretch;
  padding: 12px;
  padding-bottom: 16px; /* extra room for the CTA pill */
}

.empolas-upsell__media img {
  width: 88px !important;
  height: 88px !important;
  object-fit: cover !important;
  border-radius: 12px !important;
}

/* ── Tile content column ─────────────────────────────────────────────────── */
.empolas-upsell__content {
  position: relative;
  /* Ensure there is always enough room for the absolute CTA pill */
  min-height: 88px;
  padding-bottom: 32px; /* reserve space for the absolutely-positioned CTA */
}

.empolas-upsell__title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.empolas-upsell__title {
  font-weight: 700;
  line-height: 1.2;
}

.empolas-upsell__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empolas-upsell__badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--empolas-badge-bg, rgba(0,0,0,.06));
  border: 1px solid rgba(0,0,0,.08);
  color: var(--empolas-badge-color, inherit);
  line-height: 1.2;
  white-space: nowrap;
}

.empolas-upsell__desc {
  margin-top: 6px;
  font-size: 13px;
  opacity: .86;
}

/* Cena + „Ušetříte“ vedle sebe */
.empolas-upsell__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-weight: 700;
}

/* Savings pill — červená, vizuálně navazuje na slevu/přeškrtnutou cenu */
.empolas-upsell__savings {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(229,57,53,.10);
  border: 1px solid rgba(229,57,53,.45);
  color: #c62828;
  white-space: nowrap;
}

/* Rating row — v dlaždici hned pod názvem produktu */
.empolas-upsell__rating,
.empolas-upsell__modal-rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.empolas-upsell__content > .empolas-upsell__rating {
  display: flex;
  margin-top: 4px;
}

.empolas-upsell__rating .star-rating,
.empolas-upsell__modal-rating .star-rating {
  margin: 0;
}

.empolas-upsell__rating-count {
  display: inline-block;
  white-space: nowrap;
  font-size: 13px;
  opacity: .7;
}

/* ── CTA „Rozkliknout detail nabídky" – pinned to bottom-right of the tile ── */
.empolas-upsell__more-wrap {
  position: absolute;
  right: 12px;
  bottom: 0;
}

.empolas-upsell__more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  color: #1e40af;
  padding: 6px 12px;
  border: 1px solid rgba(30,64,175,.35);
  border-radius: 999px;
  background: rgba(30,64,175,.05);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}

.empolas-upsell__more::after {
  content: '›';
  font-size: 14px;
  line-height: 1;
}

.empolas-upsell__item:hover .empolas-upsell__more,
.empolas-upsell__item:focus-visible .empolas-upsell__more {
  background: rgba(30,64,175,.12);
  border-color: rgba(30,64,175,.55);
}

/* Chevron arrow: not rendered by PHP, kept hidden in case of theme injection */
.empolas-upsell__chevron { display: none !important; }

/* ── Popup overlay ───────────────────────────────────────────────────────── */
.empolas-upsell__overlay[hidden],
.empolas-upsell__overlay[aria-hidden="true"] { display: none !important; }

.empolas-upsell__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  /* DŮLEŽITÉ: ve výchozím stavu skrytý. display:flex nastavuje až JS při
     otevření (inline style) — base pravidlo s display:flex dříve způsobovalo,
     že se modal mohl zobrazit hned po načtení stránky, pokud šablona/optimizer
     přebily atribut [hidden]. */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px; /* prevents modal touching screen edges on mobile */
  z-index: 999999;
}

.empolas-upsell__modal {
  width: min(920px, 100%);
  max-height: min(86vh, 900px);
  /* Vždy plné bílé pozadí + tmavý text — některé šablony (či dark mode)
     nastavují průhledná pozadí/světlý text a modal pak vypadá rozbitě. */
  background: #fff !important;
  color: #111827;
  border-radius: 16px;
  overflow: auto;
  position: relative;
  box-shadow: 0 20px 80px rgba(0,0,0,.35);
}

/* ── Close button ────────────────────────────────────────────────────────── */
.empolas-upsell__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.10);
  background: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.empolas-upsell__close:focus-visible {
  outline: 3px solid #92c72f;
  outline-offset: 2px;
}

/* ── Modal body & grid ───────────────────────────────────────────────────── */
.empolas-upsell__modal-body {
  padding: 18px;
  background: #fff;
}

.empolas-upsell__modal-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 18px;
  align-items: start;
}

/* Obrázek v modalu má pevný strop velikosti — i kdyby grid selhal
   (kolize se šablonou), obrázek nikdy nezabere celý modal. */
.empolas-upsell__modal-media {
  text-align: center;
}

.empolas-upsell__modal-img {
  width: 100%;
  max-width: 360px;
  height: auto;
  border-radius: 14px;
  display: block;
  margin: 0 auto;
}

/* ── Popup head ──────────────────────────────────────────────────────────── */
.empolas-upsell__modal-head {
  padding-right: 48px; /* clear the close button */
}

/* Popup title + rating on one row */
.empolas-upsell__modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.empolas-upsell__modal-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.empolas-upsell__modal-title-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.empolas-upsell__modal-title-right .empolas-upsell__modal-rating {
  margin-top: 0;
}

.empolas-upsell__modal-rating {
  margin-top: 8px;
}

/* Popup badges */
.empolas-upsell__modal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.empolas-upsell__modal-badges .empolas-upsell__badge {
  font-size: 12px;
}

/* Popup tags (from WooCommerce product tags) */
.empolas-upsell__modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empolas-upsell__tag {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.06);
  border: 1px solid rgba(0,0,0,.08);
  line-height: 1.2;
  white-space: nowrap;
}

/* ── Popup content ───────────────────────────────────────────────────────── */
/* Pozadí textových boxů je řízené nastavením v adminu přes CSS proměnnou
   --empolas-modal-text-bg (nastavuje se na overlay elementu). */
.empolas-upsell__modal-desc {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--empolas-modal-text-bg, #f4f5f7);
  opacity: .95;
}

.empolas-upsell__modal-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.empolas-upsell__modal-price {
  font-weight: 700;
  font-size: 18px;
}

.empolas-upsell__modal-savings {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(229,57,53,.10);
  border: 1px solid rgba(229,57,53,.45);
  color: #c62828;
}

.empolas-upsell__modal-extra {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px !important;
  background: var(--empolas-modal-text-bg, #f4f5f7);
}

/* ── Popup action buttons ────────────────────────────────────────────────── */
.empolas-upsell__modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.empolas-upsell__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px !important;
  border: 1px solid rgba(0,0,0,.10);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  font-size: 14px;
  touch-action: manipulation;
  transition: filter .1s ease, opacity .1s ease;
}

.empolas-upsell__btn--primary {
  background: #92c72f;
  color: #fff;
  border-color: rgba(0,0,0,.10);
}

.empolas-upsell__btn--primary:hover {
  filter: brightness(0.95);
}

.empolas-upsell__btn--ghost {
  background: #fff;
  color: #111827;
}

.empolas-upsell__btn--ghost:hover {
  background: rgba(0,0,0,.04);
}

/* Button loading state */
.empolas-upsell__btn.is-loading {
  opacity: .65;
  cursor: wait;
  pointer-events: none;
}

/* ── Price colours ───────────────────────────────────────────────────────── */
/* Sleva: původní přeškrtnutá cena šedě, aktuální cena červeně */
.empolas-upsell__price,
.empolas-upsell__modal-price {
  color: #4daf51;
}

.empolas-upsell__price del,
.empolas-upsell__modal-price del {
  color: #9ca3af;
  opacity: 1;
  font-weight: 400 !important;
  text-decoration: line-through;
}

.empolas-upsell__price del .amount,
.empolas-upsell__modal-price del .amount,
.empolas-upsell__price del bdi,
.empolas-upsell__modal-price del bdi {
  color: #9ca3af;
  font-weight: 400 !important;
}

.empolas-upsell__price ins,
.empolas-upsell__modal-price ins {
  color: #e53935;
  text-decoration: none;
}

.empolas-upsell__price ins .amount,
.empolas-upsell__modal-price ins .amount,
.empolas-upsell__price ins bdi,
.empolas-upsell__modal-price ins bdi {
  color: #e53935;
}

/* Některé šablony zvýrazňují <ins> podbarvením — v ceně to nechceme */
.empolas-upsell__price ins,
.empolas-upsell__modal-price ins {
  background: transparent;
}

/* Sufix DPH („s DPH“ apod.) se v upsell cenách nezobrazuje —
   odstraňuje se i serverově, CSS je pojistka pro cachované odpovědi */
.empolas-upsell .woocommerce-price-suffix,
.empolas-upsell__price .woocommerce-price-suffix,
.empolas-upsell__modal-price .woocommerce-price-suffix {
  display: none !important;
}

/* ── Loading spinner ─────────────────────────────────────────────────────── */
.empolas-upsell__loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px;
}

.empolas-upsell__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,0,0,.15);
  border-top-color: rgba(0,0,0,.55);
  border-radius: 999px;
  animation: empolasSpin .8s linear infinite;
  flex-shrink: 0;
}

.empolas-upsell__loading-text {
  font-weight: 700;
  opacity: .85;
}

@keyframes empolasSpin {
  to { transform: rotate(360deg); }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .empolas-upsell__body {
    grid-template-columns: 76px 1fr;
  }

  .empolas-upsell__media img {
    width: 76px !important;
    height: 76px !important;
  }

  .empolas-upsell__modal-grid {
    grid-template-columns: 1fr;
  }

  .empolas-upsell__modal-body {
    padding: 14px;
  }

  /* Na mobilu/tabletu kompaktní obrázek — nezabírá celou obrazovku */
  .empolas-upsell__modal-img {
    max-width: 240px;
  }

  .empolas-upsell__modal-actions .empolas-upsell__btn {
    width: 100%;
    justify-content: center;
  }

  /* CTA „Přidat do košíku" zůstává viditelné — sticky u spodního okraje
     modalu s krátkým tmavším stínem nahoru (značí scrollovatelný obsah). */
  .empolas-upsell__modal-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: #fff !important; /* plné pozadí — obsah za lištou nesmí prosvítat */
    margin: 16px -14px 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 6px rgba(0,0,0,.14), 0 -8px 18px rgba(0,0,0,.05);
  }
}

@media (max-width: 480px) {
  .empolas-upsell__overlay {
    padding: 10px;
    align-items: flex-end; /* sheet slides up from bottom on small phones */
  }

  .empolas-upsell__modal {
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
  }
}

/* ── Suppress 3rd-party Add-To-Cart popups during upsell flow ────────────── */
.empolas-upsell--suppress-atcp .wc-atcp,
.empolas-upsell--suppress-atcp .wc-atcp-popup,
.empolas-upsell--suppress-atcp .wc-atcp-open {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
