/* ─── Fancy Media Gallery v3.3.0 ─── */

.fancy-media-gallery {
    margin: 20px 0;
}

/* ─── Tabs ───────────────────────────────────── */

.fmg-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.fmg-tab {
    background: #ebebeb;
    border: none;
    padding: 12px 24px;
    margin-right: 2px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: #666;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    position: relative;
}

.fmg-tab:hover {
    background-color: #e8e8e8;
    color: #333;
}

.fmg-tab.active {
    background-color: #ff7a00;
    color: white;
    border-bottom: 2px solid #ff7a00;
}

.fmg-tab.active:hover {
    background-color: #e66a00;
}

.fmg-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #ff7a00;
}

/* ─── Count badge (single definition) ────────── */

.fmg-count {
    background: rgba(0, 0, 0, 0.1);
    color: inherit;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 500;
    margin-left: 6px;
    display: inline-block;
    min-width: 18px;
    text-align: center;
    line-height: 1;
    vertical-align: middle;
}

.fmg-tab.active .fmg-count {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.fmg-tab:hover .fmg-count {
    background: #555;
    color: white;
}

.fmg-tab.active:hover .fmg-count {
    background: rgba(255, 255, 255, 0.4);
}

/* ─── Tab Content ────────────────────────────── */

.fmg-tab-content {
    display: none;
    animation: fmg-fadeIn 0.3s ease-in-out;
}

.fmg-tab-content.active {
    display: block;
}

@keyframes fmg-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Video Grid ─────────────────────────────── */

.fmg-videos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 0;
    padding: 0;
}

.fmg-videos-grid .fmg-item {
    position: relative;
    overflow: hidden;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #f5f5f5;
}

.fmg-videos-grid .fmg-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.fmg-videos-grid .fmg-item a {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.fmg-videos-grid .fmg-item img,
.fmg-videos-grid .fmg-item picture,
.fmg-videos-grid .fmg-item picture img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.fmg-videos-grid .fmg-item picture {
    height: 200px;
    overflow: hidden;
}

.fmg-videos-grid .fmg-item:hover img {
    transform: scale(1.05);
}

/* ─── Play Overlay ───────────────────────────── */

.fmg-video-item .fmg-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fmg-video-item:hover .fmg-play-overlay {
    opacity: 1;
}

.fmg-play-icon {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #333;
    transition: transform 0.3s ease;
}

.fmg-video-item:hover .fmg-play-icon {
    transform: scale(1.1);
}

/* ─── Stream indicator badge ─────────────────── */

.fmg-stream-indicator {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fmg-video-item[data-video-type="hls"] .fmg-stream-indicator {
    background: rgba(220, 53, 69, 0.9);
}

.fmg-video-item[data-video-type="dash"] .fmg-stream-indicator {
    background: rgba(40, 167, 69, 0.9);
}

.fmg-video-item[data-video-type="mp4"] .fmg-stream-indicator {
    display: none;
}

.fmg-video-item[data-video-type="hls"] .fmg-play-icon,
.fmg-video-item[data-video-type="dash"] .fmg-play-icon {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 20px;
}

/* ─── Loading state ──────────────────────────── */

.fmg-item img.lazy {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: fmg-loading 1.5s infinite;
}

@keyframes fmg-loading {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Empty state ────────────────────────────── */

.fmg-grid:empty::after {
    content: 'Không có nội dung để hiển thị';
    display: block;
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 40px;
}

/* ─── Video.js Modal ─────────────────────────── */

#fmg-videojs-modal {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

#fmg-videojs-modal .video-js {
    font-size: 14px;
    color: #fff;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
}

#fmg-videojs-container {
    position: relative;
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease-in-out;
}

#fmg-videojs-container .video-js {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* ─── Video.js Controls ──────────────────────── */

#fmg-videojs-modal .video-js .vjs-control-bar {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 0 0 8px 8px;
}

#fmg-videojs-modal .video-js .vjs-big-play-button {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    font-size: 3em;
    line-height: 1.5;
    height: 1.5em;
    width: 1.5em;
    transition: all 0.3s ease;
}

#fmg-videojs-modal .video-js:hover .vjs-big-play-button {
    background: rgba(255, 122, 0, 0.9);
    border-color: #fff;
    transform: scale(1.1);
}

#fmg-videojs-modal .video-js .vjs-progress-control .vjs-progress-holder { background: rgba(255,255,255,0.3); border-radius: 2px; }
#fmg-videojs-modal .video-js .vjs-play-progress { background: #ff7a00; border-radius: 2px; }
#fmg-videojs-modal .video-js .vjs-load-progress { background: rgba(255,255,255,0.4); border-radius: 2px; }
#fmg-videojs-modal .video-js .vjs-volume-bar { background: rgba(255,255,255,0.3); border-radius: 2px; }
#fmg-videojs-modal .video-js .vjs-volume-level { background: #ff7a00; border-radius: 2px; }
#fmg-videojs-modal .video-js .vjs-fullscreen-control:hover { color: #ff7a00; }

#fmg-videojs-modal .video-js .vjs-loading-spinner {
    border-color: rgba(255, 122, 0, 0.3);
    border-top-color: #ff7a00;
}

#fmg-videojs-modal .video-js .vjs-error-display {
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    border-radius: 8px;
}

/* ─── Close button ───────────────────────────── */

#fmg-videojs-close {
    transition: all 0.3s ease;
}

#fmg-videojs-close:hover {
    transform: scale(1.1);
    background: rgba(255, 41, 41, 0.9) !important;
}

#fmg-videojs-close:focus,
#fmg-videojs-modal .video-js button:focus {
    outline: 2px solid #ff7a00;
    outline-offset: 2px;
}

/* ─── Quality selector ───────────────────────── */

.vjs-quality-selector .vjs-menu { background: rgba(0,0,0,0.9); border-radius: 4px; }
.vjs-quality-selector .vjs-menu-item { color: #fff; padding: 0.5em 1em; }
.vjs-quality-selector .vjs-menu-item:hover { background: rgba(255,122,0,0.8); }

/* ═══ Responsive ═════════════════════════════════ */

@media (max-width: 768px) {
    .fmg-videos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .fmg-videos-grid .fmg-item img,
    .fmg-videos-grid .fmg-item picture,
    .fmg-videos-grid .fmg-item picture img {
        height: 150px;
    }
    
    .fmg-tab {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .fmg-count {
        font-size: 0.7em;
        margin-left: 3px;
    }
    
    /* Play overlay on mobile — visible on touch */
    .fmg-video-item .fmg-play-overlay {
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .fmg-video-item:hover .fmg-play-overlay,
    .fmg-video-item:active .fmg-play-overlay,
    .fmg-video-item:focus-within .fmg-play-overlay {
        opacity: 1;
    }
    
    .fmg-play-icon {
        width: 50px;
        height: 50px;
        font-size: 18px;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .fmg-stream-indicator {
        font-size: 8px;
        padding: 1px 4px;
    }
    
    /* Video.js modal mobile */
    #fmg-videojs-modal { padding: 10px; }
    
    #fmg-videojs-modal .video-js .vjs-big-play-button {
        font-size: 2.5em;
        height: 1.2em;
        width: 1.2em;
    }
    
    #fmg-videojs-modal .video-js .vjs-control-bar {
        font-size: 1.2em;
        height: 2.5em;
    }
    
    #fmg-videojs-close {
        top: -10px !important;
        right: -10px !important;
        width: 32px !important;
        height: 32px !important;
    }
    
    #fmg-videojs-close span {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .fmg-videos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .fmg-videos-grid .fmg-item img,
    .fmg-videos-grid .fmg-item picture,
    .fmg-videos-grid .fmg-item picture img {
        height: 120px;
    }
    
    .fmg-tabs { margin-bottom: 15px; }
    
    .fmg-tab {
        padding: 8px 12px;
        font-size: 13px;
        flex: 1;
        text-align: center;
        margin-right: 1px;
    }
    
    .fmg-play-icon {
        width: 35px !important;
        height: 35px !important;
        font-size: 14px !important;
    }
    
    #fmg-videojs-modal { padding: 5px; }
    
    #fmg-videojs-modal .video-js .vjs-big-play-button {
        font-size: 2em;
        height: 1em;
        width: 1em;
    }
    
    #fmg-videojs-close {
        top: -8px !important;
        right: -8px !important;
        width: 28px !important;
        height: 28px !important;
    }
}

/* ─── Landscape mobile ───────────────────────── */

@media (max-width: 768px) and (orientation: landscape) {
    #fmg-videojs-modal { padding: 5px; }
    #fmg-videojs-close { top: 5px !important; right: 5px !important; }
}

/* ─── High DPI ───────────────────────────────── */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #fmg-videojs-modal .video-js .vjs-big-play-button { border-width: 1px; }
    .fmg-stream-indicator { border: 0.5px solid rgba(255, 255, 255, 0.2); }
}

/* ─── Dark mode ──────────────────────────────── */

@media (prefers-color-scheme: dark) {
    #fmg-videojs-modal { background: rgba(0, 0, 0, 0.95); }
}
