/**
 * BESTELLEN.CITY - LIVESTREAM LAYER SYSTEM & STABILIZATION HELPER
 * Path: /dashboard/gta_mod/assets/helpers/live-stream-layer.css
 * 
 * Strict Layer Separation & Isolation:
 * - Layer 1: Agora RTC Video Canvas (100vw x 100vh / 100dvh, object-fit: cover)
 * - Layer 5: Ambient Top & Bottom Contrast Gradients (pointer-events: none)
 * - Layer 15: Stream Header Overlay (Host Pill, Studio Trigger, Viewers)
 * - Layer 25: Right Interactive Action Stack (Likes burst, Products, Share)
 * - Layer 30: Transparent In-Stream Comments Feed (High contrast, drop-shadowed bubbles)
 * - Layer 35: Commerce Pinned Product & Transparent Comment Input Bar
 * - Layer 2100: Global Persistent Bottom Navigation Dock
 */

:root {
  --z-stream-video: 1;
  --z-stream-scrim: 5;
  --z-stream-topbar: 15;
  --z-stream-actions: 25;
  --z-stream-comments: 30;
  --z-stream-commerce: 35;
  --z-stream-dock: 2100;
}

/* =========================================================================
   1. FULLSCREEN VIEWPORT & SCROLL-SNAP CONTAINER (NATIVE TIKTOK HAPTICS)
   ========================================================================= */
.live-theater-snap-view {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  z-index: 1050 !important;
  background: #000000 !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
}

.tiktok-live-viewport {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow-x: hidden !important;
  overflow-y: scroll !important;
  scroll-snap-type: y mandatory !important;
  scroll-behavior: smooth !important;
  overscroll-behavior-y: contain !important;
  -webkit-overflow-scrolling: touch !important;
  scrollbar-width: none !important;
  position: relative !important;
  background: #000000 !important;
  margin: 0 !important;
  padding: 0 !important;
  touch-action: pan-y !important;
}

.tiktok-live-viewport::-webkit-scrollbar {
  display: none !important;
}

.tiktok-live-slide {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  min-height: 100dvh !important;
  flex: 0 0 100dvh !important;
  scroll-snap-align: start !important;
  scroll-snap-stop: always !important;
  position: relative !important;
  overflow: hidden !important;
  background: #000000 !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  contain: strict;
}

/* =========================================================================
   2. LAYER 1: VIDEO CANVAS (IFRAME & AGORA RTC)
   ========================================================================= */
.tiktok-video-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-stream-video);
  background: #000000;
  overflow: hidden;
}

.tiktok-stream-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  pointer-events: auto;
}

/* =========================================================================
   3. LAYER 5: AMBIENT LEGIBILITY GRADIENTS (POINTER-EVENTS: NONE)
   ========================================================================= */
.tiktok-live-slide::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 140px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.25) 55%, transparent 100%);
  z-index: var(--z-stream-scrim);
  pointer-events: none;
}

.tiktok-live-slide::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 260px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.45) 50%, transparent 100%);
  z-index: var(--z-stream-scrim);
  pointer-events: none;
}

/* =========================================================================
   4. LAYER 15: TOP INTERACTIVE OVERLAY (HOST META & STUDIO)
   ========================================================================= */
.tiktok-top-overlay {
  position: absolute;
  top: calc(var(--gta-topbar-h, 54px) + var(--gta-safe-top, 0px) + 8px);
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: var(--z-stream-topbar);
  pointer-events: auto;
}

.tiktok-host-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  max-width: 65vw;
}

.tiktok-host-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #ec4899;
  background: #1e293b;
  flex-shrink: 0;
}

.tiktok-host-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tiktok-host-name {
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.tiktok-host-viewers {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}

.tiktok-studio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(236, 72, 153, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.4);
  transition: transform 0.15s ease, background 0.15s ease;
}

.tiktok-studio-btn:active {
  transform: scale(0.95);
  background: #db2777;
}

/* =========================================================================
   5. LAYER 25: RIGHT INTERACTION STACK (HEART, CART, SHARE)
   ========================================================================= */
.tiktok-right-stack {
  position: absolute;
  right: 12px;
  bottom: calc(var(--gta-dock-h, 72px) + var(--gta-safe-bottom, 0px) + 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: var(--z-stream-actions);
  pointer-events: auto;
}

.tiktok-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  user-select: none;
}

.tiktok-action-btn-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.2s ease;
}

.tiktok-action-item:active .tiktok-action-btn-circle {
  transform: scale(0.9);
}

.tiktok-action-btn-circle.liked {
  background: #ec4899;
  border-color: #f472b6;
  color: #ffffff;
  transform: scale(1.18);
}

.tiktok-action-btn-circle.tt-action-gold {
  color: #fbbf24;
}

.tiktok-action-count {
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  letter-spacing: 0.2px;
}

/* =========================================================================
   6. LAYER 30 & 35: TRANSPARENT COMMENTS & COMMERCE OVERLAY
   ========================================================================= */
.tiktok-bottom-area {
  position: absolute;
  left: 14px;
  right: 76px;
  bottom: calc(var(--gta-dock-h, 72px) + var(--gta-safe-bottom, 0px) + 14px) !important;
  z-index: var(--z-stream-commerce);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

/* Floating Comments Feed */
.tiktok-chat-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
  pointer-events: auto;
  mask-image: linear-gradient(to bottom, transparent 0%, black 22%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 22%);
  scrollbar-width: none;
  padding-right: 6px;
}

.tiktok-chat-feed::-webkit-scrollbar {
  display: none;
}

.tiktok-chat-bubble {
  font-size: 12.5px;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 6px 14px;
  border-radius: 9999px;
  width: fit-content;
  max-width: 95%;
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  word-break: break-word;
  animation: slideCommentIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideCommentIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tiktok-chat-bubble strong {
  color: #facc15;
  margin-right: 6px;
  font-weight: 800;
}

.tiktok-chat-bubble.tiktok-bubble-self {
  background: rgba(236, 72, 153, 0.7);
  border-color: rgba(236, 72, 153, 0.35);
}

.tiktok-chat-bubble.tiktok-bubble-self strong {
  color: #ffffff;
}

/* Pinned Stream Product Shelf */
.tiktok-pinned-product {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.75);
}

.tiktok-pinned-img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
}

.tiktok-pinned-body {
  flex: 1;
  min-width: 0;
}

.tiktok-pinned-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tiktok-pinned-price {
  font-size: 12.5px;
  font-weight: 800;
  color: #ec4899;
  margin-top: 1px;
}

.tiktok-pinned-buy {
  padding: 8px 14px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.tiktok-pinned-buy:active {
  transform: scale(0.95);
  background: #ec4899;
}

/* In-Stream Comment Bar */
.tiktok-comment-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  pointer-events: auto;
}

.tiktok-comment-input {
  flex: 1;
  height: 38px;
  padding: 0 16px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 9999px;
  font-size: 12.5px;
  color: #ffffff;
  outline: none;
  transition: all 0.2s ease;
}

.tiktok-comment-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.tiktok-comment-input:focus {
  background: rgba(15, 23, 42, 0.9);
  border-color: #ec4899;
}

.tiktok-comment-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ec4899;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

.tiktok-comment-send:active {
  transform: scale(0.92);
  background: #db2777;
}

/* =========================================================================
   7. COLLISION PREVENTION: STRICT SUPPRESSION OF LEGACY WEB ELEMENTS
   ========================================================================= */
.tiktok-live-slide .top-bar,
.tiktok-live-slide .embed-close-back,
.tiktok-live-slide .vendor-bar,
.tiktok-live-slide .featured-shelf,
.tiktok-live-slide .right-pane,
.tiktok-live-slide .header-nav,
.tiktok-live-slide .desktop-chat {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* Persistent Bottom Dock Overlays Livestream Without Obscuring Content */
body:not(.modal-open-settings) .dock-wrap {
  z-index: var(--z-stream-dock) !important;
}
