/*
 * IW Promotion New — Figma 407:3227 (desktop) / 407:2536 (mobile).
 *
 * Scope: .iw-promotion (block) + .iw-promotion-item (card). Block bg + price
 * accent come from inline --iw-promo-bg / --iw-promo-accent (editor colorpicker).
 *
 * Layout switch:
 *   --static  (<=3 items): .iw-promotion__track = flex row, slides flex:1.
 *   --slider  (>3 items) : Swiper controls widths (init in iw-promotion.js).
 *   mobile (<992px)      : always column stack; --hide-mobile cards display:none.
 */

.iw-promotion {
  --iw-promo-bg: #ff730a;
  --iw-promo-accent: #ff730a;
}

.iw-promotion__inner {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px;
  border-radius: 16px;
  background: var(--iw-promo-bg);
}

/* Kiểu nền = ảnh: phủ ảnh cover lên màu nền (màu vẫn là fallback). */
.iw-promotion--bg-image .iw-promotion__inner {
  background-image: var(--iw-promo-bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Decorative corner glow (top-right) — nền của cụm icon. Figma 407:3230. */
.iw-promotion__decor {
  position: absolute;
  top: 0;
  right: 0;
  width: 111px;
  height: 111px;
  border-top-right-radius: 16px;
  border-bottom-left-radius: 9999px;
  background:
    linear-gradient(154deg, rgba(251, 187, 30, 0) 60%, rgba(251, 187, 30, 0.6) 100%),
    rgba(255, 255, 255, 0.1);
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

/* Cụm thiết bị (camera + router) đè lên glow. Figma 407:3231/3232. */
.iw-promotion__decor-img {
  position: absolute;
  top: 0;
  right: 0;
  width: 123px;
  height: auto;
  pointer-events: none;
  z-index: 1;
}

.iw-promotion__title,
.iw-promotion__cards,
.iw-promotion__actions,
.iw-promotion__note {
  position: relative;
  z-index: 1;
}

.iw-promotion__title {
  margin: 0;
  padding-left: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 40px;
  line-height: 1.2;
  color: #fff;
}

/* ───────────────────────── Cards track ───────────────────────── */

.iw-promotion__cards {
  width: 100%;
}

/* Static (<=3): equal-width flex columns. */
.iw-promotion--static .iw-promotion__track {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.iw-promotion--static .iw-promotion__track > .iw-promotion-item {
  flex: 1 1 0;
  min-width: 0;
}

/* ───────────────────────── Item card ───────────────────────── */

.iw-promotion-item {
  position: relative;
  overflow: hidden;
  display: flex;
  height: auto;
  padding: 24px;
  border-radius: 8px;
  box-sizing: border-box;
}

.iw-promotion-item__body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

/* Ảnh trang trí góc phải-dưới (Figma 407:3292) + nền bo tròn mờ. */
.iw-promotion-item__decor-bg {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.05);
  border-top-left-radius: 999px;
  border-bottom-right-radius: 8px;
  pointer-events: none;
  z-index: 0;
}

.iw-promotion-item__image {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 91px;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  z-index: 0;
}

.iw-promotion-item--white {
  background: #fff;
}

.iw-promotion-item--glass {
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(12px);
}

.iw-promotion-item__pkg {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.iw-promotion-item__pkg-head {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.iw-promotion-item__check {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 22px;
}

.iw-promotion-item__pkg-name {
  font-weight: 600;
  font-size: 16px;
  line-height: 22px;
  color: #3d3d3d;
}

.iw-promotion-item__pkg-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.iw-promotion-item__pkg-from {
  font-size: 16px;
  line-height: 24px;
  color: #888;
}

.iw-promotion-item__pkg-value {
  font-weight: 700;
  font-size: 20px;
  line-height: 28px;
  /* Màu giá hardcode (không phụ thuộc màu nền section). Card trắng = cam,
     card glass override = trắng (xem rule .iw-promotion-item--glass bên dưới). */
  color: #ff730a;
}

.iw-promotion-item__divider {
  width: 100%;
  height: 0;
  margin: 0;
  border: 0;
  opacity: 1;
  border-top: 1px dashed #e7e7e7; /* Figma 407:3252 — đường gạch nhạt giữa 2 gói. */
}

/* Glass variant text → white. */
.iw-promotion-item--glass .iw-promotion-item__pkg-name,
.iw-promotion-item--glass .iw-promotion-item__pkg-value,
.iw-promotion-item--glass .iw-promotion-item__editor-title,
.iw-promotion-item--glass .iw-promotion-item__editor-body {
  color: #fff;
}

.iw-promotion-item--glass .iw-promotion-item__pkg-from {
  color: rgba(255, 255, 255, 0.8);
}

.iw-promotion-item--glass .iw-promotion-item__divider {
  border-top-color: rgba(255, 255, 255, 0.2);
}

/* Editor mode: tiêu đề (icon + text) + rich body. */
.iw-promotion-item__editor-head {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.iw-promotion-item__editor-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 20px;
  color: #3d3d3d;
}

.iw-promotion-item__editor-body {
  /* Hardcode size — không cho Typography panel của text-editor overwrite. */
  font-size: 16px !important;
  line-height: 24px;
  color: #3d3d3d;
  /* Scroll khi vượt quá 5 dòng (5 × 24px). */
  max-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Scrollbar mảnh cho vùng nội dung tràn. */
.iw-promotion-item__editor-body::-webkit-scrollbar {
  width: 4px;
}
.iw-promotion-item__editor-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
}
.iw-promotion-item--glass .iw-promotion-item__editor-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
}

/* Ép mọi element con (span style="font-size:..%" do TinyMCE chèn) inherit về
   16px — author !important thắng inline style không-!important. */
.iw-promotion-item__editor-body * {
  font-size: inherit !important;
}

.iw-promotion-item__editor-body > :first-child { margin-top: 0; }
.iw-promotion-item__editor-body > :last-child { margin-bottom: 0; }

.iw-promotion-item__editor-body p {
  margin: 0 0 4px;
}

.iw-promotion-item__editor-body ul,
.iw-promotion-item__editor-body ol {
  margin: 0;
  padding-left: 0;
}

.iw-promotion-item__editor-body li {
  margin: 0;
  padding: 0;
  line-height: 24px;
}

.iw-promotion-item__editor-body a {
  color: inherit;
  text-decoration: underline;
}

/* ───────────────────────── Actions ───────────────────────── */

.iw-promotion__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.iw-promotion__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 250px;
  max-width: 100%;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 510;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.iw-promotion__btn--register {
  background: #4564ed;
  color: #fff;
}

.iw-promotion__btn--register:hover {
  background: #3a52c4;
  color: #fff;
}

.iw-promotion__btn--call {
  background: #f3f3f3;
  color: #4564ed;
}

.iw-promotion__btn--call:hover {
  background: #e7e7e7;
  color: #4564ed;
}

.iw-promotion__note {
  margin: 0;
  font-style: italic;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  color: #fff;
}

/* ───────────────────────── Slider (Swiper) ───────────────────────── */

/* Pagination dots — trắng (style giống iw-banner-slider). */
.iw-promotion__pagination {
  position: relative;
  margin-top: 30px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.iw-promotion__pagination .swiper-pagination-bullet {
  width: 8px;
  height: 8px;
  background: #fff;
  opacity: 0.6;
}

.iw-promotion__pagination .swiper-pagination-bullet-active {
  width: 24px;
  border-radius: 999px;
  opacity: 1;
}

/* Nav arrows — tròn, nền tối, trắng (style giống iw-banner-slider__nav).
   Anchor vào .iw-promotion__cards (.swiper, position:relative), đặt sát mép
   trái/phải cards → nằm gọn trong __inner, không bị overflow:hidden cắt. */
.iw-promotion__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  z-index: 3;
  transition: background-color 0.2s ease;
}

.iw-promotion__nav--prev { left: 8px; right: auto; }
.iw-promotion__nav--next { right: 8px; left: auto; }

.iw-promotion__nav:hover,
.iw-promotion__nav:focus-visible {
  background: rgba(0, 0, 0, 0.55);
}

.iw-promotion__nav::after {
  font-size: 16px;
  font-weight: 700;
}

/* Swiper draws slides via inline width; keep equal heights. */
.iw-promotion--slider .iw-promotion-item,
.iw-promotion--slider .swiper-slide {
  height: auto;
}

/* ───────────────────────── Responsive ───────────────────────── */

@media (max-width: 991px) {
  .iw-promotion__inner {
    gap: 8px;
    padding: 12px 8px;
  }

  .iw-promotion__title {
    font-size: 20px;
    line-height: 28px;
    /* Chừa chỗ cho cụm icon góc phải (123px) → text rơi dòng, không bị cắt. */
    padding-right: 116px;
  }

  /* Force column stack regardless of static/slider (swiper destroyed on mobile). */
  .iw-promotion__track {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px;
    transform: none !important;
  }

  .iw-promotion__track > .iw-promotion-item {
    width: 100% !important;
    margin: 0 !important;
    flex: none !important;
  }

  .iw-promotion-item {
    padding: 16px;
  }

  .iw-promotion-item--hide-mobile {
    display: none !important;
  }

  .iw-promotion-item__pkg-value {
    font-size: 16px;
    line-height: 22px;
  }

  .iw-promotion-item__pkg-from {
    font-size: 14px;
  }

  .iw-promotion__actions {
    flex-direction: column;
  }

  .iw-promotion__btn {
    width: 100%;
  }

  /* Hide nav arrows on mobile (no swiper). */
  .iw-promotion__nav {
    display: none !important;
  }
}
