/* ==========================================================================
   CBQ Article Media Engine: Photo Galleries (Smart Collage, Slider, Grid) & Direct HTML5 Video
   ========================================================================== */

.cbq-article-gallery {
    margin: 1.5rem 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
    position: relative;
    user-select: none;
}

.cbq-gal-header-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px 8px 6px;
    font-size: 0.78rem;
    color: #475569;
    font-weight: 600;
}

.cbq-gal-header-badge .cbq-gal-count-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.74rem;
    font-weight: 700;
}

.cbq-gal-header-badge .cbq-gal-viewall-btn {
    background: none;
    border: none;
    color: #0284c7;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.15s;
}
.cbq-gal-header-badge .cbq-gal-viewall-btn:hover {
    background: #e0f2fe;
}

/* Reset article-body img rules inside gallery */
.cbq-article-gallery img.cbq-gal-img {
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    transition: transform 0.35s ease;
    cursor: zoom-in;
}

.cbq-gal-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    background: #e2e8f0;
    cursor: pointer;
}
.cbq-gal-item:hover img.cbq-gal-img {
    transform: scale(1.04);
}

/* 1. Smart Album Collage Layout (data-layout="smart") */
.cbq-gal-smart {
    display: grid;
    gap: 8px;
}
.cbq-gal-smart.count-1 {
    grid-template-columns: 1fr;
}
.cbq-gal-smart.count-1 .cbq-gal-item {
    aspect-ratio: 16 / 10;
    max-height: 440px;
}
.cbq-gal-smart.count-2 {
    grid-template-columns: repeat(2, 1fr);
}
.cbq-gal-smart.count-2 .cbq-gal-item {
    aspect-ratio: 4 / 3;
}
.cbq-gal-smart.count-3 {
    grid-template-columns: 1.35fr 1fr;
    grid-template-rows: repeat(2, 185px);
}
.cbq-gal-smart.count-3 .cbq-gal-item:first-child {
    grid-row: 1 / span 2;
    height: 100%;
}
.cbq-gal-smart.count-4 {
    grid-template-columns: repeat(2, 1fr);
}
.cbq-gal-smart.count-4 .cbq-gal-item {
    aspect-ratio: 16 / 11;
}

/* 2. Uniform Grid Layouts (grid-2, grid-3) */
.cbq-gal-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.cbq-gal-grid-2 .cbq-gal-item {
    aspect-ratio: 4 / 3;
}

.cbq-gal-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.cbq-gal-grid-3 .cbq-gal-item {
    aspect-ratio: 4 / 3;
}

/* +N More Photos Overlay Badge */
.cbq-gal-more-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.68);
    backdrop-filter: blur(2px);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.55rem;
    letter-spacing: -0.5px;
    transition: background 0.2s;
    z-index: 2;
}
.cbq-gal-more-overlay span.cbq-gal-more-sub {
    font-size: 0.76rem;
    font-weight: 600;
    opacity: 0.92;
    margin-top: 2px;
    background: rgba(255, 255, 255, 0.18);
    padding: 2px 10px;
    border-radius: 99px;
}
.cbq-gal-item:hover .cbq-gal-more-overlay {
    background: rgba(15, 23, 42, 0.55);
}

/* 3. Carousel / Slider Layout (data-layout="slider") */
.cbq-gal-slider-wrap {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #0f172a;
}
.cbq-gal-slider-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 460px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cbq-gal-slider-stage img.cbq-gal-img {
    object-fit: contain !important;
    background: #0f172a;
}
.cbq-gal-slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.65);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    transition: all 0.2s;
    font-size: 1rem;
}
.cbq-gal-slider-nav:hover {
    background: #f59e0b;
    color: #fff;
}
.cbq-gal-slider-nav.prev { left: 10px; }
.cbq-gal-slider-nav.next { right: 10px; }

.cbq-gal-slider-counter {
    position: absolute;
    bottom: 10px;
    right: 12px;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    z-index: 3;
}

.cbq-gal-thumbs-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 4px 2px 4px;
    scrollbar-width: thin;
}
.cbq-gal-thumb-btn {
    width: 62px;
    height: 46px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    padding: 0;
    flex-shrink: 0;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.18s;
    background: #cbd5e1;
}
.cbq-gal-thumb-btn.active,
.cbq-gal-thumb-btn:hover {
    opacity: 1;
    border-color: #f59e0b;
}

/* Gallery Caption */
.cbq-gal-caption {
    text-align: center;
    font-size: 0.84rem;
    color: #475569;
    font-style: italic;
    margin-top: 8px;
    padding: 2px 8px;
}

/* Direct HTML5 & Embedded Video Block (.cbq-article-video) */
.cbq-article-video {
    margin: 1.5rem 0;
    background: #0f172a;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    border: 1px solid #1e293b;
    width: 100%;
    max-width: 100%;
    transform: translateZ(0);
}
.cbq-video-stage {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: #000;
    overflow: hidden;
    display: block;
}
.cbq-video-stage video.cbq-video-player,
.article-body video {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 500px;
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto !important;
    background: #000;
    outline: none;
    border: 0 !important;
    border-radius: 0 !important;
}
.cbq-video-stage .cbq-video-iframe-wrap {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-top: 56.25% !important; /* Chuẩn khung 16:9 trên cả máy tính và di động */
    height: 0 !important;
    overflow: hidden !important;
    background: #000;
}
.cbq-video-stage .cbq-video-iframe-wrap iframe,
.article-body .cbq-article-video iframe,
.cbq-article-video iframe.cbq-video-embed-iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    display: block !important;
}
.cbq-video-caption {
    background: #f8fafc;
    color: #475569;
    font-size: 0.84rem;
    font-style: italic;
    text-align: center;
    padding: 8px 12px;
    border-top: 1px solid #e2e8f0;
}

/* Editor-only floating toolbar inside Quill (.ql-editor) */
.cbq-editor-block-toolbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    background: #1e293b;
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.76rem;
    font-style: normal;
}
.ql-editor .cbq-article-gallery .cbq-editor-block-toolbar,
.ql-editor .cbq-article-video .cbq-editor-block-toolbar {
    display: flex;
}
.cbq-editor-block-toolbar .btn-cbq-tool {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.cbq-editor-block-toolbar .btn-cbq-tool:hover,
.cbq-editor-block-toolbar .btn-cbq-tool.active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
}
.cbq-editor-block-toolbar .btn-cbq-tool.danger:hover {
    background: #ef4444;
    border-color: #ef4444;
}

/* Fullscreen Lightbox for Article Galleries & Images */
.cbq-lightbox-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(9, 13, 22, 0.94);
    backdrop-filter: blur(6px);
    z-index: 99999;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    user-select: none;
}
.cbq-lightbox-backdrop.open {
    display: flex;
}
.cbq-lb-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    color: #f8fafc;
    background: linear-gradient(180deg, rgba(0,0,0,0.6), transparent);
}
.cbq-lb-counter {
    font-weight: 700;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.12);
    padding: 4px 12px;
    border-radius: 99px;
}
.cbq-lb-close {
    background: rgba(255,255,255,0.14);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}
.cbq-lb-close:hover {
    background: #ef4444;
}
.cbq-lb-stage {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 56px;
    min-height: 0;
}
.cbq-lb-stage img {
    max-width: 100%;
    max-height: 76vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.cbq-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.cbq-lb-nav:hover {
    background: #f59e0b;
}
.cbq-lb-nav.prev { left: 14px; }
.cbq-lb-nav.next { right: 14px; }
.cbq-lb-bottom {
    padding: 10px 16px 16px;
    background: linear-gradient(0deg, rgba(0,0,0,0.75), transparent);
    text-align: center;
}
.cbq-lb-caption {
    color: #e2e8f0;
    font-size: 0.88rem;
    margin-bottom: 8px;
}
.cbq-lb-thumbs {
    display: flex;
    gap: 8px;
    justify-content: center;
    overflow-x: auto;
    padding-bottom: 4px;
}
.cbq-lb-thumbs img {
    width: 58px;
    height: 42px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
    opacity: 0.55;
    cursor: pointer;
    transition: all 0.18s;
}
.cbq-lb-thumbs img.active,
.cbq-lb-thumbs img:hover {
    opacity: 1;
    border-color: #f59e0b;
}

@media (max-width: 767.98px) {
    .cbq-article-video {
        margin: 1rem 0;
        border-radius: 10px;
    }
    .cbq-video-stage video.cbq-video-player,
    .article-body video {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 58vh;
        object-fit: contain !important;
    }
    .cbq-gal-smart.count-3 {
        grid-template-rows: repeat(2, 130px);
    }
    .cbq-gal-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .cbq-lb-stage {
        padding: 6px 12px;
    }
    .cbq-lb-nav {
        width: 38px;
        height: 38px;
        font-size: 1.05rem;
    }
    .cbq-lb-nav.prev { left: 8px; }
    .cbq-lb-nav.next { right: 8px; }
}
