/* Audio Player UI CSS */
:root {
    --bg-dark: rgba(18, 18, 18, 0.95);
    --bg-panel: rgba(30, 30, 30, 0.9);
    --text-main: #ffffff;
    --text-muted: #b3b3b3;
    --accent: #1db954; /* Spotify-like green */
    --font-family: 'Inter', sans-serif;
}

body, html {
    margin: 0; 
    padding: 0;
    width: 100%; 
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: var(--font-family);
    color: var(--text-main);
    touch-action: none; /* Strictly prevents zooming on iOS/Safari */
}

.app-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; 
    height: 100%;
    height: 100dvh; /* Fixes mobile address bar hiding the bottom */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Background & Overlays */
.video-background {
    position: fixed; 
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 0;
}
.video-foreground, .video-background iframe {
    position: absolute; 
    top: 0; left: 0;
    width: 100%; height: 100%; 
    pointer-events: none;
}
@media (min-aspect-ratio: 16/9) { .video-foreground { height: 300%; top: -100%; } }
@media (max-aspect-ratio: 16/9) { .video-foreground { width: 300%; left: -100%; } }

/* Much Darker Overlay for Audio Player feel */
.video-overlay {
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); /* 85% opacity black */
    backdrop-filter: blur(12px); /* Blur the video heavily */
    -webkit-backdrop-filter: blur(12px);
    z-index: 5; 
    pointer-events: none;
}

/* Loading */
.loading-overlay {
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    background-color: #000; 
    z-index: 100; 
    transition: opacity 0.5s ease;
}
.loading-overlay.hidden { 
    opacity: 0; 
    pointer-events: none; 
}
.spinner {
    width: 40px; height: 40px; 
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%; 
    border-top-color: var(--accent);
    animation: spin 1s infinite; 
    margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Main Content (Center) */
.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 40px;
    padding-bottom: 130px; /* Space for absolute bottom bar */
    text-align: center;
    width: 100vw;
    box-sizing: border-box;
    overflow: hidden; /* Prevent child from pushing boundaries */
}
.track-info {
    max-width: 800px;
    width: 100%;
}
#video-title {
    font-size: 4rem;
    font-weight: 700;
    margin: 0 0 20px 0;
    letter-spacing: -0.04em;
    line-height: 1.2;
    text-shadow: 0 4px 16px rgba(0,0,0,0.8);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}
#video-description {
    font-size: 1.3rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
}

/* Audio Player Bottom Bar */
.audio-player-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    height: 90px;
    width: 100vw;
    box-sizing: border-box;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.bar-left, .bar-right {
    width: 30%;
    display: flex;
    align-items: center;
}
.bar-left { justify-content: flex-start; }
.bar-right { justify-content: flex-end; gap: 20px; }
.bar-center {
    width: 40%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
}

.time-display {
    font-family: monospace;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.player-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.player-btn:hover { 
    color: var(--text-main); 
    transform: scale(1.1); 
}
.player-btn:active { 
    transform: scale(0.95); 
}

.play-btn {
    background: var(--text-main);
    color: #000;
    width: 56px; 
    height: 56px;
    border-radius: 50%;
    font-size: 1.4rem;
    padding-left: 4px; /* visually center play icon */
}
.play-btn:hover {
    background: var(--accent);
    color: #fff;
    transform: scale(1.05);
}

/* Sidebar Playlist */
.sidebar {
    position: absolute;
    top: 0; 
    right: 0; 
    bottom: 90px; /* stops above bottom bar */
    width: 400px;
    background: var(--bg-panel);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    z-index: 15;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.3);
}
.sidebar.closed { 
    transform: translateX(100%); 
}

.sidebar-header {
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-header h2 { 
    margin: 0; 
    font-size: 1.15rem; 
    font-weight: 700; 
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.close-btn {
    background: transparent; 
    border: none; 
    color: var(--text-muted);
    cursor: pointer; 
    font-size: 1.4rem; 
    transition: 0.2s;
}
.close-btn:hover { color: var(--text-main); }

.playlist-items {
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden; /* Hide any horizontal scrollbars */
    padding: 16px;
    touch-action: pan-y; /* Allow vertical scrolling here */
    overscroll-behavior-y: contain; /* Prevent scroll chaining */
}
.playlist-items::-webkit-scrollbar { width: 8px; height: 8px; }
.playlist-items::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }
.playlist-items::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.playlist-item {
    padding: 16px; 
    border-radius: 8px; 
    margin-bottom: 8px;
    cursor: pointer; 
    transition: 0.2s; 
    background: transparent;
    width: 100%;
    box-sizing: border-box;
}
.playlist-item:hover { background: rgba(255,255,255,0.08); }
.playlist-item.active { background: rgba(255,255,255,0.12); }

.playlist-item-title {
    font-weight: 500; 
    font-size: 1rem; 
    margin-bottom: 6px; 
    color: var(--text-main);
    line-height: 1.4;
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}
.playlist-item.active .playlist-item-title { color: var(--accent); }

.playlist-item-desc {
    font-size: 0.85rem; 
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Responsive */
@media (max-width: 900px) {
    #video-title { font-size: 2.8rem; }
    .bar-left, .bar-right { width: 25%; }
    .bar-center { width: 50%; gap: 20px;}
    .sidebar { width: 320px; }
}

@media (max-width: 600px) {
    .audio-player-bar { padding: 0 10px; height: 80px; width: 100%; }
    .bar-left { display: none; } /* Hide completely to make room for controls */
    .bar-center { width: 60%; gap: 15px; justify-content: flex-start; padding-left: 10px; }
    .bar-right { width: 40%; gap: 15px; }
    .sidebar { width: 100%; }
    #video-title { font-size: 2rem; }
    .play-btn { width: 48px; height: 48px; font-size: 1.2rem; }
}
