/**
 * Indo Smart Popup Banner Stylesheet
 * File: assets/css/popup-banner.css
 * Zero External Dependencies · Mobile-first · Glassmorphism · Optimized for 4:5 Portrait Banners
 */

:root {
  --indo-popup-red: #b20000;
  --indo-popup-red-hover: #900000;
  --indo-popup-bg-light: #ffffff;
  --indo-popup-bg-dark: #111827;
  --indo-popup-text-dark: #0f172a;
  --indo-popup-text-muted: #64748b;
  --indo-popup-border: rgba(226, 232, 240, 0.8);
  --indo-popup-radius: 16px;
  --indo-popup-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.05);
  --indo-popup-anim-curve: cubic-bezier(0.16, 1, 0.3, 1);
}

/* =========================================================================
   1. OVERLAY & BACKDROP
   ========================================================================= */
.indo-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s var(--indo-popup-anim-curve), visibility 0.32s;
  box-sizing: border-box;
}

.indo-popup-overlay.is-active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.indo-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

/* =========================================================================
   2. POPUP DIALOG CONTAINER (Tối ưu độ rộng gọn gàng cho Banner dọc 4:5)
   ========================================================================= */
.indo-popup-dialog {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px; /* Mặc định 440px gọn gàng, vừa vặn tỷ lệ vàng với poster dọc 4:5 */
  max-height: 90vh;
  background: var(--indo-popup-bg-light);
  border-radius: var(--indo-popup-radius);
  box-shadow: var(--indo-popup-shadow);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  transform: scale(0.94) translateY(12px);
  opacity: 0;
  transition: transform 0.35s var(--indo-popup-anim-curve), opacity 0.3s ease;
  box-sizing: border-box;
}

/* Tùy biến độ rộng qua Admin */
.indo-popup-dialog.indo-width-compact_440 {
  max-width: 440px;
}

.indo-popup-dialog.indo-width-standard_500 {
  max-width: 500px;
}

.indo-popup-dialog.indo-width-wide_580 {
  max-width: 580px;
}

/* Thanh cuộn tinh tế nếu màn hình quá thấp */
.indo-popup-dialog::-webkit-scrollbar {
  width: 4px;
}
.indo-popup-dialog::-webkit-scrollbar-track {
  background: transparent;
}
.indo-popup-dialog::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
  border-radius: 4px;
}

.indo-popup-overlay.is-active .indo-popup-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* =========================================================================
   3. CLOSE BUTTON (Nhỏ gọn, nổi bật trên ảnh banner)
   ========================================================================= */
.indo-popup-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.indo-popup-close-btn:hover {
  background: #ffffff;
  color: var(--indo-popup-red);
  transform: scale(1.08) rotate(90deg);
}

.indo-popup-close-btn:focus-visible {
  outline: 2px solid var(--indo-popup-red);
  outline-offset: 2px;
}

/* =========================================================================
   4. BANNER MEDIA - HIỂN THỊ 100% CỠ ẢNH, KHÔNG BỊ CẮT XÉN (NO CROP)
   ========================================================================= */
.indo-popup-layout {
  display: flex;
  flex-direction: column;
}

.indo-popup-media {
  position: relative;
  width: 100%;
  background: transparent;
  overflow: hidden;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.indo-popup-img-link {
  display: block;
  width: 100%;
  line-height: 0;
}

/* Hiển thị 100% cỡ ảnh banner, không bị crop bất kỳ pixel nào */
.indo-popup-media img {
  width: 100%;
  height: auto;
  max-height: 52vh; /* Không bao giờ chiếm quá 52vh để chừa chỗ cho text & nút CTA */
  object-fit: contain;
  display: block;
  margin: 0 auto;
  transition: transform 0.4s ease;
}

.indo-popup-img-link:hover img {
  transform: scale(1.02);
}

/* Cấu hình đặc thù theo tỷ lệ */
.indo-ratio-portrait_4_5 .indo-popup-media,
.indo-ratio-natural_auto .indo-popup-media {
  aspect-ratio: auto;
}

.indo-ratio-portrait_4_5 .indo-popup-media img,
.indo-ratio-natural_auto .indo-popup-media img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* Dành riêng cho banner ngang 16:9 nếu admin chọn */
.indo-ratio-landscape_16_9 .indo-popup-media {
  aspect-ratio: 16 / 9;
}
.indo-ratio-landscape_16_9 .indo-popup-media img {
  height: 100%;
  object-fit: cover;
}

/* =========================================================================
   5. THU NHỎ TEXT & NỘI DUNG (THANH THOÁT, VỪA VẶN MẮT NHÌN)
   ========================================================================= */
.indo-popup-content {
  padding: 14px 18px 16px; /* Giảm padding gọn gàng */
  text-align: center;
  box-sizing: border-box;
}

.indo-popup-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: 9999px;
  background: rgba(178, 0, 0, 0.08);
  color: var(--indo-popup-red);
  font-size: 11px; /* Thu nhỏ từ 12px */
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.indo-badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--indo-popup-red);
  display: inline-block;
  box-shadow: 0 0 6px rgba(178, 0, 0, 0.6);
}

.indo-popup-title {
  margin: 0 0 6px;
  font-size: 15px; /* Thu nhỏ từ 22px xuống 15px theo đúng yêu cầu */
  line-height: 1.35;
  font-weight: 800;
  color: var(--indo-popup-text-dark);
  letter-spacing: -0.01em;
}

.indo-popup-desc {
  margin: 0 0 12px;
  font-size: 12.5px; /* Thu nhỏ từ 15px xuống 12.5px */
  line-height: 1.45;
  color: var(--indo-popup-text-muted);
}

/* =========================================================================
   6. THU NHỎ NÚT CALL ACTION (CTA)
   ========================================================================= */
.indo-popup-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px; /* Giảm từ 12px */
  width: 100%;
}

.indo-popup-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 18px; /* Thu nhỏ từ 14px 24px xuống 9px 18px */
  border-radius: 8px; /* Bo góc tinh tế */
  background: linear-gradient(135deg, var(--indo-popup-red) 0%, #8b0000 100%);
  color: #ffffff !important;
  font-size: 13.5px; /* Thu nhỏ từ 16px xuống 13.5px */
  font-weight: 700;
  text-decoration: none !important;
  letter-spacing: 0.01em;
  box-shadow: 0 3px 12px rgba(178, 0, 0, 0.32);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-sizing: border-box;
}

.indo-popup-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(178, 0, 0, 0.42);
  filter: brightness(1.05);
  color: #ffffff !important;
}

.indo-popup-cta-btn:active {
  transform: translateY(0);
}

.indo-popup-cta-btn svg {
  width: 15px;
  height: 15px;
  transition: transform 0.2s ease;
}

.indo-popup-cta-btn:hover svg {
  transform: translateX(3px);
}

.indo-popup-dismiss-link {
  background: none;
  border: none;
  padding: 3px 6px;
  color: #94a3b8;
  font-size: 11.5px; /* Thu nhỏ từ 14px xuống 11.5px */
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.indo-popup-dismiss-link:hover {
  color: #475569;
}

/* =========================================================================
   7. DARK MODE SYNCHRONIZATION
   ========================================================================= */
body.dark .indo-popup-dialog,
.dark-page-wrapper .indo-popup-dialog {
  background: var(--indo-popup-bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

body.dark .indo-popup-close-btn,
.dark-page-wrapper .indo-popup-close-btn {
  background: rgba(30, 41, 59, 0.88);
  border-color: rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
}

body.dark .indo-popup-close-btn:hover,
.dark-page-wrapper .indo-popup-close-btn:hover {
  background: #1e293b;
  color: #ffffff;
}

body.dark .indo-popup-title,
.dark-page-wrapper .indo-popup-title {
  color: #f8fafc;
}

body.dark .indo-popup-desc,
.dark-page-wrapper .indo-popup-desc {
  color: #94a3b8;
}

body.dark .indo-popup-dismiss-link,
.dark-page-wrapper .indo-popup-dismiss-link {
  color: #64748b;
}

body.dark .indo-popup-dismiss-link:hover,
.dark-page-wrapper .indo-popup-dismiss-link:hover {
  color: #cbd5e1;
}

/* =========================================================================
   8. MOBILE RESPONSIVE OPTIMIZATIONS (Cân đối trọn vẹn trên màn hình dọc)
   ========================================================================= */
@media (max-width: 640px) {
  .indo-popup-overlay {
    padding: 12px;
    align-items: center; /* Giữ căn giữa tự nhiên, không bị kéo dãn */
    justify-content: center;
  }

  .indo-popup-dialog {
    max-width: 360px; /* Vừa vặn chiều rộng màn hình mobile */
    max-height: 88vh;
    border-radius: 14px;
    transform: scale(0.96) translateY(8px);
  }

  .indo-popup-overlay.is-active .indo-popup-dialog {
    transform: scale(1) translateY(0);
  }

  .indo-popup-media img {
    max-height: 44vh; /* Đảm bảo cả banner dọc + text + CTA nằm trọn trong 1 màn hình */
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  .indo-popup-content {
    padding: 12px 14px 14px;
  }

  .indo-popup-title {
    font-size: 14px;
    margin-bottom: 5px;
  }

  .indo-popup-desc {
    font-size: 12px;
    margin-bottom: 10px;
    line-height: 1.4;
  }

  .indo-popup-cta-btn {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 7px;
  }

  .indo-popup-dismiss-link {
    font-size: 11px;
  }

  .indo-popup-close-btn {
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
  }

  .indo-popup-close-btn svg {
    width: 16px;
    height: 16px;
  }
}
