/* ========================================
   SyncPlay — Premium Dark Theme
   ======================================== */

:root {
    --bg-base: #09090b;
    --bg-surface: #111114;
    --bg-elevated: #19191d;
    --bg-overlay: rgba(9, 9, 11, 0.85);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(139, 92, 246, 0.5);

    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-glow: rgba(139, 92, 246, 0.25);
    --accent-secondary: #ec4899;
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #ec4899);

    --success: #22c55e;
    --danger: #ef4444;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ========================================
   App Shell
   ======================================== */
.app-shell {
    display: flex;
    height: 100vh;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(139, 92, 246, 0.08), transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(236, 72, 153, 0.06), transparent 50%),
        var(--bg-base);
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    z-index: 20;
    transition: transform var(--transition-smooth);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-tag {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-light);
    opacity: 0.8;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.sidebar-close:hover {
    background: var(--bg-elevated);
}

/* Search */
.search-wrapper {
    padding: 0 20px 16px;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 4px 4px 4px 16px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-field:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-field i {
    color: var(--text-muted);
    font-size: 1rem;
    flex-shrink: 0;
}

.search-field input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    min-width: 0;
}

.search-field input::placeholder {
    color: var(--text-muted);
}

.search-go {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform var(--transition-fast), filter var(--transition-fast);
}

.search-go:hover {
    transform: scale(1.08);
    filter: brightness(1.15);
}

/* Search Results */
.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    text-align: center;
    gap: 10px;
    padding: 2rem 1rem;
    min-height: 120px;
}

.empty-state i {
    font-size: 2.5rem;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.8rem;
    line-height: 1.5;
    max-width: 200px;
}

.empty-state.small {
    min-height: 80px;
    padding: 1rem;
}

.empty-state.small i {
    font-size: 1.8rem;
}

.empty-state.small p {
    font-size: 0.75rem;
}

/* Result Cards */
.result-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    cursor: default;
}

.result-card:hover {
    background: var(--bg-elevated);
}

.result-thumb {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

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

.result-info h4 {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.result-info p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.add-btn:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

/* ========================================
   Main Area
   ======================================== */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--bg-elevated);
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.live-dot {
    width: 7px;
    height: 7px;
    background: var(--danger);
    border-radius: 50%;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.listeners-count {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

.listeners-count i {
    font-size: 1rem;
}

/* ========================================
   Player Section
   ======================================== */
.player-section {
    padding: 0 24px;
    flex-shrink: 0;
}

.player-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 400px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
}

.player-frame video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#audioPoolA,
#audioPoolB {
    display: none;
}

.player-frame.audio-mode video {
    display: none;
}

/* Audio artwork */
.audio-artwork {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    flex-direction: column;
    gap: 16px;
}

.player-frame.audio-mode .audio-artwork {
    display: flex;
}

.audio-artwork img {
    width: 140px;
    height: 140px;
    border-radius: var(--radius-lg);
    object-fit: cover;
    box-shadow: var(--shadow-glow);
    animation: float 4s ease-in-out infinite;
}

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

.artwork-glow {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--accent-gradient);
    filter: blur(80px);
    opacity: 0.2;
    animation: glow-pulse 3s ease-in-out infinite alternate;
}

@keyframes glow-pulse {
    0% { opacity: 0.15; transform: scale(0.9); }
    100% { opacity: 0.25; transform: scale(1.1); }
}

/* Audio visualizer bars */
.audio-visualizer {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 24px;
}

.audio-visualizer span {
    width: 4px;
    border-radius: 2px;
    background: var(--accent-gradient);
    animation: visualize 0.8s ease-in-out infinite alternate;
}

.audio-visualizer span:nth-child(1) { height: 8px; animation-delay: 0s; }
.audio-visualizer span:nth-child(2) { height: 16px; animation-delay: 0.15s; }
.audio-visualizer span:nth-child(3) { height: 24px; animation-delay: 0.3s; }
.audio-visualizer span:nth-child(4) { height: 12px; animation-delay: 0.45s; }
.audio-visualizer span:nth-child(5) { height: 20px; animation-delay: 0.6s; }

@keyframes visualize {
    0% { transform: scaleY(0.4); }
    100% { transform: scaleY(1); }
}

.audio-visualizer.paused span {
    animation-play-state: paused;
}

/* Loading */
.player-loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-overlay);
    z-index: 5;
}

.player-loading.visible {
    display: flex;
}

.loader-ring {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.player-loading p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Idle */
.player-idle {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--text-muted);
}

.player-idle i {
    font-size: 3rem;
    opacity: 0.3;
}

.player-idle p {
    font-size: 0.85rem;
}

/* Player Meta */
.player-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 8px;
    gap: 16px;
}

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

.track-info h2 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.player-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    align-items: center;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    padding: 3px;
    position: relative;
    border: 1px solid var(--border-subtle);
}

.mode-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    transition: color var(--transition-fast);
}

.mode-btn.active {
    color: white;
}

.mode-slider {
    position: absolute;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-gradient);
    top: 3px;
    left: 3px;
    transition: transform var(--transition-smooth);
    z-index: 1;
}

.mode-toggle[data-active="audio"] .mode-slider {
    transform: translateX(34px);
}

/* Action buttons (mute, personal pause) */
.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.action-btn.active {
    color: white;
    background: var(--accent-gradient);
    border-color: transparent;
}

/* Unmute prompt overlay */
.unmute-banner {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    z-index: 5;
}

.unmute-banner.hidden {
    display: none;
}

/* Progress Bar */
.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 16px;
}

.time-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    min-width: 32px;
}

.time-label:last-child {
    text-align: right;
}

.progress-track {
    flex: 1;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    width: 0%;
    position: relative;
    transition: width 0.1s linear;
}

/* ========================================
   Queue Section
   ======================================== */
.queue-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0 24px 16px;
}

.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 12px;
    flex-shrink: 0;
}

.queue-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.queue-header h3 i {
    color: var(--accent-light);
    font-size: 1.1rem;
}

.queue-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.queue-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Playlist Items */
.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.queue-item:hover {
    background: var(--bg-elevated);
}

.queue-num {
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 18px;
    text-align: center;
    font-weight: 600;
    flex-shrink: 0;
}

.queue-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

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

.queue-info h4 {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-info p {
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.queue-duration {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all var(--transition-fast);
}

.queue-item:hover .remove-btn {
    opacity: 1;
}

.remove-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        inset: 0;
        width: 100%;
        transform: translateX(-100%);
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .menu-toggle {
        display: block;
    }

    .player-frame {
        max-height: 240px;
    }

    .top-bar {
        padding: 12px 16px;
    }

    .player-section {
        padding: 0 16px;
    }

    .queue-section {
        padding: 0 16px 12px;
    }

    .player-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .player-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
