/**
 * WPX Episode Player - Frontend Styles
 * Zero bloat, CLS = 0, Aspect Ratio 16/9, Dark Theme Native
 * Includes Smart Compact Mode for single-episode multi-server videos.
 */

.wpx-player-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 24px;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Video Viewport (16:9 Aspect Ratio) */
.wpx-player-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpx-player-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpx-player-screen video,
.wpx-player-screen iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: #000;
}

/* Loader Overlay */
.wpx-player-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(2px);
}

.wpx-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-left-color: #ef4444;
    border-radius: 50%;
    animation: wpxSpin 0.8s linear infinite;
}

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

/* Control Panel */
.wpx-episodes-panel {
    background: #111827;
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   SMART COMPACT MODE (1 Single Row for Single-Episode Multi-Server)
   ========================================================================== */
.wpx-compact-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.wpx-compact-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.wpx-compact-label svg {
    color: #ef4444;
}

.wpx-compact-servers-list {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wpx-compact-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 14px !important;
    background: #1e293b !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    white-space: nowrap !important;
}

.wpx-compact-btn:hover {
    background: #334155 !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-1px);
}

.wpx-compact-btn.is-active {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35) !important;
}

.wpx-compact-btn .wpx-server-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}

.wpx-compact-btn.is-active .wpx-server-dot {
    background: #ffffff;
}

.wpx-compact-btn .wpx-ep-type-badge {
    position: static !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    background: rgba(0, 0, 0, 0.3) !important;
    color: #cbd5e1 !important;
    line-height: 1.2 !important;
}

.wpx-compact-btn.is-active .wpx-ep-type-badge {
    background: rgba(0, 0, 0, 0.25) !important;
    color: #ffffff !important;
}

.wpx-btn-sub-label {
    font-size: 12px;
    opacity: 0.9;
    font-weight: 500;
}

/* ==========================================================================
   FULL MULTI-EPISODE MODE (Server Tabs + Episodes Grid)
   ========================================================================== */
.wpx-servers-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.wpx-servers-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wpx-servers-label svg {
    color: #ef4444;
}

.wpx-server-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wpx-server-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1f2937;
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.wpx-server-tab-btn:hover {
    background: #374151;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

.wpx-server-tab-btn.is-active {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.wpx-server-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}

.wpx-server-tab-btn.is-active .wpx-server-dot {
    background: #ffffff;
}

.wpx-server-count {
    font-size: 11px;
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 6px;
    border-radius: 10px;
    color: inherit;
    opacity: 0.85;
}

/* Episodes Groups */
.wpx-server-episodes-group {
    display: none;
}

.wpx-server-episodes-group.is-visible {
    display: block;
    animation: wpxFadeIn 0.25s ease-out;
}

@keyframes wpxFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Episodes Grid */
.wpx-episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom Scrollbar */
.wpx-episodes-grid::-webkit-scrollbar {
    width: 5px;
}

.wpx-episodes-grid::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 4px;
}

.wpx-episodes-grid::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.wpx-episodes-grid::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Episode Button in Grid */
.wpx-ep-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 10px;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.wpx-ep-btn:hover {
    background: #334155;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.wpx-ep-btn.is-active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35);
}

.wpx-ep-icon {
    display: inline-flex;
    align-items: center;
    color: inherit;
    opacity: 0.8;
}

.wpx-ep-type-badge {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 9px;
    background: rgba(0, 0, 0, 0.4);
    color: #94a3b8;
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1;
}

.wpx-ep-btn.is-active .wpx-ep-type-badge {
    color: #fff;
    background: rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    /* Edge-to-edge full width on mobile */
    .wpx-player-wrapper {
        margin-left: -16px;
        margin-right: -16px;
        width: calc(100% + 32px);
        max-width: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }

    /* Boost height to compensate for internal server bar in iframe */
    .wpx-player-viewport {
        min-height: 245px;
    }

    .wpx-episodes-panel {
        padding: 12px 16px;
        border-radius: 0;
    }
}

@media (max-width: 640px) {
    .wpx-episodes-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 6px;
        max-height: 200px;
    }

    .wpx-ep-btn {
        padding: 7px 6px;
        font-size: 12px;
    }

    .wpx-compact-btn {
        padding: 7px 10px !important;
        font-size: 12px !important;
    }
}
