/* Bouton partage produit — style Alibaba (panel canaux) */
.tk-product-share {
  position: relative;
  display: inline-flex;
  align-items: center;
  /* Pas de z-index ici : sinon le panel fixed est piégé sous le backdrop */
  max-width: 100%;
}

.tk-product-share__btn {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  background: #fff;
  color: #374151;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.tk-product-share__btn:hover,
.tk-product-share__btn[aria-expanded="true"] {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 4px 12px rgb(15 23 42 / 0.08);
}

.tk-product-share__btn i {
  font-size: 0.95rem;
}

.tk-product-share__panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  left: auto;
  width: 18.5rem;
  max-width: min(18.5rem, calc(100vw - 1.5rem));
  padding: 0.85rem;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 18px 40px rgb(15 23 42 / 0.14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 10050;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}

.tk-product-share__panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.tk-product-share__title {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
}

.tk-product-share__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.tk-product-share__channel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.25rem;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: #334155;
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  min-width: 0;
  max-width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.tk-product-share__channel span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tk-product-share__channel:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.tk-product-share__icon {
  width: 2.35rem;
  height: 2.35rem;
  flex-shrink: 0;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
}

.tk-product-share__icon--wa { background: #25d366; }
.tk-product-share__icon--fb { background: #1877f2; }
.tk-product-share__icon--tg { background: #229ed9; }
.tk-product-share__icon--x { background: #111827; }
.tk-product-share__icon--mail { background: #64748b; }
.tk-product-share__icon--copy { background: #0f766e; }
.tk-product-share__icon--native { background: #ea580c; }
.tk-product-share__icon--linkedin { background: #0a66c2; }

.tk-product-share__hint {
  margin: 0.75rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid #f1f5f9;
  font-size: 0.72rem;
  color: #94a3b8;
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.35;
  max-width: 100%;
}

.tk-product-share__toast {
  position: fixed;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  z-index: 10060;
  max-width: calc(100vw - 2rem);
  padding: 0.65rem 1rem;
  border-radius: 9999px;
  background: #0f172a;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tk-product-share__toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tk-product-share__backdrop {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: rgb(15 23 42 / 0.4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.tk-product-share__backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Mobile : bottom sheet au-dessus du backdrop */
@media (max-width: 640px) {
  .tk-product-share__btn {
    padding: 0.45rem 0.7rem;
  }

  .tk-product-share__panel,
  .tk-product-share__panel.is-open {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    max-height: min(70vh, 26rem);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10050;
    border-radius: 1.15rem;
    box-shadow: 0 22px 48px rgb(15 23 42 / 0.28);
  }

  .tk-product-share__panel:not(.is-open) {
    transform: translateY(1rem);
  }

  .tk-product-share__panel.is-open {
    transform: translateY(0);
  }

  .tk-product-share__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
  }
}

@media (max-width: 360px) {
  .tk-product-share__btn span {
    display: none;
  }

  .tk-product-share__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/*
 * Pendant le partage : décaler WhatsApp / Telegram / Assistant
 * de la même valeur (espacement relatif inchangé), juste au-dessus du sheet.
 * --tk-share-sheet-lift est mesuré en JS (hauteur réelle du panel + 1 interligne).
 */
body.tk-product-share-open .whatsapp-btn,
body.tk-product-share-open .telegram-btn,
body.tk-product-share-open .tk-ai-chat-toggle {
  z-index: 10045 !important;
  transform: translate3d(0, calc(-1 * var(--tk-share-sheet-lift, 0px)), 0);
  transition: transform 0.2s ease;
}

body.tk-product-share-open .whatsapp-btn:hover,
body.tk-product-share-open .telegram-btn:hover,
body.tk-product-share-open .tk-ai-chat-toggle:hover {
  transform: translate3d(0, calc(-1 * var(--tk-share-sheet-lift, 0px) - 1px), 0);
}

body.tk-product-share-open .tk-ai-chat-panel {
  z-index: 10046 !important;
  transform: translate3d(0, calc(-1 * var(--tk-share-sheet-lift, 0px)), 0);
}
