/* Vectra TV App - YouTube Video Mode */

/* ==========================================
   CSS VARIABLES
   ========================================== */
:root {
    --tv-bg: #0a0a0f;
    --tv-panel: rgba(18, 18, 26, 0.85);
    --tv-panel-border: rgba(255, 255, 255, 0.08);
    --tv-text: #ffffff;
    --tv-text-secondary: #9ca3af;
    --tv-text-muted: #6b7280;
    --tv-accent: #22d3ee;
    --tv-accent-purple: #a855f7;
    --tv-focus-ring: 0 0 0 3px rgba(34, 211, 238, 0.6),
        0 0 20px rgba(34, 211, 238, 0.3);
    --tv-focus-ring-active: 0 0 0 3px rgba(168, 85, 247, 0.8),
        0 0 30px rgba(168, 85, 247, 0.4);
    --tv-transition: 0.2s ease;
}

.hidden {
    display: none !important;
}

/* ==========================================
   RESET & BASE
   ========================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--tv-bg);
    color: var(--tv-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    cursor: none;
}

/* ==========================================
   LAYOUT - Two-column TV layout
   ========================================== */
.tv-app {
    display: grid;
    grid-template-columns: 175px 1fr;
    grid-template-rows: 1fr auto;
    width: auto;
    height: auto;
    position: absolute;
    inset: 1%;
    padding: 0;
    border: 0;
    border-radius: 24px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    gap: 20px;
}

/* ==========================================
   CHANNELS SIDEBAR
   ========================================== */
.channels-sidebar {
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    background: var(--tv-panel);
    border: 1px solid var(--tv-panel-border);
    border-radius: 20px;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.channels-list.hidden {
    display: none;
}

.channels-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--tv-panel-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.channels-header img {
    height: 10px;
    max-width: 80%;
    object-fit: contain;
    width: auto;
}

.channels-header .logo-icon {
    width: 20px;
    height: 20px;
}

.channels-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    scrollbar-width: none;
}

.channels-list::-webkit-scrollbar {
    display: none;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 14px;
    cursor: pointer;
    transition: all var(--tv-transition);
    border: 2px solid transparent;
    margin-bottom: 2px;
    outline: none;
}

.channel-item:focus,
.channel-item.focused {
    border-color: var(--tv-accent);
    box-shadow: var(--tv-focus-ring);
    background: rgba(34, 211, 238, 0.1);
    transform: scale(1.02);
}

.channel-item.active {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(168, 85, 247, 0.15));
    border-color: rgba(34, 211, 238, 0.4);
}

.channel-item.active.focused {
    border-color: var(--tv-accent);
    box-shadow: var(--tv-focus-ring);
}

.channel-item .channel-color {
    width: 8px;
    height: 36px;
    border-radius: 4px;
    flex-shrink: 0;
}

.channel-item .channel-info {
    flex: 1;
    min-width: 0;
}

.channel-item .channel-name {
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-item .channel-tracks {
    font-size: 10px;
    color: var(--tv-text-muted);
    margin-top: 1px;
}

.channel-item .eq-indicator {
    display: none !important;
}

/* ==========================================
   MAIN CONTENT AREA
   ========================================== */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
}

/* ==========================================
   VIDEO CONTAINER (replaces visualizer)
   ========================================== */
.video-container {
    flex: 1;
    background: #000;
    border: 1px solid var(--tv-panel-border);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    min-height: 200px;
}

.video-container #youtubePlayer,
.video-container iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 20px;
    z-index: 1;
}

/* Welcome Overlay */
.welcome-overlay {
    position: absolute;
    inset: 0;
    padding: 4%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
    background: rgba(10, 10, 15, 0.85);
    transition: opacity 0.5s ease;
}

.welcome-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.welcome-overlay .welcome-icon {
    font-size: 64px;
    animation: floatBounce 3s ease-in-out infinite;
}

.welcome-overlay h2 {
    font-size: 26px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--tv-accent), var(--tv-accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    padding: 0 20px;
}

.welcome-overlay p {
    font-size: 18px;
    color: var(--tv-text-secondary);
}

@keyframes floatBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* Channel Info Overlay on Video */
.channel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    padding: 16px 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 1), 0 0 20px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    color: #fff;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.channel-overlay.visible {
    opacity: 1;
}

.channel-overlay.welcome-mode {
    opacity: 1;
    justify-content: center;
}

.channel-info-left {
    flex-shrink: 0;
}

.channel-overlay .channel-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--tv-text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.channel-overlay .channel-title {
    font-size: 26px;
    font-weight: 800;
}

.remote-hint {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.hint-key {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    color: #fff;
    white-space: nowrap;
}

.hint-key kbd {
    display: inline-block;
    padding: 1px 4px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    font-family: inherit;
    font-size: 9px;
    color: #fff;
    line-height: 1.2;
    min-width: 18px;
    height: 16px;
}

/* ==========================================
   NOW PLAYING BAR
   ========================================== */
.now-playing-bar {
    background: var(--tv-panel);
    border: 1px solid var(--tv-panel-border);
    border-radius: 20px;
    padding: 16px 28px;
    position: relative;
    display: none;
    align-items: center;
    gap: 0;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
    min-height: 90px;
    box-sizing: border-box;
    margin-top: 12px;
}

.now-playing-bar.visible {
    display: flex;
}

/* Track Info - Left */
.track-info {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 40%;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.track-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
}

.track-text {
    flex: 1;
    min-width: 0;
}

.track-info .track-title {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-info .track-artist {
    font-size: 11px;
    color: var(--tv-text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls Center - Right */
.controls-center {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    width: auto;
}

.transport-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    color: var(--tv-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--tv-transition);
    outline: none;
}

.transport-btn:focus,
.transport-btn.focused {
    border-color: var(--tv-accent);
    box-shadow: var(--tv-focus-ring);
    background: rgba(34, 211, 238, 0.15);
    transform: scale(1.1);
}

.transport-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.fav-btn svg {
    fill: none;
    stroke: currentColor;
}

.fav-btn.active {
    color: #e91e8c;
}

.fav-btn.active svg {
    fill: currentColor;
    stroke: none;
}

.transport-btn.play-btn {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--tv-accent), var(--tv-accent-purple));
    box-shadow: 0 4px 20px rgba(34, 211, 238, 0.3);
}

.transport-btn.play-btn:focus,
.transport-btn.play-btn.focused {
    box-shadow: var(--tv-focus-ring-active);
    transform: scale(1.12);
}

.transport-btn.play-btn svg {
    width: 24px;
    height: 24px;
}

.time-display {
    margin-top: 2px;
    font-size: 11px;
    color: var(--tv-text-muted);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.time-separator {
    margin: 0 4px;
    opacity: 0.6;
}

/* ==========================================
   IN-SIDEBAR PLAYLIST
   ========================================== */
.sidebar-playlist {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInUp 0.25s ease-out;
}

.sidebar-playlist.hidden {
    display: none;
}

.sidebar-playlist-header {
    padding: 10px 10px;
    border-bottom: 1px solid var(--tv-panel-border);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-shrink: 0;
}

.back-to-channels-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--tv-text-secondary);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 6px;
    transition: all var(--tv-transition);
    outline: none;
}

.back-to-channels-btn svg {
    width: 16px;
    height: 16px;
}

.back-to-channels-btn:focus,
.back-to-channels-btn.focused {
    border-color: var(--tv-accent);
    box-shadow: var(--tv-focus-ring);
    color: var(--tv-accent);
}

.sidebar-playlist-header .playlist-count {
    font-size: 10px;
    color: var(--tv-text-muted);
    margin-left: auto;
}

.sidebar-playlist-title {
    padding: 8px 12px 4px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
    background: linear-gradient(135deg, var(--tv-accent), var(--tv-accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex-shrink: 0;
}

.playlist-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 6px;
    scrollbar-width: none;
}

.playlist-list::-webkit-scrollbar {
    display: none;
}

.playlist-track {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--tv-transition);
    border: 2px solid transparent;
    margin-bottom: 1px;
    outline: none;
}

.playlist-track:focus,
.playlist-track.focused {
    border-color: var(--tv-accent);
    box-shadow: var(--tv-focus-ring);
    background: rgba(34, 211, 238, 0.1);
}

.playlist-track.active {
    background: linear-gradient(90deg, rgba(34, 211, 238, 0.12), transparent);
    border-left: 3px solid var(--tv-accent);
}

.playlist-track .track-num {
    width: 16px;
    text-align: center;
    font-size: 10px;
    color: var(--tv-text-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.playlist-track.active .track-num {
    color: var(--tv-accent);
}

.playlist-track .track-details {
    flex: 1;
    min-width: 0;
}

.playlist-track .track-name {
    font-size: 9px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-track .track-artist-name {
    font-size: 8px;
    color: var(--tv-text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Playing indicator */
.playlist-track .playing-indicator {
    display: none;
    margin-left: auto;
}

.playlist-track.active .playing-indicator {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 14px;
}

.playing-bar {
    width: 2px;
    background: var(--tv-accent);
    border-radius: 1px;
    animation: eqBarTV 0.5s ease-in-out infinite alternate;
}

.playing-bar:nth-child(1) { animation-delay: 0s; height: 4px; }
.playing-bar:nth-child(2) { animation-delay: 0.1s; height: 8px; }
.playing-bar:nth-child(3) { animation-delay: 0.2s; height: 6px; }

@keyframes eqBarTV {
    from { height: 4px; }
    to { height: 14px; }
}

/* ==========================================
   SCREENSAVER
   ========================================== */
.screensaver {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.screensaver.active {
    display: flex;
}

.logo-float {
    animation: dvdBounce 20s linear infinite;
}

@keyframes dvdBounce {
    0% { transform: translate(0, 0); }
    25% { transform: translate(30vw, 20vh); }
    50% { transform: translate(-20vw, 30vh); }
    75% { transform: translate(25vw, -15vh); }
    100% { transform: translate(0, 0); }
}

/* ==========================================
   FOCUS RING UTILITY
   ========================================== */
.focus-ring:focus {
    outline: none;
    box-shadow: var(--tv-focus-ring);
}

/* ==========================================
   LOADING SPINNER
   ========================================== */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(34, 211, 238, 0.2);
    border-top-color: var(--tv-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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