/**
 * Banner Item Component Styles
 */

/* CSS Variables - Banner CTA Gradients (định nghĩa để đảm bảo hoạt động độc lập) */
:root {
    --gradient-purple: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    --gradient-blue: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    --gradient-green: linear-gradient(135deg, #10b981 0%, #22c55e 100%);
}

/* Video controls - pointer-events auto (fallback khi chưa load variables.css) */
.banner-video-controls {
    pointer-events: auto;
    z-index: calc(var(--z-index-base, 1) + 1);
}

/* Video iframe - pointer-events auto */
.banner-video-iframe {
    pointer-events: auto;
    z-index: calc(var(--z-index-base, 1) + 1);
}

/* Video link overlay - pointer-events none */
.banner-video-link-overlay {
    pointer-events: none;
}

/* Video top click area — vùng clickable phần trên video (không che controls phía dưới) */
.banner-video-top-click-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 75%;
    z-index: calc(var(--z-index-base, 1) + 2);
    cursor: pointer;
    pointer-events: none;
}

/* YouTube click overlay — vùng clickable phần trên iframe (không che controls YouTube) */
.banner-youtube-click-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60%;
    z-index: calc(var(--z-index-base, 1) + 2);
    cursor: pointer;
    pointer-events: auto;
}

/* Thumbnail image - pointer-events none */
.banner-thumbnail-image {
    pointer-events: none;
}

/* Play button overlay - z-index cao (fallback khi chưa load variables.css) */
.banner-play-overlay {
    pointer-events: none;
    z-index: var(--z-index-dropdown, 10);
}

/* Play button - z-index cao hơn overlay */
.banner-play-button {
    pointer-events: auto;
    position: relative;
    z-index: calc(var(--z-index-dropdown, 10) + 1);
}

/* Background link - z-index thấp */
.banner-background-link {
    z-index: var(--z-index-base, 1);
    pointer-events: auto;
}

/* CTA-only horizontal bar: chiều cao cố định (không phụ thuộc Tailwind khi HTML inject từ server) */
.banner-item__cta-bar {
    min-height: 120px;
}

.banner-item__cta-bar--xs {
    height: 80px;
    min-height: 80px;
}

.banner-item__cta-bar--sm {
    height: 120px;
    min-height: 120px;
}

.banner-item__cta-bar--md,
.banner-item__cta-bar--auto {
    height: 180px;
    min-height: 180px;
}

.banner-item__cta-bar--lg {
    height: 240px;
    min-height: 240px;
}

.banner-item__cta-bar--xl {
    height: 320px;
    min-height: 320px;
}

.banner-item__cta-bar--min-height {
    min-height: 120px;
}

/* CTA background styles by cta_style (CSP-safe replacement for inline style) */
.banner-item__cta-bg--primary {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
}

.banner-item__cta-bg--ocean {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 50%, #14b8a6 100%);
}

.banner-item__cta-bg--sunset {
    background: linear-gradient(135deg, #f59e0b 0%, #fb923c 50%, #fbbf24 100%);
}

.banner-item__cta-bg--emerald {
    background: linear-gradient(135deg, #059669 0%, #10b981 50%, #34d399 100%);
}

.banner-item__cta-bg--midnight {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #60a5fa 100%);
}

.banner-item__cta-bg--rose {
    background: linear-gradient(135deg, #be123c 0%, #e11d48 50%, #fb7185 100%);
}

/* Banner image wrapper: chiều cao cố định (không phụ thuộc Tailwind khi HTML inject từ server) */
.banner-item__image-inner {
    min-height: 120px;
}

.banner-item__image-inner--xs {
    height: 80px;
    min-height: 80px;
}

.banner-item__image-inner--sm {
    height: 120px;
    min-height: 120px;
}

.banner-item__image-inner--md,
.banner-item__image-inner--auto {
    height: 180px;
    min-height: 180px;
}

.banner-item__image-inner--lg {
    height: 240px;
    min-height: 240px;
}

.banner-item__image-inner--xl {
    height: 320px;
    min-height: 320px;
}

/* Base text sharpness cho banner-item title/subtitle (1 nguồn: CTA không ảnh + CTA trên ảnh) */
.banner-item__title,
.banner-item__subtitle,
.banner-item__title p,
.banner-item__subtitle p,
.banner-item__title *,
.banner-item__subtitle * {
    text-align: inherit;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-rendering: optimizeLegibility !important;
    transform: none !important;
    filter: none !important;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    isolation: isolate;
    will-change: auto;
}

/* Text shadow khi CTA trên ảnh (overlay) - đọc được trên ảnh */
/* z-index 10: thấp hơn carousel buttons (25) để buttons nhận click */
/* pointer-events: none trên overlay div → click xuyên qua tới buttons bên dưới */
/* pointer-events: auto chỉ trên <a> con → CTA link vẫn clickable */
.banner-item--overlay {
    z-index: 10;
    pointer-events: none;
}

.banner-item--overlay a,
.banner-item--overlay button {
    pointer-events: auto;
}

.banner-item--overlay .banner-item__title,
.banner-item--overlay .banner-item__title p,
.banner-item--overlay .banner-item__title * {
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7), 0 1px 3px rgba(0, 0, 0, 0.5);
}

.banner-item--overlay .banner-item__subtitle,
.banner-item--overlay .banner-item__subtitle p,
.banner-item--overlay .banner-item__subtitle * {
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Đảm bảo banner horizontal luôn dùng flex-row trên desktop */
/* IMPORTANT: Phải có specificity cao và !important để override Tailwind */
/* Sử dụng selector với nhiều class để tăng specificity */
.banner-item--overlay.banner-item__horizontal-mobile-vertical,
.banner-item__horizontal-mobile-vertical {
    /* Desktop: giữ nguyên flex-row (được set từ template) */
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
}

/* Đảm bảo child elements cũng dùng flex-row trên desktop */
.banner-item__horizontal-mobile-vertical>div:first-child,
.banner-item__horizontal-mobile-vertical>a>div:first-child {
    flex-direction: row !important;
    align-items: center !important;
    text-align: left !important;
    flex: 1 !important;
    width: auto !important;
    margin-bottom: 0 !important;
}

/* Đảm bảo link wrapper (image+overlay mode) dùng flex-row trên desktop */
/* BUG FIX: Phải có display: flex để flex-direction có tác dụng */
.banner-item__horizontal-mobile-vertical>a {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
}

/* Đảm bảo button luôn bám sát mép phải banner horizontal trên desktop */
.banner-item__horizontal-mobile-vertical>div:last-child,
.banner-item__horizontal-mobile-vertical>a>div:last-child {
    margin-left: auto !important;
}

/* Responsive: Horizontal banner trên mobile chuyển về vertical */
@media (max-width: 639px) {

    /* Banner horizontal trên mobile: chuyển về flex-col */
    .banner-item__horizontal-mobile-vertical {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding: 1rem !important;
        gap: 0.75rem !important;
    }

    .banner-item__horizontal-mobile-vertical>div:first-child {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        margin-bottom: 0 !important;
        gap: 0.5rem !important;
        flex: none !important;
        width: 100% !important;
    }

    /* Image+overlay mode: <a> bên trong overlay cũng phải chuyển flex-col trên mobile */
    .banner-item__horizontal-mobile-vertical>a {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 0.75rem !important;
    }

    .banner-item__horizontal-mobile-vertical>a>div:first-child {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 0.5rem !important;
        flex: none !important;
        width: 100% !important;
    }

    .banner-item__horizontal-mobile-vertical .banner-item__title {
        text-align: center !important;
        font-size: 0.875rem !important;
    }

    .banner-item__horizontal-mobile-vertical .banner-item__subtitle {
        text-align: center !important;
        font-size: 0.75rem !important;
    }

    .banner-item__horizontal-mobile-vertical .banner-item__cta-btn {
        width: 100% !important;
        max-width: 100% !important;
        justify-content: center !important;
        margin-left: 0 !important;
        margin-top: 0.5rem !important;
    }

    /* Icon responsive */
    .banner-item__horizontal-mobile-vertical>div:first-child>div:first-child {
        font-size: 1.5rem !important;
    }
}

/* Theme chữ cho banner-item CTA - override mọi nguồn (prose, tailwind, inherit) */
.banner-item--dark .banner-item__title,
.banner-item--dark .banner-item__title *,
.banner-item--dark .banner-item__subtitle,
.banner-item--dark .banner-item__subtitle *,
.prose .banner-item--dark .banner-item__title,
.prose .banner-item--dark .banner-item__title *,
.prose .banner-item--dark .banner-item__subtitle,
.prose .banner-item--dark .banner-item__subtitle * {
    color: #fff !important;
}

.banner-item--light .banner-item__title,
.banner-item--light .banner-item__title *,
.prose .banner-item--light .banner-item__title,
.prose .banner-item--light .banner-item__title * {
    color: #1e293b !important;
}

.banner-item--light .banner-item__subtitle,
.banner-item--light .banner-item__subtitle *,
.prose .banner-item--light .banner-item__subtitle,
.prose .banner-item--light .banner-item__subtitle * {
    color: #475569 !important;
}

/* =================================================================
   Ad label - Đồng nhất cho TẤT CẢ banners (Google Ads compliance)
   Tuân thủ: https://support.google.com/adspolicy/answer/6020955
   - Text "Ad" (tiếng Anh) → Googlebot nhận diện chính xác
   - Nhỏ gọn, không ảnh hưởng UI, không gây nhầm lẫn nội dung
   ================================================================= */
/* Wrapper cho Ad label + Banner content — relative context cho absolute ad label */
.banner-item-wrapper {
    position: relative;
}

.banner-ad-label {
    position: absolute;
    top: 2px;
    left: 2px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 2px;
    padding: 1px 4px;
    line-height: 1;
    margin: 0;
    pointer-events: none;
}

.banner-ad-label span {
    font-size: 0.5rem;
    /* 8px — "Ad" chỉ 2 ký tự nên nhỏ hơn vẫn đọc được */
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    line-height: 1;
    display: inline-block;
    pointer-events: none;
    user-select: none;
}

/* Nút CTA - dùng chung cho CTA không ảnh và CTA trên ảnh (1 nguồn).
   Dùng em để scale theo font-size của banner → CTA nhỏ hơn khi banner trong cột hẹp (ad-block__container--narrow). */
.banner-item__cta-btn {
    height: auto;
    min-height: 2em;
    padding: 0.375em 0.75em;
    font-size: 1em;
    border-radius: 0.5rem;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    transition: box-shadow 0.2s ease, background 0.2s ease;
    /* Text sharpness - no filter/transform to avoid blur */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Size variants - Horizontal banner heights (dùng em để scale đồng bộ với narrow container) */
.banner-item__cta-btn--size-xs {
    height: 2em;
    min-height: 1.75em;
    padding: 0 0.5em;
    font-size: 0.85em;
}

.banner-item__cta-btn--size-sm {
    height: 2.25em;
    min-height: 1.875em;
    padding: 0 0.5em;
    font-size: 0.85em;
}

/* =================================================================
   6 COMBO CTA - Nền + chữ + nút đồng bộ, tương phản tốt (xem docs/banner_layout_preview.html)
   Nút: nền trắng, chữ màu brand → dễ đọc trên mọi gradient nền
   ================================================================= */

.banner-item__cta-btn--primary {
    background: #fff;
    color: #4f46e5;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.banner-item__cta-btn--ocean {
    background: #fff;
    color: #0e7490;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.35);
}

.banner-item__cta-btn--sunset {
    background: #fff;
    color: #b45309;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.banner-item__cta-btn--emerald {
    background: #fff;
    color: #047857;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
}

.banner-item__cta-btn--midnight {
    background: #fff;
    color: #1e3a8a;
    box-shadow: 0 4px 15px rgba(30, 58, 138, 0.35);
}

.banner-item__cta-btn--rose {
    background: #fff;
    color: #b91c1c;
    box-shadow: 0 4px 15px rgba(225, 29, 72, 0.35);
}

.banner-item__cta-btn--primary:hover,
.banner-item__cta-btn--ocean:hover,
.banner-item__cta-btn--sunset:hover,
.banner-item__cta-btn--emerald:hover,
.banner-item__cta-btn--midnight:hover,
.banner-item__cta-btn--rose:hover {
    filter: brightness(0.98);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

/* === CTA Below Image (non-horizontal banners: inline, content, sidebar) === */
/* Khi banner có ảnh + CTA, CTA hiển thị phía dưới ảnh thay vì overlay */
.banner-item--cta-below {
    transition: filter 0.2s ease;
    text-decoration: none;
    /* Text sharpness */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.banner-item--cta-below:hover {
    filter: brightness(1.05);
}

.banner-item--image-cta-below {
    border-radius: 0.5rem;
    overflow: hidden;
    /* Shadow nhẹ cho card */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
}

.banner-item--image-cta-below:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* =================================================================
   Banner Carousel — Nhiều ảnh với nút ‹ › (chỉ horizontal)
   Ảnh fade transition, CTA overlay giữ nguyên không đổi.
   ================================================================= */
.banner-carousel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.banner-carousel__slide {
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
    pointer-events: none;
}

.banner-carousel__slide--active {
    opacity: 1;
    pointer-events: auto;
}

/* Nút ‹ › — nhỏ gọn, bán trong suốt, 2 bên banner */
/* z-index 25 > CTA overlay (10) để nhận click */
.banner-carousel__btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 25;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 0;
    outline: none;
}

/* Hiện nút khi hover container (group hover) */
.group:hover .banner-carousel__btn,
.banner-carousel__btn:focus-visible {
    opacity: 1;
}

.banner-carousel__btn:hover {
    background: rgba(0, 0, 0, 0.55);
}

.banner-carousel__btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.banner-carousel__btn--prev {
    left: 6px;
}

.banner-carousel__btn--next {
    right: 6px;
}

/* Dots indicator — nhỏ gọn, nằm dưới cùng trong banner */
/* z-index 25 > CTA overlay (10) để nhận click */
.banner-carousel__dots {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.group:hover .banner-carousel__dots {
    opacity: 1;
}

.banner-carousel__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.banner-carousel__dot--active {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.25);
}

.banner-carousel__dot:hover {
    background: rgba(255, 255, 255, 0.75);
}

/* Mobile: nút và dots luôn hiện (không có hover) */
@media (max-width: 639px) {
    .banner-carousel__btn {
        opacity: 0.7;
        width: 24px;
        height: 24px;
        font-size: 0.875rem;
    }

    .banner-carousel__dots {
        opacity: 0.8;
    }

    .banner-carousel__dot {
        width: 5px;
        height: 5px;
    }
}
