/**
 * Sidebar Playlist Layout
 * Dual-pane: Main player + scrollable playlist
 */

.gtnb-vp-sidebar {
    display: grid;
    grid-template-columns: 1fr var(--playlist-width, 30%);
    gap: 20px;
    padding: 20px 0;
    align-items: start;
}

.gtnb-vp-sidebar.playlist-left {
    grid-template-columns: var(--playlist-width, 30%) 1fr;
}

.gtnb-vp-sidebar.playlist-right {
    grid-template-columns: 1fr var(--playlist-width, 30%);
}

/* Wrapper - controls height for both player and playlist */
.gtnb-vp-sidebar-wrapper {
    width: 100%;
    position: relative;
    grid-row: 1;
}

.gtnb-vp-sidebar.playlist-left .gtnb-vp-sidebar-wrapper {
    grid-column: 2;
}

.gtnb-vp-sidebar.playlist-right .gtnb-vp-sidebar-wrapper {
    grid-column: 1;
}

/* Main Player */
.gtnb-vp-sidebar-player {
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.gtnb-vp-sidebar-player video,
.gtnb-vp-sidebar-player .video-js {
    width: 100% !important;
    height: auto !important;
    display: block;
}

/* Video Title Display */
.gtnb-vp-sidebar-video-title {
    padding: 12px 16px;
    background: linear-gradient(135deg, #f5b82e 0%, #d9a426 100%);
    color: #000;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    border-radius: 8px;
    margin-top: 12px;
    box-shadow: 0 2px 8px rgba(245, 184, 46, 0.2);
    transition: all 0.3s ease;
}

/* Playlist Container - matches wrapper height via grid */
.gtnb-vp-sidebar-playlist {
    display: flex;
    flex-direction: column;
    background: transparent;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    grid-row: 1;
    height: 100%;
    align-self: stretch;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gtnb-vp-sidebar-playlist.height-synced {
    opacity: 1;
}

.gtnb-vp-sidebar.playlist-left .gtnb-vp-sidebar-playlist {
    grid-column: 1;
}

.gtnb-vp-sidebar.playlist-right .gtnb-vp-sidebar-playlist {
    grid-column: 2;
}

.gtnb-vp-sidebar-playlist-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f5b82e 0%, #d9a426 100%);
    color: #000;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.gtnb-vp-sidebar-playlist:not(:has(.gtnb-vp-sidebar-playlist-header)) .gtnb-vp-sidebar-playlist-items {
    /* When no header, items take full height */
    padding-top: 0;
}

.gtnb-vp-sidebar-playlist-header::before {
    content: '📋';
    font-size: 20px;
}

/* Scrollable List */
.gtnb-vp-sidebar-playlist-items {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    min-height: 0;
}

/* Webkit scrollbar styling */
.gtnb-vp-sidebar-playlist-items::-webkit-scrollbar {
    width: 8px;
}

.gtnb-vp-sidebar-playlist-items::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.gtnb-vp-sidebar-playlist-items::-webkit-scrollbar-thumb {
    background: #f5b82e;
    border-radius: 4px;
}

.gtnb-vp-sidebar-playlist-items::-webkit-scrollbar-thumb:hover {
    background: #d9a426;
}

/* Playlist Item */
.gtnb-vp-sidebar-item {
    display: flex;
    gap: 12px;
    padding: 0;
    margin-bottom: 8px;
    background: transparent;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gtnb-vp-sidebar-item:hover {
    background: rgba(245, 184, 46, 0.05);
    box-shadow: none;
}

.gtnb-vp-sidebar-item.active {
    background: rgba(245, 184, 46, 0.1);
    box-shadow: none;
}

.gtnb-vp-sidebar-item.active .gtnb-vp-sidebar-item-title {
    color: #f5b82e;
    font-weight: 700;
}

/* Item Thumbnail */
.gtnb-vp-sidebar-item-thumbnail {
    width: 80px;
    height: 45px;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

/* Hide duration overlay in thumbnail on desktop */
.gtnb-vp-sidebar-item-thumbnail .gtnb-vp-sidebar-item-meta {
    display: none;
}

.gtnb-vp-sidebar-item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gtnb-vp-sidebar-item-thumbnail .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: rgba(245, 184, 46, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gtnb-vp-sidebar-item-thumbnail .play-icon::before {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #000;
    margin-left: 2px;
}

.gtnb-vp-sidebar-item.active .play-icon {
    background: #f5b82e;
}

/* Active item - pause icon (two bars) */
.gtnb-vp-sidebar-item.active.playing .play-icon::before {
    border: none;
    width: 10px;
    height: 10px;
    background: linear-gradient(to right, #000 0%, #000 35%, transparent 35%, transparent 65%, #000 65%, #000 100%);
    margin-left: 0;
}

/* Active item when paused - play icon (triangle) */
.gtnb-vp-sidebar-item.active.paused .play-icon::before {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #000;
    margin-left: 2px;
}

/* Item Content */
.gtnb-vp-sidebar-item-content {
    flex: 1;
    min-width: 0;
}

.gtnb-vp-sidebar-item-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin: 0 0 4px 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.gtnb-vp-sidebar-item-meta {
    font-size: 11px;
    color: #999;
    display: flex;
    gap: 8px;
}

.gtnb-vp-sidebar-item-meta span {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(245, 184, 46, 0.15);
    border-radius: 3px;
    font-size: 11px;
    color: #f5b82e;
    font-weight: 600;
}

.gtnb-vp-sidebar-item-meta .gtnb-vp-duration {
    background: rgba(245, 184, 46, 0.1);
    color: #f5b82e;
    font-variant-numeric: tabular-nums;
}

/* Responsive */
@media (max-width: 1024px) {
    .gtnb-vp-sidebar {
        grid-template-columns: 1fr 35%;
    }
    
    .gtnb-vp-sidebar.playlist-left {
        grid-template-columns: 35% 1fr;
    }
}

/* Tablet - 2 column grid below video */
@media (max-width: 768px) {
    .gtnb-vp-sidebar {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px;
    }
    
    /* Wrapper takes full width */
    .gtnb-vp-sidebar-wrapper {
        width: 100%;
        grid-column: unset !important;
    }
    
    /* Playlist below video, full width */
    .gtnb-vp-sidebar-playlist {
        width: 100% !important;
        height: auto !important;
        grid-column: unset !important;
        align-self: unset !important;
        padding: 0;
    }
    
    /* Remove scrolling, show all items */
    .gtnb-vp-sidebar-playlist-items {
        overflow-y: visible;
        overflow-x: visible;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0;
    }
    
    /* Remove top padding when no header */
    .gtnb-vp-sidebar-playlist:not(:has(.gtnb-vp-sidebar-playlist-header)) .gtnb-vp-sidebar-playlist-items {
        padding-top: 0;
    }
    
    /* Item layout for grid - vertical stack */
    .gtnb-vp-sidebar-item {
        display: flex;
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
        padding: 0;
        background: transparent;
        border-radius: 0;
        overflow: hidden;
        box-shadow: none;
    }
    
    .gtnb-vp-sidebar-item:hover {
        transform: translateY(-2px);
        box-shadow: none;
        background: rgba(245, 184, 46, 0.05);
    }
    
    .gtnb-vp-sidebar-item.active {
        background: rgba(245, 184, 46, 0.1);
    }
    
    /* Thumbnail takes full width - wrapper for overlay positioning */
    .gtnb-vp-sidebar-item-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
        border-radius: 0;
        position: relative;
    }
    
    /* Move meta inside thumbnail as overlay */
    .gtnb-vp-sidebar-item-thumbnail .gtnb-vp-sidebar-item-meta {
        display: flex;
        position: absolute;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        align-items: flex-end;
        justify-content: flex-end;
        padding: 8px;
        pointer-events: none;
        gap: 0;
        margin: 0;
    }
    
    /* Hide extension/size meta on tablet, show only duration */
    .gtnb-vp-sidebar-item-meta span:not(.gtnb-vp-duration) {
        display: none;
    }
    
    /* Duration badge as overlay in bottom right corner */
    .gtnb-vp-sidebar-item-meta .gtnb-vp-duration {
        background: rgba(0, 0, 0, 0.85);
        color: #fff;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 11px;
        font-weight: 600;
    }
    
    /* Hide meta when it's in content (move it to thumbnail via JS or keep both) */
    .gtnb-vp-sidebar-item-content .gtnb-vp-sidebar-item-meta {
        display: none;
    }
    
    /* Content below thumbnail */
    .gtnb-vp-sidebar-item-content {
        padding: 10px;
        background: transparent;
    }
    
    .gtnb-vp-sidebar-item.active .gtnb-vp-sidebar-item-content {
        background: #fff9e6;
    }
    
    .gtnb-vp-sidebar-item-title {
        font-size: 13px;
        line-height: 1.3;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

/* Mobile - 1 column */
@media (max-width: 480px) {
    .gtnb-vp-sidebar {
        padding: 10px 0;
        gap: 15px;
    }
    
    /* Single column layout */
    .gtnb-vp-sidebar-playlist-items {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0;
    }
    
    .gtnb-vp-sidebar-item-title {
        font-size: 12px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .gtnb-vp-sidebar-playlist-header {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* Animation */
.gtnb-vp-sidebar-item {
    opacity: 0;
    animation: sidebarItemFadeIn 0.4s ease forwards;
}

@keyframes sidebarItemFadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Stagger animation */
.gtnb-vp-sidebar-item:nth-child(1) { animation-delay: 0.05s; }
.gtnb-vp-sidebar-item:nth-child(2) { animation-delay: 0.1s; }
.gtnb-vp-sidebar-item:nth-child(3) { animation-delay: 0.15s; }
.gtnb-vp-sidebar-item:nth-child(4) { animation-delay: 0.2s; }
.gtnb-vp-sidebar-item:nth-child(5) { animation-delay: 0.25s; }
.gtnb-vp-sidebar-item:nth-child(n+6) { animation-delay: 0.3s; }
