:root { 
    --p: #2074fa; 
    --glass: rgba(255, 255, 255, 0.05); 
    --border: rgba(255, 255, 255, 0.1); 
    --bg: #050505;
    --text: white;
    --item-bg: rgba(255, 255, 255, 0.05);
    --item-hover: rgba(255, 255, 255, 0.1);
}
body.light-mode {
    --bg: #f3f4f6;
    --text: #1f2937;
    --glass: rgba(255, 255, 255, 0.75);
    --border: rgba(0, 0, 0, 0.1);
    --item-bg: rgba(0, 0, 0, 0.05);
    --item-hover: rgba(0, 0, 0, 0.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Outfit', sans-serif; }
body { background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; transition: background 0.3s, color 0.3s; }
body.loading { overflow: hidden; }

.startup-loader {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top, rgba(32, 116, 250, 0.25), rgba(5, 5, 5, 0.95) 55%);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.startup-loader.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.startup-loader-inner {
    width: min(92vw, 360px);
    text-align: center;
    padding: 30px 24px;
    border-radius: 24px;
    background: rgba(10, 10, 10, 0.7);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.startup-brand {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 8px;
    color: var(--p);
}
.startup-loader-inner p {
    margin-top: 8px;
    font-size: 14px;
    opacity: 0.75;
}

.bg-overlay { position: fixed; inset: 0; background-size: cover; filter: blur(100px) brightness(0.2); z-index: -3; transition: 1.5s ease; }
body.light-mode .bg-overlay { filter: blur(100px) brightness(1.1); opacity: 0.5; }
#visualizer { position: fixed; inset: 0; z-index: -1; pointer-events: none; width: 100%; height: 100%; }
.custom-bg { position: fixed; inset: 0; background-size: cover; z-index: -2; opacity: 0.25; }

.app-container { display: grid; grid-template-columns: 280px 1fr; height: 100vh; padding: 20px; gap: 20px; }
.content-area { overflow: hidden; height: 100%; position: relative; }
.glass { background: var(--glass); backdrop-filter: blur(25px); border: 1px solid var(--border); border-radius: 30px; }

/* Sidebar */
.sidebar { padding: 40px; display: flex; flex-direction: column; }
.logo { font-size: 28px; letter-spacing: 6px; margin-bottom: 50px; color: var(--p); font-weight: 800; }
.nav-item { padding: 15px; cursor: pointer; display: flex; align-items: center; gap: 15px; opacity: 0.6; transition: 0.3s; }
.nav-item.active, .nav-item:hover { opacity: 1; color: var(--p); }
.sidebar .user-profile { margin-top: auto; display: flex; align-items: center; cursor: pointer; }
.sidebar .user-profile .avatar { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--p); }
.sidebar .user-profile span { margin-left: 10px; }

/* Spotify Grid Home */
.home-grid { position: absolute; inset: 0; padding-top: 80px; display: flex; flex-direction: column; gap: 40px; overflow-y: auto; }
.scroll-view { position: absolute; inset: 0; padding-top: 80px; overflow-y: auto; }
.horizontal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; }
.playlist-card { display: flex; align-items: center; gap: 15px; padding: 10px; cursor: pointer; }
.playlist-card img { width: 50px; border-radius: 8px; }

.vertical-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; padding-bottom: 100px; }
.song-card { padding: 15px; border-radius: 20px; transition: 0.3s; cursor: pointer; }
.song-card:hover { background: var(--item-hover); transform: translateY(-5px); }
.song-card img { width: 100%; aspect-ratio: 1; border-radius: 12px; margin-bottom: 10px; }

/* Horizontal Shelf (Spotify Style) */
.shelf-view { display: flex; overflow-x: auto; gap: 20px; padding-bottom: 15px; scroll-snap-type: x mandatory; }
.shelf-view::-webkit-scrollbar { height: 6px; }
.shelf-view .song-card { min-width: 160px; width: 160px; flex-shrink: 0; scroll-snap-align: start; }

/* Player UI */
.player-container { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; height: 100%; text-align: center; padding-top: 110px; }
.art-frame { width: 280px; height: 280px; border-radius: 20px; overflow: hidden; margin-bottom: 20px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); position: relative; }
.art-frame img { width: 100%; height: 100%; object-fit: cover; }
.video-surface { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; border-radius: inherit; overflow: hidden; background: #000; }
.video-surface.video-hidden { opacity: 0; pointer-events: none; }
#track-art { position: relative; z-index: 1; }
.play-btn { width: 75px; height: 75px; background: white; color: black; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.player-controls { width: min(92vw, 430px); }
.floating-control-deck {
    width: 100%;
    border-radius: 28px;
    padding: 12px 16px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}
.transport-row-compact i,
.utility-row-compact i {
    width: 20px;
    height: 20px;
}
.mode-toggle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 12px;
}
.mode-btn {
    border: none;
    border-radius: 999px;
    padding: 6px 14px;
    background: transparent;
    color: var(--text);
    opacity: 0.75;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}
.mode-btn.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.18);
}
.mode-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Top Search Bar & Results */
.search-bar-wrapper { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: 100%; max-width: 550px; padding: 12px 20px; display: flex; gap: 15px; z-index: 1001; }
.search-bar-wrapper input { background: none; border: none; color: var(--text); width: 100%; outline: none; }
.search-bar-wrapper i[data-lucide="list-music"] { cursor: pointer; margin-left: 10px; }
#search-results { position: absolute; top: 70px; left: 0; width: 100%; max-width: 550px; max-height: 400px; overflow-y: auto; z-index: 1000; padding: 10px; background: rgba(10, 10, 10, 0.7); backdrop-filter: blur(25px); border-radius: 20px; border: 1px solid var(--border); box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.track-item { display: flex; gap: 15px; padding: 10px; border-radius: 10px; cursor: pointer; margin-bottom: 5px; }

/* Queue Sidebar */
.queue-sidebar { padding: 25px; display: flex; flex-direction: column; overflow: hidden; position: fixed; right: 25px; top: 25px; bottom: 25px; width: 300px; transform: translateX(120%); opacity: 0; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease; z-index: 1500; }
.queue-sidebar.show { transform: translateX(0); opacity: 1; }
.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0;
}
.queue-header h3 {
    font-size: 20px;
    font-weight: 600;
}
.queue-controls {
    display: flex;
    gap: 5px;
}
.queue-controls button {
    background: none; border: none; color: var(--text); opacity: 0.6; cursor: pointer; transition: 0.3s; padding: 5px; border-radius: 5px;
}
.queue-controls button:hover { opacity: 1; background: var(--item-hover); }
.queue-controls button.active { opacity: 1; color: var(--p); }
.queue-list { flex: 1 1 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.queue-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: var(--item-bg); cursor: grab; transition: 0.2s; }
.queue-item:hover { background: var(--item-hover); }
.queue-item.active { border: 1px solid var(--p); background: rgba(59, 130, 246, 0.1); }
.queue-item img { width: 40px; height: 40px; border-radius: 5px; object-fit: cover; }
.queue-info { flex: 1; overflow: hidden; }
.queue-info b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-info span { font-size: 12px; opacity: 0.6; }
.remove-btn { color: #ff4444; opacity: 0; cursor: pointer; transition: 0.2s; }
.queue-item:hover .remove-btn { opacity: 1; }
.track-item:hover .remove-btn { opacity: 1; }

.hidden { display: none !important; }

/* Dropdown Menu */
.dropdown-menu { position: absolute; top: 110%; left: 0; background: #1e1e1e; border: 1px solid var(--border); border-radius: 10px; padding: 5px; display: flex; flex-direction: column; gap: 5px; min-width: 160px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(20px); }
.dropdown-item { padding: 10px; cursor: pointer; border-radius: 5px; transition: 0.2s; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.dropdown-item:hover { background: var(--item-hover); }

/* Scrollbar Styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

/* Loading Spinner */
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: var(--p); animation: spin 1s ease-in-out infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin-anim { animation: spin 0.5s linear; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container { grid-template-columns: 1fr; padding: 10px; gap: 0; }
    .sidebar { position: fixed; inset: 0; width: 80%; max-width: 300px; z-index: 2000; transform: translateX(-100%); transition: transform 0.3s ease; background: var(--bg); border-right: 1px solid var(--border); }
    .sidebar.mobile-open { transform: translateX(0); box-shadow: 10px 0 50px rgba(0,0,0,0.5); }
    
    .content-area { padding-top: 70px; }
    .search-bar-wrapper { width: calc(100% - 40px); top: 10px; }
    #mobile-menu-btn { display: block !important; }
    
    .queue-sidebar { width: 100%; right: 0; top: 0; bottom: 0; transform: translateX(100%); }
    .queue-sidebar.show { transform: translateX(0); }
    
    .art-frame { width: min(320px, 64vw); height: min(320px, 64vw); }
    .controls { width: 100%; }
    .player-controls { width: min(95vw, 460px); }
    .play-btn { width: 70px; height: 70px; }
    .floating-control-deck { padding: 14px 18px; border-radius: 26px; }
    .player-container { padding-top: 120px; }
    
    .horizontal-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .vertical-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* Short-height screens: keep full artwork visible and allow player scrolling */
@media (max-height: 760px) {
    .player-container {
        justify-content: flex-start;
        overflow-y: auto;
        padding-top: 96px;
        padding-bottom: 18px;
    }

    .art-frame {
        width: min(300px, 60vw);
        height: min(300px, 60vw);
        margin-bottom: 12px;
    }

    #player-view .track-info {
        margin-bottom: 10px !important;
    }

    #player-view .controls > div {
        margin-bottom: 12px !important;
    }

    .play-btn { width: 66px; height: 66px; }
    .floating-control-deck { padding: 12px 16px; }
    .transport-row-compact { gap: 20px !important; }
    .utility-row-compact { gap: 16px !important; margin-bottom: 10px !important; }
    .volume-row-compact { margin-top: 0 !important; }
}

@media (max-height: 640px) {
    .player-container {
        padding-top: 68px;
    }

    .art-frame {
        width: min(250px, 54vw);
        height: min(250px, 54vw);
    }

    .floating-control-deck {
        padding: 10px 14px;
        border-radius: 22px;
    }

    .play-btn { width: 60px; height: 60px; }
    .transport-row-compact { gap: 18px !important; margin-bottom: 8px !important; }
    .utility-row-compact { margin-bottom: 8px !important; }
}
