/* ==========================================================================
   TD MMO System: Shopee-Style Modal Popup Overlay & Paywall Teaser
   @package Nhalavn
   @version 2.0.1
   ========================================================================== */

/* ── Prevent Body Scrolling when MMO Modal is Active ── */
body.td-mmo-locked-scroll {
  overflow: hidden !important;
  touch-action: none !important;
}

/* ── Modal Popup Overlay Container (Centered on Screen) ── */
.td-mmo-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
  animation: tdMmoFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tdMmoFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes tdMmoZoomIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── Main Shopee-Style Modal Card ── */
/* ── Main Shopee-Style Modal Card ── */
.td-mmo-modal-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: min(92vh, 580px);
  margin: auto;
  background: #ffffff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.08);
  animation: tdMmoZoomIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
}

/* ── Top Bar: Title & Short URL ── */
.td-mmo-modal-top {
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  line-height: 1.4;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.td-mmo-modal-top-title {
  font-weight: 600;
  color: #0f172a;
  white-space: normal;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.td-mmo-modal-top-link {
  color: #0284c7;
  text-decoration: underline;
  word-break: break-all;
  font-family: inherit;
  transition: color 0.15s ease;
}

.td-mmo-modal-top-link:hover {
  color: #0369a1;
}

/* ── Main Product Image (Constrained height so modal never overflows screen) ── */
.td-mmo-modal-media {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: clamp(140px, 25vh, 200px);
  max-height: 210px;
  background: #f8fafc;
  overflow: hidden;
  text-decoration: none;
  flex-shrink: 0;
}

.td-mmo-modal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background-color: #f8fafc;
  transition: transform 0.35s ease;
}

.td-mmo-modal-media:hover .td-mmo-modal-img {
  transform: scale(1.025);
}

.td-mmo-modal-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 32px;
}

.td-mmo-modal-img-placeholder span {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
}

/* ── Bottom Section: Full Info + High-Conversion CTA Button ── */
.td-mmo-modal-bottom {
  padding: 12px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #ffffff;
  flex-shrink: 0;
}

.td-mmo-modal-info {
  width: 100%;
}

.td-mmo-modal-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 4px;
  text-decoration: none;
  word-break: break-word;
  transition: color 0.15s ease;
}

.td-mmo-modal-title:hover {
  color: #ee4d2d;
}

.td-mmo-modal-shop {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}

.td-mmo-shop-icon {
  font-size: 14px;
  line-height: 1;
}

.td-mmo-modal-action {
  width: 100%;
}

.td-mmo-btn-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  padding: 0 18px;
  background: linear-gradient(135deg, #ee4d2d 0%, #ff5722 100%);
  color: #ffffff !important;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: 0.2px;
  text-decoration: none !important;
  box-shadow: 0 4px 14px rgba(238, 77, 45, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.td-mmo-btn-cta:hover {
  background: linear-gradient(135deg, #d83e21 0%, #f4511e 100%);
  transform: translateY(-1.5px);
  box-shadow: 0 6px 20px rgba(238, 77, 45, 0.45);
}

.td-mmo-btn-cta:active {
  transform: translateY(0.5px);
  box-shadow: 0 2px 8px rgba(238, 77, 45, 0.3);
}

/* ── Optional Guide Video Bar ── */
.td-mmo-modal-guide-bar {
  padding: 10px 20px 14px;
  background: #ffffff;
  border-top: 1px dashed #e2e8f0;
  text-align: center;
}

.td-mmo-btn-guide {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.td-mmo-btn-guide:hover,
.td-mmo-btn-guide.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.td-mmo-video-wrapper {
  margin-top: 12px;
  width: 100%;
}

.td-mmo-video-inner {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
}

.td-mmo-iframe,
.td-mmo-video-tag {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ── Dark Mode & Color Themes Harmonization ── */
.dark-mode .td-mmo-modal-card,
.theme-dark .td-mmo-modal-card,
.theme-midnight .td-mmo-modal-card,
[data-bs-theme="dark"] .td-mmo-modal-card {
  background: #182234;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.dark-mode .td-mmo-modal-top,
.theme-dark .td-mmo-modal-top,
.theme-midnight .td-mmo-modal-top,
[data-bs-theme="dark"] .td-mmo-modal-top {
  background: #121826;
  border-bottom-color: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.dark-mode .td-mmo-modal-top-title,
.theme-dark .td-mmo-modal-top-title,
.theme-midnight .td-mmo-modal-top-title,
[data-bs-theme="dark"] .td-mmo-modal-top-title {
  color: #f1f5f9;
}

.dark-mode .td-mmo-modal-media,
.theme-dark .td-mmo-modal-media,
.theme-midnight .td-mmo-modal-media,
[data-bs-theme="dark"] .td-mmo-modal-media {
  background: #0f172a;
}

.dark-mode .td-mmo-modal-img,
.theme-dark .td-mmo-modal-img,
.theme-midnight .td-mmo-modal-img,
[data-bs-theme="dark"] .td-mmo-modal-img {
  background-color: #0f172a;
}

.dark-mode .td-mmo-modal-bottom,
.theme-dark .td-mmo-modal-bottom,
.theme-midnight .td-mmo-modal-bottom,
[data-bs-theme="dark"] .td-mmo-modal-bottom {
  background: #182234;
}

.dark-mode .td-mmo-modal-title,
.theme-dark .td-mmo-modal-title,
.theme-midnight .td-mmo-modal-title,
[data-bs-theme="dark"] .td-mmo-modal-title {
  color: #f8fafc;
}

.dark-mode .td-mmo-modal-shop,
.theme-dark .td-mmo-modal-shop,
.theme-midnight .td-mmo-modal-shop,
[data-bs-theme="dark"] .td-mmo-modal-shop {
  color: #94a3b8;
}

.dark-mode .td-mmo-modal-guide-bar,
.theme-dark .td-mmo-modal-guide-bar,
.theme-midnight .td-mmo-modal-guide-bar,
[data-bs-theme="dark"] .td-mmo-modal-guide-bar {
  background: #182234;
  border-top-color: rgba(255, 255, 255, 0.08);
}

.dark-mode .td-mmo-btn-guide,
.theme-dark .td-mmo-btn-guide,
.theme-midnight .td-mmo-btn-guide,
[data-bs-theme="dark"] .td-mmo-btn-guide {
  border-color: #334155;
  color: #cbd5e1;
}

.dark-mode .td-mmo-btn-guide:hover,
.theme-dark .td-mmo-btn-guide:hover,
.theme-midnight .td-mmo-btn-guide:hover,
[data-bs-theme="dark"] .td-mmo-btn-guide:hover {
  background: #38bdf8;
  border-color: #38bdf8;
  color: #0f172a;
}

.dark-mode .td-mmo-qr-box,
.theme-dark .td-mmo-qr-box,
.theme-midnight .td-mmo-qr-box,
[data-bs-theme="dark"] .td-mmo-qr-box {
  background: #ffffff;
}

/* ── Sepia Eye-Comfort Theme ── */
.theme-sepia .td-mmo-modal-card {
  background: #fbf5e8;
  box-shadow: 0 25px 50px -12px rgba(80, 50, 20, 0.25), 0 0 0 1px rgba(80, 50, 20, 0.08);
}
.theme-sepia .td-mmo-modal-top {
  background: #f4ecda;
  border-bottom-color: #e6dcbe;
}
.theme-sepia .td-mmo-modal-bottom,
.theme-sepia .td-mmo-modal-guide-bar {
  background: #fbf5e8;
}
.theme-sepia .td-mmo-modal-title {
  color: #433422;
}

/* ── Backward Compatibility: Inline Teaser Wrap ── */
.td-mmo-gate-container {
  position: relative;
  width: 100%;
  max-width: 850px;
  margin: 0 auto;
}

.td-mmo-teaser-wrap {
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.td-mmo-paywall-active .td-mmo-teaser-wrap {
  max-height: 480px;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,0.85) 45%, rgba(0,0,0,0.3) 75%, rgba(0,0,0,0) 100%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,0.85) 45%, rgba(0,0,0,0.3) 75%, rgba(0,0,0,0) 100%);
}

.td-mmo-teaser-content {
  font-size: 1.15rem;
  line-height: 1.9;
  color: inherit;
  opacity: 0.9;
}

@media (max-width: 540px) {
  .td-mmo-modal-card {
    max-width: 100%;
    border-radius: 18px;
  }
  .td-mmo-modal-title {
    font-size: 17px;
  }
  .td-mmo-qr-box {
    width: 78px;
    height: 78px;
  }
}
