/* ═══════════════════════════════════════════════════════════
   🖥️ Cyle Music — Web/Desktop Platform Overrides
   Responsive layouts, hover effects, scrollbar styling,
   desktop sidebar navigation
   ═══════════════════════════════════════════════════════════ */

/* ─── Desktop sidebar: hidden by default ───────────────── */
.desktop-sidebar {
    display: none;
}

/* ─── No safe areas on desktop ─────────────────────────── */
.app-header {
    padding-top: 0;
}

.app-content {
    padding-top: 3rem;
}

/* ─── Scrollbar styling (Chromium/WebKit) ──────────────── */
::-webkit-scrollbar {
    width: 14px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 4px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ─── Hover effects (pointer devices only) ─────────────── */
@media (hover: hover) {
    .song-row:hover {
        background: var(--bg-glass-hover);
    }

    .song-menu-btn:hover {
        color: var(--text-primary);
    }

    .card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-glow);
    }

    .nav-btn:hover {
        color: var(--text-secondary);
    }

    .btn:hover {
        transform: translateY(-1px);
    }

    .np-heart-btn:hover svg {
        transform: scale(1.1);
    }

    .sidebar-nav-item:hover {
        background: var(--bg-glass-hover);
        color: var(--text-primary);
    }
}

/* ─── Medium screens (tablet) ──────────────────────────── */
@media (min-width: 768px) {
    .card {
        width: 160px;
    }

    .card-cover {
        width: 160px;
        height: 160px;
    }

    .np-cover {
        width: 340px;
        height: 340px;
    }

    .search-container {
        max-width: 600px;
        margin: 0 auto;
    }
}

/* ═══════════════════════════════════════════════════════════
   DESKTOP LAYOUT (≥1024px) — Sidebar + Content
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {

    /* ─── Show sidebar, hide mobile nav ─────────────── */
    .desktop-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 240px;
        background: var(--bg-secondary);
        border-right: 1px solid var(--border);
        z-index: 100;
        padding: 0;
        overflow-y: auto;
    }

    .bottom-nav,
    .bottom-islands,
    .mini-player-island {
        display: none !important;
    }

    /* ─── Header shifts right ──────────────────────── */
    .player-header {
        left: 240px;
        width: calc(100% - 240px);
    }

    /* Hide hamburger/back on desktop — sidebar handles nav */
    #header-menu-btn {
        display: none;
    }

    /* ─── Content shifts right ─────────────────────── */
    .player-content {
        margin-left: 240px;
        max-width: 900px;
        padding-top: 3rem;
    }

    /* ─── Sidebar Logo ─────────────────────────────── */
    .sidebar-logo {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1rem 0.75rem;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-logo-img {
        display: none;
    }

    .sidebar-logo-text-img {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    /* ─── Sidebar Navigation ───────────────────────── */
    .sidebar-nav {
        display: flex;
        flex-direction: column;
        padding: 0.5rem 0.6rem;
        gap: 2px;
        flex: 1;
    }

    .sidebar-nav-row {
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .sidebar-nav-row .sidebar-nav-item {
        flex: 1;
    }

    .sidebar-search-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        background: transparent;
        border: 1px solid transparent;
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        cursor: pointer;
        transition: all var(--transition);
    }
    .sidebar-search-btn:hover {
        background: var(--bg-glass-hover);
        color: var(--accent);
        border-color: rgba(255,255,255,0.08);
    }
    .sidebar-search-btn svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .sidebar-nav-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.6rem 0.8rem;
        border: none;
        background: transparent;
        color: var(--text-secondary);
        font-family: var(--font);
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        border-radius: var(--radius-sm);
        transition: all var(--transition);
        text-align: left;
        width: 100%;
    }

    .sidebar-nav-item svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .sidebar-nav-item.active {
        background: var(--accent-soft);
        color: var(--accent);
    }

    .sidebar-nav-item.active svg {
        color: var(--accent);
    }

    /* ─── Sidebar Divider ──────────────────────────── */
    .sidebar-divider {
        height: 1px;
        background: var(--border);
        margin: 0.5rem 1rem;
    }

    /* ─── Sidebar Bottom ───────────────────────────── */
    .sidebar-bottom {
        padding: 0.5rem 0.6rem;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .sidebar-logout { color: var(--text-muted); opacity: 0.7; }
    .sidebar-logout:hover { color: #e74c3c; opacity: 1; }

    /* ─── Sidebar Sub-items (collapsible) ─────────── */
    .sidebar-nav-sub {
        display: flex;
        align-items: center;
        padding: 0 0.8rem 0 2.8rem;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-family: var(--font);
        font-size: 0.78rem;
        font-weight: 500;
        cursor: pointer;
        border-radius: var(--radius-sm);
        transition: max-height 0.4s ease-in-out, opacity 0.4s ease-in-out, padding 0.4s ease-in-out, background-color 0.2s, color 0.2s;
        text-align: left;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
    }

    .sidebar-nav-sub.visible {
        max-height: 40px;
        opacity: 1;
        padding: 0.35rem 0.8rem 0.35rem 2.8rem;
        visibility: visible;
    }

    .sidebar-nav-sub:hover {
        color: var(--text-primary);
        background: rgba(255, 255, 255, 0.03);
    }

    .sidebar-nav-sub.active {
        color: var(--accent);
        background: var(--accent-soft);
    }

    /* Chevron on parent playlist item */
    .sidebar-nav-item .sidebar-chevron {
        margin-left: auto;
        font-size: 0.6rem;
        transition: transform var(--transition);
        opacity: 0.5;
    }

    .sidebar-nav-item.expanded .sidebar-chevron {
        transform: rotate(180deg);
    }

    /* ─── Sidebar Player Widget ─────────────────────── */
    .sidebar-player {
        padding: 0.75rem;
        border-top: 1px solid var(--border);
        text-align: center;
        margin-top: auto;
    }

    .sidebar-player-cover {
        width: 100%;
        aspect-ratio: 1;
        border-radius: var(--radius);
        object-fit: cover;
        cursor: pointer;
        transition: transform var(--transition);
        margin-bottom: 0.6rem;
    }

    .sidebar-player-cover:hover {
        transform: scale(1.02);
    }

    .sidebar-player-artist {
        font-size: 0.75rem;
        color: var(--text-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-player-title {
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 0.5rem;
    }

    .sidebar-player-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.6rem;
        margin-bottom: 0.5rem;
    }

    .spb-btn {
        background: none;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 0.2rem;
        transition: all var(--transition);
        display: flex;
        align-items: center;
    }

    .spb-btn svg { fill: currentColor; }

    .spb-btn:hover {
        color: var(--text-primary);
        transform: scale(1.1);
    }

    .spb-play-btn {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--text-primary) !important;
        color: var(--bg-primary) !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .spb-play-btn:hover {
        transform: scale(1.08);
        background: var(--accent) !important;
    }

    .spb-heart {
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 0.2rem;
        transition: all var(--transition);
    }

    .spb-heart svg {
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
    }

    .spb-heart.starred { color: var(--accent); }
    .spb-heart.starred svg { fill: var(--accent); }
    .spb-heart:hover { color: var(--accent); transform: scale(1.15); }

    .spb-menu {
        color: var(--text-muted);
        padding: 0.2rem;
    }
    .spb-menu:hover { color: var(--text-primary); transform: scale(1.15); }

    .sidebar-player-progress { padding: 0 0.2rem; }

    .spb-progress-bar {
        width: 100%;
        height: 3px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 2px;
        cursor: pointer;
        transition: height 0.15s;
    }

    .spb-progress-bar:hover { height: 5px; }

    .spb-progress-fill {
        height: 100%;
        background: var(--accent);
        border-radius: 2px;
        width: 0%;
        transition: none;
    }

    .spb-times {
        display: flex;
        justify-content: space-between;
        font-size: 0.65rem;
        color: var(--text-muted);
        margin-top: 0.2rem;
        font-variant-numeric: tabular-nums;
    }

    /* ─── Hide mobile playlist tabs on desktop (sidebar handles this) ─── */
    .playlist-tabs {
        display: none !important;
    }

    /* ─── Larger album covers on desktop ───────────── */
    .np-cover {
        width: 400px;
        height: 400px;
    }

    .now-playing {
        max-width: 800px;
        margin: 0 auto;
    }

    /* ─── Hide mobile swipe UI on desktop ───────────── */
    .np-swipe-container {
        height: auto;
        overflow: visible;
    }

    .np-section-previous,
    .np-section-queue,
    .np-swipe-hint {
        display: none !important;
    }

    .np-section-current {
        min-height: auto;
    }
}

/* ─── Wide desktop ─────────────────────────────────────── */
@media (min-width: 1440px) {
    .player-content {
        max-width: 1100px;
    }

    body.has-right-panel .player-content {
        max-width: none;
    }
}

/* ═══════════════════════════════════════════════════════════
   DESKTOP BOTTOM ACTIONS (Connect + Volume)
   ═══════════════════════════════════════════════════════════ */
.desktop-bottom-actions {
    display: none;
}

@media (min-width: 1024px) {
    .desktop-bottom-actions {
        display: flex;
        position: fixed;
        bottom: 0;
        right: 0;
        width: 280px; /* aligns with right-panel width */
        align-items: center;
        gap: 0.8rem;
        padding: 1rem;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        border-left: 1px solid var(--border);
        z-index: 101; /* Above right-panel */
    }

    .desktop-actions-separator {
        width: 1px;
        height: 24px;
        background: var(--border);
        margin: 0 0.4rem;
        margin-left: auto;
    }

    .desktop-connect-btn {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 4px;
        border-radius: 50%;
        transition: color 0.2s, background 0.2s;
    }

    .desktop-connect-btn:hover {
        color: var(--text-primary);
        background: var(--bg-tertiary);
    }

    .desktop-volume-widget {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.6rem;
    }

    .desktop-bottom-actions svg {
        color: var(--text-secondary);
        flex-shrink: 0;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .vol-slider {
        -webkit-appearance: none;
        appearance: none;
        width: 90px;
        height: 3px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 2px;
        outline: none;
        cursor: pointer;
    }

    .vol-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 10px;
        height: 10px;
        background: var(--text-primary);
        border-radius: 50%;
        cursor: pointer;
    }

    .vol-slider::-webkit-slider-thumb:hover {
        background: var(--accent);
    }

    .vol-slider::-moz-range-thumb {
        width: 10px;
        height: 10px;
        background: var(--text-primary);
        border-radius: 50%;
        border: none;
        cursor: pointer;
    }
}

/* ─── Song sections side-by-side on desktop ─────────────── */
.songs-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

@media (min-width: 1280px) {
    .songs-section {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0 1rem;
    }
}

/* ═══════════════════════════════════════════════════════════
   SCROLL ARROWS (desktop only, ≥1024px)
   ═══════════════════════════════════════════════════════════ */
.section-scroll-wrapper {
    position: relative;
}

.scroll-arrow {
    display: none;
}

@media (min-width: 1024px) {
    .scroll-arrow {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 50%;
        transform: translateY(-60%);
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(30, 30, 60, 0.75);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.12);
        color: var(--text-primary);
        font-size: 1.3rem;
        cursor: pointer;
        z-index: 10;
        opacity: 0;
        transition: opacity 0.2s ease, background 0.2s ease;
        line-height: 1;
        padding: 0;
    }

    .section-scroll-wrapper:hover .scroll-arrow {
        opacity: 1;
    }

    .scroll-arrow:hover {
        background: rgba(30, 30, 60, 0.95);
        border-color: var(--accent);
        color: var(--accent);
    }

    .scroll-arrow.hidden {
        opacity: 0 !important;
        pointer-events: none;
    }

    .scroll-arrow-left {
        left: -12px;
    }

    .scroll-arrow-right {
        right: -12px;
    }
}

/* ═══════════════════════════════════════════════════════════
   RIGHT PANEL (desktop only)
   ═══════════════════════════════════════════════════════════ */
.right-panel {
    display: none;
}

@media (min-width: 1280px) {
    .right-panel {
        display: flex;
        flex-direction: column;
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        background: var(--bg-secondary);
        border-left: 1px solid var(--border);
        z-index: 100;
        overflow: hidden;
        padding-bottom: 74px; /* Space for the fixed bottom actions bar */
    }

    /* Hide sidebar queue item when right panel is visible */
    #sidebar-queue-item {
        display: none;
    }

    /* Adjust layout when right panel is present */
    body.has-right-panel .player-header {
        width: calc(100% - 240px - 280px);
    }

    body.has-right-panel .player-content {
        width: calc(100% - 240px - 280px);
        margin-right: 0;
        max-width: none;
        padding-right: 0;
    }

    /* ─── Previous Tracks (top) ─── */
    .rp-section-previous {
        padding: 0.4rem 0.5rem;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }

    .rp-track-previous {
        opacity: 0.5;
        transition: opacity var(--transition), background var(--transition);
    }

    .rp-track-previous:hover {
        opacity: 1;
    }

    /* ─── Info Card COMPACT (horizontal) ─── */
    .rp-info-card-compact {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.6rem 0.5rem;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        cursor: pointer;
        transition: background var(--transition);
    }

    .rp-info-card-compact:hover {
        background: var(--bg-glass-hover);
    }

    .rp-compact-cover {
        width: 100px;
        height: 100px;
        border-radius: var(--radius);
        object-fit: cover;
        flex-shrink: 0;
    }

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

    .rp-info-title {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.15rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .rp-info-artist {
        font-size: 0.8rem;
        color: var(--text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .rp-info-album {
        font-size: 0.72rem;
        color: var(--text-muted);
        margin-top: 0.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ─── Queue Section (max 35%) ─── */
    .rp-queue-section {
        display: flex;
        flex-direction: column;
        max-height: 35%;
        min-height: 0;
        border-bottom: 1px solid var(--border);
    }

    .rp-queue-header {
        font-size: 0.78rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--accent);
        padding: 0.5rem 0.5rem 0.3rem;
        flex-shrink: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .rp-queue-list {
        flex: 1;
        overflow-y: auto;
        padding: 0 0 0 0.5rem;
        min-height: 0;
    }

    .rp-clear-queue-btn {
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 1rem;
        cursor: pointer;
        padding: 2px 4px;
        border-radius: var(--radius-sm);
        transition: all var(--transition);
        flex-shrink: 0;
        line-height: 1;
    }

    .rp-clear-queue-btn:hover {
        color: #e74c3c;
    }

    /* ─── 🌸 Autoplay Section (max 30%) ─── */
    .rp-autoplay-section {
        display: flex;
        flex-direction: column;
        max-height: 30%;
        min-height: 0;
    }

    .rp-autoplay-section.rp-autoplay-off {
        max-height: none;
        flex: 0;
    }

    .rp-autoplay-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem;
        flex-shrink: 0;
    }

    .rp-autoplay-header:hover {
        background: var(--bg-glass-hover);
    }

    .rp-autoplay-header span:first-child {
        font-size: 0.78rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        color: #c084fc;
    }

    .rp-autoplay-switch {
        font-size: 0.65rem;
        font-weight: 700;
        padding: 0.15rem 0.5rem;
        border-radius: var(--radius-pill);
        background: var(--bg-glass);
        color: var(--text-muted);
        transition: all var(--transition);
    }

    .rp-autoplay-switch.on {
        background: rgba(192, 132, 252, 0.2);
        color: #c084fc;
    }

    .rp-autoplay-list {
        flex: 1;
        overflow-y: auto;
        padding: 0 0.5rem;
        min-height: 0;
    }

    .rp-track-suggestion {
        opacity: 0.7;
        border-left: 2px solid rgba(192, 132, 252, 0.3);
        transition: opacity var(--transition), background var(--transition);
    }

    .rp-track-suggestion:hover {
        opacity: 1;
    }

    /* ─── 🔗 Cyle Connect — Device Bar ─── */
    .rp-devices-bar {
        flex-shrink: 0;
        margin-top: auto;
        padding: 0.5rem 0.6rem;
        border-top: 1px solid var(--border);
        background: rgba(0, 0, 0, 0.15);
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .rp-devices-header {
        font-size: 0.65rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        margin-bottom: 0.3rem;
    }

    .rp-device-item {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.3rem 0.4rem;
        border-radius: var(--radius-sm);
        font-size: 0.8rem;
        transition: background var(--transition);
    }

    .rp-device-item:hover {
        background: var(--bg-glass);
    }

    .rp-device-me {
        color: var(--accent);
        font-weight: 500;
    }

    .rp-device-playing {
        background: rgba(var(--accent-rgb, 0, 212, 255), 0.08);
        box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb, 0, 212, 255), 0.15);
    }

    .rp-device-icon {
        font-size: 0.7rem;
        flex-shrink: 0;
    }

    .rp-device-name {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: var(--text-secondary);
    }

    .rp-device-me .rp-device-name {
        color: var(--accent);
    }

    .rp-device-btn {
        background: transparent;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        cursor: pointer;
        padding: 0.15rem 0.35rem;
        font-size: 0.7rem;
        line-height: 1;
        transition: all var(--transition);
        opacity: 0.6;
    }

    .rp-device-btn:hover {
        opacity: 1;
        border-color: var(--accent);
        background: rgba(var(--accent-rgb, 0, 212, 255), 0.1);
    }

    .rp-device-offline {
        font-size: 0.75rem;
        color: var(--text-muted);
        padding: 0.2rem 0;
    }

    /* ─── Track Row (compact) ─── */
    .rp-track-row {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.4rem;
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition: background var(--transition);
    }

    .rp-track-row:hover {
        background: var(--bg-glass-hover);
    }

    .rp-track-cover {
        width: 36px;
        height: 36px;
        border-radius: 4px;
        overflow: hidden;
        flex-shrink: 0;
        background: var(--bg-card);
    }

    .rp-track-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

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

    .rp-track-title {
        font-size: 0.8rem;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .rp-track-artist {
        font-size: 0.7rem;
        color: var(--text-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .rp-track-dur {
        font-size: 0.7rem;
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .rp-empty {
        text-align: center;
        padding: 2rem 1rem;
        color: var(--text-muted);
        font-size: 0.85rem;
    }

    .rp-empty-small {
        text-align: center;
        padding: 0.8rem 0.5rem;
        color: var(--text-muted);
        font-size: 0.75rem;
    }

    .rp-info-quality {
        font-size: 0.65rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.1em;
        margin-top: 0.8rem;
    }
}
