/*
 * LIVI Single Product Page — CSS
 * Mobile-first. Loaded only on is_product() pages.
 * Consumes tokens from livi-design-system.css.
 * Uses !important only to override Porto where necessary.
 */

/* ══════════════════════════════════════════════════════════
   PAGE WRAPPER
══════════════════════════════════════════════════════════ */

.livi-single-product {
  background: #fff;
  font-family: var(--livi-font) !important;
}

/* ══════════════════════════════════════════════════════════
   TOP SECTION — default: stacked (mobile)
══════════════════════════════════════════════════════════ */

.livi-sp-top {
  display: flex;
  flex-direction: column;
}

/* ── Gallery (mobile) ───────────────────────────────────── */

.livi-gallery {
  position: relative;
  display: flex;
  flex-direction: column;
}

.livi-gallery__main {
  position: relative;
  background: #f8f8f8;
}

.livi-gallery__img {
  width: 100% !important;
  height: auto !important;
  max-height: 600px;
  object-fit: contain;
  display: block;
}

/* Thumbnails — horizontal scroll on mobile */
.livi-gallery__thumbs {
  display: flex;
  flex-direction: row;
  gap: 6px;
  overflow-x: auto;
  padding: 8px var(--sp-4);
  background: #fafafa;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  order: 1;
}
.livi-gallery__thumbs::-webkit-scrollbar { display: none; }

.livi-gallery__thumb {
  flex-shrink: 0;
  width: 72px;
  height: 90px;
  border: 1px solid #eee;
  border-radius: 2px;
  overflow: hidden;
  padding: 0;
  background: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.livi-gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.livi-gallery__thumb.is-active,
.livi-gallery__thumb:hover {
  border-color: #111;
}

/* Badges on gallery */
.livi-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  font-family: var(--livi-font);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 2px;
  z-index: 2;
  line-height: 1;
}
.livi-badge--new {
  background: #111;
  color: #fff;
}
.livi-badge--sale {
  background: var(--livi-accent);
  color: #fff;
  top: 12px;
  left: auto;
  right: 12px;
}

/* ── Product Info (mobile) ──────────────────────────────── */

.livi-product-info {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.livi-product-info__brand {
  font-size: 8px;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin: 0;
}

.livi-product-info__title {
  font-family: var(--livi-font) !important;
  font-size: 20px !important;
  font-weight: 600 !important;
  color: #111 !important;
  line-height: 1.25 !important;
  margin: 0 !important;
}

/* Price */
.livi-product-info__price .price {
  font-family: var(--livi-font) !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  color: #111 !important;
}
.livi-product-info__price .price ins {
  color: var(--livi-accent) !important;
  text-decoration: none !important;
}
.livi-product-info__price .price del {
  color: #ccc !important;
  opacity: 1 !important;
  font-weight: 400 !important;
  font-size: 14px !important;
}

.livi-product-info__divider {
  border: none;
  border-top: 1px solid #f2f2f2;
  margin: 0;
}

/* ── Variation swatches ─────────────────────────────────── */

/* Hide native selects + Porto filter list */
.livi-product-info .variations td.value select,
.livi-product-info__variations .variations td.value select {
  display: none !important;
}
.variations td.value ul.filter-item-list {
  display: none !important;
}

/* Table layout */
.variations {
  border-collapse: collapse !important;
  width: 100% !important;
}
.variations tr {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  margin-bottom: 12px !important;
}
.variations th.label,
.variations td.value {
  display: block !important;
  width: 100% !important;
  padding: 0 !important;
  border: none !important;
}
.variations th.label label {
  font-family: var(--livi-font) !important;
  font-size: 8px !important;
  color: #888 !important;
  text-transform: uppercase !important;
  letter-spacing: 1.5px !important;
  font-weight: 400 !important;
}

/* Swatch group */
.livi-swatches {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
}

/* Size pill */
.livi-swatch {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 44px !important;
  height: 36px !important;
  padding: 0 var(--sp-3) !important;
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  background: #fff !important;
  color: var(--livi-text) !important;
  font-family: var(--livi-font) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: border-color 0.15s, background 0.15s, color 0.15s !important;
  -webkit-appearance: none !important;
  text-align: center !important;
}
.livi-swatch:hover:not(.livi-swatch--unavailable):not(.livi-swatch--active) {
  border-color: #888 !important;
}
.livi-swatch--active {
  border-color: #111 !important;
  background: #111 !important;
  color: #fff !important;
}
.livi-swatch--unavailable {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  text-decoration: line-through !important;
}

/* Color swatch circles */
.livi-swatch--color {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  position: relative !important;
  border-width: 1.5px !important;
}
.livi-swatch--color.livi-swatch--active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #111 !important;
  background: inherit !important;
}
/* OOS diagonal line on color swatch */
.livi-swatch--color.livi-swatch--unavailable::after {
  content: '' !important;
  position: absolute !important;
  inset: 0 !important;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.75px),
    #aaa calc(50% - 0.75px),
    #aaa calc(50% + 0.75px),
    transparent calc(50% + 0.75px)
  ) !important;
  border-radius: 50% !important;
}

/* Reset link — hide */
a.reset_variations,
.reset_variations {
  display: none !important;
}

/* ── Add to cart area (mobile) ──────────────────────────── */

.livi-product-info__variations form.cart,
.livi-product-info__add-to-cart--simple form.cart {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  margin: 0 !important;
}

/* Qty selector */
.quantity {
  display: flex !important;
  align-items: center !important;
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  overflow: hidden !important;
  width: auto !important;
}
.quantity input.qty {
  width: 40px !important;
  height: 40px !important;
  text-align: center !important;
  border: none !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #111 !important;
  background: #fff !important;
  -moz-appearance: textfield !important;
  padding: 0 !important;
  margin: 0 !important;
}
.quantity input.qty::-webkit-inner-spin-button,
.quantity input.qty::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
}

/* Wishlist button */
.livi-wishlist-btn {
  width: 40px;
  height: 40px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.livi-wishlist-btn:hover,
.livi-wishlist-btn.is-active {
  color: var(--livi-accent);
  border-color: var(--livi-accent);
}

/* CTA button — full width on mobile */
.single_add_to_cart_button,
button.single_add_to_cart_button,
.livi-product-info .single_add_to_cart_button {
  width: 100% !important;
  height: 44px !important;
  background: #111 !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  border: none !important;
  border-radius: 4px !important;
  font-family: var(--livi-font) !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  letter-spacing: 1.5px !important;
  text-transform: uppercase !important;
  cursor: pointer !important;
  transition: background 0.15s !important;
}
.single_add_to_cart_button:hover {
  background: #333 !important;
}

/* Qty + CTA + Wishlist row (JS inserts .livi-qty-cta-row) */
.livi-qty-cta-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.livi-qty-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.livi-qty-wrapper .qty-btn {
  width: 36px;
  height: 40px;
  background: #f9f9f9;
  border: none;
  font-size: 17px;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}
.livi-qty-wrapper .qty-btn--minus { border-right: 1px solid #ddd; }
.livi-qty-wrapper .qty-btn--plus  { border-left:  1px solid #ddd; }
.livi-qty-wrapper .qty-btn:hover  { background: #f0f0f0; }

.livi-qty-cta-row .single_add_to_cart_button {
  flex: 1 !important;
  height: 40px !important;
}

/* ── Trust Badges (mobile) ──────────────────────────────── */

.livi-trust-badges {
  display: flex;
  align-items: stretch;
  padding: 12px 0;
  border-top: 1px solid #f2f2f2;
  border-bottom: 1px solid #f2f2f2;
}
.livi-trust-badge {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
  padding: 4px;
  cursor: default;
  position: relative;
}
.livi-trust-badge__sep {
  width: 1px;
  background: #f0f0f0;
  flex-shrink: 0;
}
.livi-trust-badge__icon {
  color: #111;
  display: block;
  flex-shrink: 0;
}
.livi-trust-badge__label {
  font-family: var(--livi-font);
  font-size: 7px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.3;
  font-weight: 500;
}

/* Tooltip (desktop only via hover) */
.livi-trust-badge::before {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  font-size: 9px;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 10;
}
.livi-trust-badge::after {
  content: '';
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #111;
}

/* Delivery link */
.livi-product-info__delivery-link {
  margin-top: -4px;
}
.livi-delivery-trigger {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--livi-font);
  font-size: 9px;
  color: #444;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
  letter-spacing: 0.3px;
  line-height: 1.4;
  transition: color 0.15s, border-color 0.15s;
}
.livi-delivery-trigger:hover {
  color: #111;
  border-color: #111;
}

/* ══════════════════════════════════════════════════════════
   BOTTOM SECTION — Description + Size Table
   Mobile: single column
══════════════════════════════════════════════════════════ */

.livi-sp-bottom {
  border-top: 2px solid #f0f0f0;
  margin-top: 0;
}
.livi-sp-bottom__inner {
  padding: 28px var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.livi-sp-bottom__sep {
  display: none;
}
.livi-sp-section-heading {
  font-family: var(--livi-font) !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 2px !important;
  color: #111 !important;
  margin: 0 0 14px !important;
}
.livi-sp-description {
  font-family: var(--livi-font);
  font-size: 13px;
  color: #555;
  line-height: 1.85;
}
.livi-sp-description p { margin-bottom: 10px; }
.livi-sp-description p:last-child { margin-bottom: 0; }

/* Size table */
.livi-size-chart {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.livi-size-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--livi-font);
  font-size: 11px;
  min-width: 280px;
}
.livi-size-table thead tr { background: #111; }
.livi-size-table thead th {
  padding: 8px 12px;
  color: #fff;
  font-weight: 500;
  text-align: left;
  font-size: 9px;
  letter-spacing: 0.5px;
}
.livi-size-table tbody tr:nth-child(odd)  { background: #fff; }
.livi-size-table tbody tr:nth-child(even) { background: #fafafa; }
.livi-size-table tbody tr.is-active       { background: #fdf5f7 !important; }
.livi-size-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f0f0;
  color: #555;
}
.livi-size-table tbody tr.is-active td { color: #111; font-weight: 700; }
.livi-size-table tbody tr.is-active td:first-child { border-left: 3px solid var(--livi-accent); }

.livi-size-chart__hint {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fafafa;
  border-radius: 2px;
  border-left: 2px solid #ddd;
  font-size: 10px;
  color: #888;
  line-height: 1.6;
}
.livi-size-chart__hint-link {
  color: #111;
  border-bottom: 1px solid #ccc;
  text-decoration: none;
}

/* ══════════════════════════════════════════════════════════
   CROSS-SELLS + RELATED — mobile: horizontal scroll
══════════════════════════════════════════════════════════ */

.livi-cross-sells,
.livi-related {
  padding: 24px 0;
  border-top: 1px solid #f0f0f0;
}
.livi-cross-sells { background: #fafafa; }

.livi-products-heading {
  font-family: var(--livi-font) !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  letter-spacing: 2.5px !important;
  text-transform: uppercase !important;
  color: #111 !important;
  margin: 0 0 16px var(--sp-4) !important;
}

.livi-products-grid {
  display: flex;
  flex-direction: row;
  gap: 12px;
  overflow-x: auto;
  padding: 0 var(--sp-4) 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.livi-products-grid::-webkit-scrollbar { display: none; }

.livi-product-card {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
}
.livi-product-card__link { display: block; overflow: hidden; }
.livi-product-card__img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  transition: transform 0.3s ease;
}
.livi-product-card:hover .livi-product-card__img {
  transform: scale(1.03);
}
.livi-product-card__body { padding: 8px 0 0; }
.livi-product-card__title {
  font-family: var(--livi-font);
  font-size: 12px;
  font-weight: 500;
  color: #111;
  line-height: 1.4;
  margin: 0 0 4px;
}
.livi-product-card__title a {
  color: inherit;
  text-decoration: none;
}
.livi-product-card__price .price {
  font-family: var(--livi-font) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #111 !important;
}
.livi-product-card__price .price ins { color: var(--livi-accent) !important; text-decoration: none !important; }
.livi-product-card__price .price del { color: #ccc !important; font-size: 11px !important; font-weight: 400 !important; }

/* ══════════════════════════════════════════════════════════
   DELIVERY POPUP
══════════════════════════════════════════════════════════ */

.livi-dp {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.livi-dp.is-open { display: flex; }
.livi-dp__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.livi-dp__box {
  position: relative;
  background: #fff;
  max-width: 600px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding: 40px 32px;
  z-index: 1;
  animation: liviDpIn 0.2s ease;
}
@keyframes liviDpIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.livi-dp__close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 22px;
  color: #aaa;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  transition: color 0.15s;
}
.livi-dp__close:hover { color: #111; }
.livi-dp__title {
  font-family: var(--livi-font) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 2px !important;
  color: #111 !important;
  margin: 0 0 20px !important;
  padding-bottom: 16px !important;
  border-bottom: 1px solid #eee !important;
}
.livi-dp__section {
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid #f0f0f0;
}
.livi-dp__section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}
.livi-dp__section-heading {
  font-family: var(--livi-font) !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 1.5px !important;
  color: #111 !important;
  margin: 0 0 8px !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}
.livi-dp__section p {
  font-family: var(--livi-font);
  font-size: 12px;
  color: #666;
  line-height: 1.8;
  margin: 0;
}

/* ══════════════════════════════════════════════════════════
   STICKY BOTTOM BAR (mobile only)
══════════════════════════════════════════════════════════ */

.livi-sticky-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: #111;
  padding: 10px 16px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
}
.livi-sticky-bar.is-visible {
  display: block;
}
.livi-sticky-bar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}
.livi-sticky-bar__meta {
  flex: 1;
  min-width: 0;
}
.livi-sticky-bar__price {
  display: block;
  font-family: var(--livi-font);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.livi-sticky-bar__selection {
  display: block;
  font-family: var(--livi-font);
  font-size: 10px;
  color: #aaa;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.livi-sticky-bar__cta {
  flex-shrink: 0;
  background: var(--livi-accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: var(--livi-font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.livi-sticky-bar__cta:hover { background: #b5758a; }

/* Scroll lock when popup open */
body.livi-popup-open {
  overflow: hidden !important;
}

/* ══════════════════════════════════════════════════════════
   TABLET (768px+)
══════════════════════════════════════════════════════════ */

@media (min-width: 768px) {

  /* Top split: 50/50 side by side */
  .livi-sp-top {
    flex-direction: row;
  }
  .livi-sp-top__gallery {
    flex: 0 0 50%;
  }
  .livi-sp-top__info {
    flex: 1;
    border-left: 1px solid #f0f0f0;
  }

  /* Gallery: thumbnails vertical, main image beside */
  .livi-gallery {
    flex-direction: row;
    padding: 16px 16px 16px 24px;
    background: #fafafa;
    min-height: 320px;
    align-items: flex-start;
    gap: 8px;
  }
  .livi-gallery__thumbs {
    flex-direction: column;
    flex-shrink: 0;
    width: 72px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0;
    order: 0;
    gap: 5px;
    background: transparent;
  }
  .livi-gallery__thumb {
    width: 72px;
    height: 90px;
  }
  .livi-gallery__main {
    flex: 1;
    min-height: 300px;
  }
  .livi-gallery__img {
    aspect-ratio: 4 / 5;
    height: 100% !important;
    object-fit: cover;
  }

  /* Product info */
  .livi-product-info {
    padding: 20px 24px;
  }
  .livi-product-info__title {
    font-size: 16px !important;
  }

  /* Bottom section: 2 columns 50/50 */
  .livi-sp-bottom__inner {
    flex-direction: row;
    gap: 0;
    padding: 28px 24px;
    align-items: flex-start;
  }
  .livi-sp-bottom__desc {
    flex: 0 0 50%;
    padding-right: 32px;
  }
  .livi-sp-bottom__sep {
    display: block;
    width: 1px;
    background: #eee;
    align-self: stretch;
    flex-shrink: 0;
  }
  .livi-sp-bottom__sizes {
    flex: 1;
    padding-left: 32px;
  }

  /* Products: 3-column grid */
  .livi-products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow: visible;
    padding: 0 24px;
    gap: 14px;
  }
  .livi-product-card {
    flex: unset;
  }

  .livi-products-heading {
    margin-left: 24px !important;
  }
  .livi-cross-sells,
  .livi-related {
    padding: 24px 0;
  }

  /* Trust badge tooltips visible on hover */
  .livi-trust-badge:hover::before,
  .livi-trust-badge:hover::after {
    display: block;
  }

  /* Sticky bar: hide on tablet+ */
  .livi-sticky-bar {
    display: none !important;
  }
}

/* ══════════════════════════════════════════════════════════
   DESKTOP (1024px+)
══════════════════════════════════════════════════════════ */

@media (min-width: 1024px) {

  /* 55/45 split */
  .livi-sp-top__gallery { flex: 0 0 55%; max-width: 55%; }
  .livi-sp-top__info    { flex: 1; }

  /* Gallery padding */
  .livi-gallery {
    padding: 16px 16px 24px 28px;
  }
  .livi-gallery__main {
    min-height: 400px;
  }

  /* Product info */
  .livi-product-info {
    padding: 28px;
  }
  .livi-product-info__title {
    font-size: clamp(18px, 2vw, 22px) !important;
  }

  /* Bottom section */
  .livi-sp-bottom__inner {
    padding: 36px 28px;
  }
  .livi-sp-bottom__desc {
    flex: 0 0 55%;
    padding-right: 48px;
  }

  /* Size table: sticky */
  .livi-sp-bottom__sizes {
    position: sticky;
    top: 80px;
    padding-left: 48px;
  }

  /* Products: 4-column grid */
  .livi-products-grid {
    grid-template-columns: repeat(4, 1fr);
    padding: 0 28px;
  }
  .livi-products-heading {
    margin-left: 28px !important;
  }
}

/* ══════════════════════════════════════════════════════════
   SKU
══════════════════════════════════════════════════════════ */

.livi-product-info__sku {
  font-size: 12px;
  color: #999;
  margin: -4px 0 0;
  line-height: 1.4;
}
.livi-product-info__sku span {
  color: #777;
}
