/* ============================================================
   VIDEO TABS GENERATOR — frontend stylesheet
   Built around CSS custom properties. Override via Custom CSS.
   ============================================================ */

.vtg-tabs,
.vtg-series-wrapper,
.vtg-downloads,
.vtg-ads-codes {
    /* ---- Design tokens (override these in Custom CSS) ---- */
    --vtg-accent: #e50914;
    --vtg-accent-dark: #b00610;
    --vtg-bg: #141414;
    --vtg-bg-hover: #1f1f1f;
    --vtg-text: #ffffff;
    --vtg-border: #222;
    --vtg-radius: 14px;
    --vtg-gap: 12px;
    --vtg-player-min-height: 540px;
    box-sizing: border-box;
}

/* ============================================================
   1. BASE LAYOUT
   ============================================================ */

.vtg-tabs {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
}

/* ============================================================
   2. SERVER TABS (buttons)
   ============================================================ */

.vtg-tabs .vtg-tabs-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--vtg-gap);
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    border: none;
}

.vtg-tabs .vtg-tab {
    flex: 0 0 auto;
    list-style: none;
}

.vtg-tabs .vtg-tabs-list .vtg-tab a {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--vtg-radius);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    background: var(--vtg-bg);
    color: var(--vtg-text);
    border: 1px solid var(--vtg-border);
    transition: all .25s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .4);
}

.vtg-tabs .vtg-tabs-list .vtg-tab a:hover {
    border-color: var(--vtg-accent);
    transform: translateY(-2px);
}

.vtg-tabs .vtg-tabs-list .vtg-tab.active a {
    background: var(--vtg-accent);
    border-color: var(--vtg-accent);
    box-shadow: 0 8px 25px rgba(0, 0, 0, .45);
    box-shadow: 0 8px 25px color-mix(in srgb, var(--vtg-accent) 45%, transparent);
    transform: scale(1.05);
}

/* ============================================================
   3. PLAYER & IFRAME
   ============================================================ */

.vtg-tabs .vtg-panels {
    position: relative;
    width: 100%;
    min-height: var(--vtg-player-min-height);
    padding: 0;
    border: none;
    background: transparent;
}

.vtg-tabs .vtg-video {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, .7), 0 0 30px rgba(0, 0, 0, .25);
    box-shadow: 0 15px 40px rgba(0, 0, 0, .7), 0 0 30px color-mix(in srgb, var(--vtg-accent) 20%, transparent);
}

.vtg-tabs .vtg-video iframe,
.vtg-tabs .vtg-panels iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
}

/* Fallback for browsers without aspect-ratio */
@supports not (aspect-ratio: 1/1) {
    .vtg-tabs .vtg-video {
        position: relative;
        padding-top: 56.25%;
    }
    .vtg-tabs .vtg-video iframe {
        position: absolute;
        top: 0;
        inset-inline-start: 0;
        height: 100%;
    }
}

/* ============================================================
   4. LOADER (only shown if loader_enabled in settings)
   ============================================================ */

.vtg-player-wrapper { position: relative; }

.vtg-player-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, .85);
    backdrop-filter: blur(4px);
    border-radius: 18px;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s ease;
}

.vtg-player-loader.active {
    opacity: 1;
    pointer-events: auto;
}

.vtg-loader-ring {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, .1);
    border-top-color: var(--vtg-accent);
    animation: vtgSpin 1s linear infinite;
    box-shadow: 0 0 25px rgba(0, 0, 0, .4);
    box-shadow: 0 0 25px color-mix(in srgb, var(--vtg-accent) 40%, transparent);
}

@keyframes vtgSpin { to { transform: rotate(360deg); } }

.vtg-loader-text {
    margin-top: 15px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: .5px;
    opacity: .8;
}

/* ============================================================
   5. SERIES — player on top, episode list below
   ============================================================ */

.vtg-series-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Player + servers take full width on top */
.vtg-series-wrapper .vtg-tabs {
    width: 100%;
}

/* Episode list: sits BELOW the player, wraps into rows */
.vtg-episode-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: var(--vtg-bg);
    border-radius: var(--vtg-radius);
    border: 1px solid var(--vtg-border);
}

.vtg-episode-pagination-title {
    width: 100%;
    margin-bottom: 4px;
    color: var(--vtg-text);
    font-size: 14px;
    font-weight: 700;
    opacity: .85;
}

/* Desktop: if many episodes, cap height and allow a tidy horizontal wrap */
@media (min-width: 769px) {
    .vtg-episode-pagination {
        flex-direction: row;
        align-content: flex-start;
        max-height: 280px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

.vtg-episode-btn {
    padding: 10px 15px;
    background: var(--vtg-bg);
    border: 1px solid var(--vtg-border);
    color: var(--vtg-text);
    border-radius: var(--vtg-radius);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all .25s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .4);
}

.vtg-episode-btn:hover {
    border-color: var(--vtg-accent);
    background: var(--vtg-bg-hover);
    transform: translateY(-2px);
}

.vtg-episode-btn.active {
    background: var(--vtg-accent);
    border-color: var(--vtg-accent);
    color: #fff;
    box-shadow: 0 8px 25px rgba(0, 0, 0, .45);
    box-shadow: 0 8px 25px color-mix(in srgb, var(--vtg-accent) 45%, transparent);
    transform: scale(1.03);
}

/* ============================================================
   6. DOWNLOAD SERVERS LIST
   ============================================================ */

.vtg-downloads ul,
ul.vtg-downloads-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.vtg-downloads li,
.vtg-downloads-list li {
    flex: 0 0 auto;
}

.vtg-downloads a,
.vtg-downloads-list a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--vtg-radius);
    font-weight: 700;
    text-decoration: none;
    background: var(--vtg-bg);
    color: var(--vtg-text);
    border: 1px solid var(--vtg-border);
    transition: all .25s ease;
}

.vtg-downloads a:hover,
.vtg-downloads-list a:hover {
    border-color: var(--vtg-accent);
    transform: translateY(-2px);
}

.vtg-downloads svg,
.vtg-downloads-list svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ============================================================
   8. RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .vtg-tabs {
        gap: 14px;
    }
    .vtg-tabs .vtg-tabs-list {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 5px 5px 12px 5px;
        scrollbar-width: none;
    }
    .vtg-tabs .vtg-tabs-list::-webkit-scrollbar {
        display: none;
    }
    .vtg-tabs .vtg-panels {
        min-height: 300px;
    }
    .vtg-series-wrapper {
        flex-direction: column !important;
    }
    /* On mobile: episode list as a 3-column grid below the player,
       scrollable vertically for many episodes. */
    .vtg-episode-pagination {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        max-height: 260px;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }
    /* Title takes the full first row of the grid */
    .vtg-episode-pagination-title {
        grid-column: 1 / -1;
    }
    /* Each episode button fills its grid cell and centers its label */
    .vtg-episode-pagination .vtg-episode-btn {
        width: 100%;
        text-align: center;
        padding: 10px 6px;
        font-size: 13px;
    }
}

/* ============================================================
   9. ADMIN PREVIEW OVERRIDES (side-tabs in metabox/preview)
   ============================================================ */

.vtg-admin-preview .vtg-tabs {
    max-width: 100%;
    flex-direction: row;
    gap: 1rem;
    align-items: flex-start;
}

.vtg-admin-preview .vtg-tabs-list {
    flex: 0 0 220px;
    width: 220px;
    flex-direction: column;
    background: transparent;
}

.vtg-admin-preview .vtg-tabs-list .vtg-tab a {
    display: block;
    padding: 10px 12px;
}

.vtg-admin-preview .vtg-panels {
    flex: 1 1 auto;
    min-width: 360px;
    min-height: 480px;
    border: 1px solid #ddd;
    padding: 1em;
    background: #fff;
}

.vtg-admin-preview .vtg-panels iframe {
    min-height: 360px;
}
