/* ==========================================
   UNITY TV COMPONENT STYLES
   Standalone CSS for Unity TV component
   ========================================== */

/* ==========================================
   MAIN COMPONENT
   ========================================== */
.unity-tv-section {
    margin-bottom: 0;
}

.unity-tv-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    height: inherit;

    grid-column: 1 / span 4;   /* 75% */
}

.unity-tv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.unity-tv-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}



.unity-tv-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-right: 30px;
}

.unity-tv-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

.unity-tv-status .status-dot.connecting {
    background: #f59e0b;
    animation: unity-tv-pulse 1.5s infinite;
}

.unity-tv-status .status-dot.live {
    background: #ef4444;
    animation: unity-tv-pulse 1s infinite;
}

.unity-tv-status .status-dot.error {
    background: #ef4444;
}

/* ==========================================
   PLAYER AREA
   ========================================== */
.unity-tv-body {
    display: flex;
    height: 59.2vh;
    /*height: -webkit-fill-available;*/
}

.unity-tv-player {
    flex: 1;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    position: relative;
    min-height: 350px;
    z-index: 1;
}

.tv-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    /* Ensure inactive content is completely hidden */
    visibility: hidden;
    z-index: 0;
}

.tv-content.active {
    display: flex;
    visibility: visible;
    z-index: 1;
}

.tv-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================
   ZOOM EMBED CONTAINER
   ========================================== */
#zoomEmbedContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: none;
    isolation: isolate;
    contain: strict;
}

#zoomEmbedContainer iframe {
    border: none !important;
    background: #000 !important;
}

/* ==========================================
   LIVE SESSION STATES
   Mutual exclusion with fade transitions
   ========================================== */
.live-session-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 2%;
    position: relative;
}

/* Base state styles - hidden by default */
.no-live-state,
.live-state {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    text-align: center;
}

/* Visible state - show with fade */
.no-live-state.visible,
.live-state.visible {
    display: block;
    opacity: 1;
}

/* Fading out state - for smooth transitions */
.no-live-state.fading-out,
.live-state.fading-out {
    display: block;
    opacity: 0;
}

.no-live-icon {
    font-size: 35px;
    opacity: 0.6;
    float: left;
    margin-left: -35px;
}

.no-live-state h3,
.live-state h3 {
    font-size: 18px;
    color: #fff;
    margin: 0 0 8px 0;
}

.no-live-state p {
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
    font-size: 0.85rem;
}

.next-session-box {
    margin-top: 20px;
    padding: 7px 16px;
    background: rgba(124, 58, 237, 0.2);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 8px;
}

.next-label {
    color: rgba(255, 255, 255, 0.7);
    margin-right: 8px;
}

.next-time {
    color: var(--accent-primary);
    font-weight: 600;
}

.live-banner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ef4444;
    border-radius: 20px;
    margin-bottom: 16px;
}

.live-pulse {
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    animation: unity-tv-pulse 1s infinite;
}

.live-text {
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 1px;
}

.live-host {
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 16px 0;
}

.live-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.join-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.join-btn.primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
}

.join-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.join-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.3);
}

/* Loading & Error States */
.loading-state,
.error-state {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    /* Ensure these don't escape their parent container */
    position: relative;
    z-index: 1;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: unity-tv-spin 1s linear infinite;
    margin: 0 auto 16px;
}

/* ==========================================
   VERTICAL TABS
   ========================================== */
.unity-tv-tabs {
    display: flex;
    flex-direction: column;
    width: 10%;
    background: #252525;
    border-left: 1px solid var(--border-color);
}

.tv-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.8vw 12px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: #ffffff4d;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    min-height: 90px;
}

.tv-tab:last-child {
    border-bottom: none;
}

.tv-tab:hover {
    background: rgb(26 26 26 / 76%);
    color: var(--text-primary);
}

.tv-tab.active {
    background: var(--accent-primary);
    color: #fff;
}

.tab-icon {
    font-size: 24px;
    line-height: 1rem;
}

.live-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: unity-tv-pulse 1s infinite;
    display: none;
}

/* ==========================================
   STICKY MINI PLAYER - SEAMLESS PLAYBACK
   Uses transform for animation to prevent video pause
   ========================================== */
.mini-player {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 280px;
    max-width: calc(100vw - 40px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    z-index: 99999;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);

    /* CRITICAL: Use transform for show/hide, NOT opacity/visibility */
    /* This prevents browser from pausing video during transitions */
    transform: translateY(150%);
    transition: transform 0.3s ease;

    /* Always keep rendered but off-screen when hidden */
    visibility: visible;
    opacity: 1;
    pointer-events: none;
}

.mini-player.visible {
    transform: translateY(0);
    pointer-events: auto;
}

/* Disable transition during iframe move to prevent glitches */
.mini-player.transitioning {
    transition: none;
}

.mini-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.mini-player-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-player-title .live-dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: unity-tv-pulse 1s infinite;
}

.mini-player-controls {
    display: flex;
    gap: 4px;
}

.mini-player-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.2s;
}

.mini-player-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.mini-player-content {
    aspect-ratio: 16 / 9;
    background: #000;
    position: relative;
}

.mini-player-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.mini-player-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--text-tertiary);
    font-size: 12px;
    padding: 20px;
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
}

/* Placeholder shown in main player when video is in mini player */
.iframe-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

/* ==========================================
   MINI MODE - CSS TRANSFORMATION
   Slides up and fades in from bottom-right corner
   ========================================== */

/* Target the grid-stack-item that contains Unity TV when in mini mode */
/* Must override GridStack's inline styles with maximum specificity */
.grid-stack-item.unity-tv-grid-mini[style] {
    position: fixed !important;
    bottom: 15px !important;
    right: 15px !important;
    left: auto !important;
    top: auto !important;
    width: 240px !important;
    height: 169px !important;  /* 16:9 ratio for 300px width */
    min-width: 246px !important;
    max-width: 246px !important;
    min-height: 138px !important;
    max-height: 130px !important;
    z-index: 99999 !important;

    /* Slide up + fade in animation */
    animation: miniSlideUp 0.3s ease forwards !important;

    /* Reset ALL GridStack transforms and positioning */
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Content wrapper inside grid item */
.grid-stack-item.unity-tv-grid-mini > .grid-stack-item-content {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    border-radius: 12px !important;
}

/* The card itself in mini mode */
.draggable-card.unity-tv-card.unity-tv-mini-mode {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.1) !important;
    border-radius: 12px !important;
    overflow: hidden !important;
}

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

/* Hide header, tabs, drag handle in mini mode */
.unity-tv-mini-mode .unity-tv-header {
    display: none !important;
}

.unity-tv-mini-mode .unity-tv-tabs {
    display: none !important;
}

.unity-tv-mini-mode > .drag-handle {
    display: none !important;
}

/* Tighter container - video only, no extra space */
.unity-tv-mini-mode > .unity-tv-section {
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
}

/* Inner .unity-tv-card (the one inside section) */
.unity-tv-mini-mode .unity-tv-section > .unity-tv-card {
    border-radius: 12px !important;
    border: none !important;
    background: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.unity-tv-mini-mode .unity-tv-body {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
}

.unity-tv-mini-mode .unity-tv-player {
    aspect-ratio: 16 / 9;
    min-height: auto !important;
    height: auto !important;
    width: 100% !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: none !important;
}

.unity-tv-mini-mode .tv-content {
    border-radius: 12px !important;
}

.unity-tv-mini-mode .tv-content iframe {
    border-radius: 12px !important;
}

/* Mini player close button */
.mini-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.unity-tv-mini-mode:hover .mini-close-btn {
    opacity: 1;
}

.mini-close-btn:hover {
    background: rgba(239, 68, 68, 0.9);
}

/* Mobile mini mode */
@media (max-width: 768px) {
    .draggable-card.unity-tv-card.unity-tv-mini-mode {
        width: 220px !important;
        bottom: 10px !important;
        right: 10px !important;
    }
}

@media (max-width: 480px) {
    .draggable-card.unity-tv-card.unity-tv-mini-mode {
        width: 160px !important;
    }
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes unity-tv-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes unity-tv-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
    .unity-tv-card {
        min-width: auto;
    }

    .unity-tv-body {
        flex-direction: column;
    }

    .unity-tv-tabs {
        flex-direction: row;
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .tv-tab {
        flex: 1;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        padding: 12px 8px;
    }

    .tv-tab:last-child {
        border-right: none;
    }

    .tab-label {
        display: none;
    }

    .mini-player {
        width: 220px;
        bottom: 10px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    .unity-tv-player {
        min-height: 250px;
    }

    .tv-content iframe {
        min-height: 250px;
    }

    .live-session-wrapper {
        padding: 20px;
        min-height: 250px;
    }

    .no-live-icon {
        font-size: 48px;
    }
}

.unity_tv_full .unity-tv-card{border-radius: 0 !important; max-height: 92.5vh; overflow: hidden;}
.unity_tv_full .unity-tv-body {max-height:84.2vh;}