:root {
    --bg: #121212;
    --card: #181818;
    --text: #fff;
    --sub: #b3b3b3;
    --green: #1db954;
}

body.light {
    --bg: #f2f2f2;
    --card: #fff;
    --text: #000;
    --sub: #555;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Loading Screen Styles */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.loading-credits {
    text-align: center;
    margin-top: 20px;
    opacity: 0.8;
}

.loading-credits .version {
    color: #1DB954;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.loading-credits .creator {
    color: #b3b3b3;
    font-size: 13px;
    font-weight: 400;
}

.loading-credits .creator-name {
    color: #fff;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #1DB954 0%, #1ed760 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.spotify-logo {
    width: 300px;
    max-width: 90vw;
    height: auto;
    animation: logoFade 2s ease-in-out infinite;
    object-fit: contain;
}

@keyframes logoFade {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 0.8;
        transform: translateY(0);
    }
}

.loading-credits {
    animation: fadeInUp 1s ease-out 0.5s both;
}

.loading-bars {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    height: 50px;
}

.loading-bars .bar {
    width: 6px;
    background: linear-gradient(to top, #1DB954, #1ed760);
    border-radius: 3px;
    animation: barDance 1.2s ease-in-out infinite;
}

.loading-bars .bar:nth-child(1) {
    animation-delay: 0s;
}

.loading-bars .bar:nth-child(2) {
    animation-delay: 0.1s;
}

.loading-bars .bar:nth-child(3) {
    animation-delay: 0.2s;
}

.loading-bars .bar:nth-child(4) {
    animation-delay: 0.3s;
}

.loading-bars .bar:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes barDance {
    0%, 100% {
        height: 10px;
    }
    50% {
        height: 50px;
    }
}

body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    overflow: hidden;
    transition: background 0.4s ease;
    padding: 10px;
}

/* Blur background */
.bg {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(40px) brightness(.4);
    transform: scale(1.2);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.8s ease, background-image 0.8s ease;
}

/* Overlay for closing sidebar */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    display: none;
    z-index: 40;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 260px;
    height: 100%;
    background: var(--card);
    padding: 20px 8px 20px 20px;
    transition: left .4s;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
}

/* Scrollbar Styling - WebKit (Chrome, Safari, Edge) */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--green);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #1ed760;
}

/* Remove scrollbar buttons completely */
.sidebar::-webkit-scrollbar-button {
    width: 0;
    height: 0;
    display: none;
}

.sidebar::-webkit-scrollbar-button:increment,
.sidebar::-webkit-scrollbar-button:decrement {
    display: none;
}

/* Firefox Scrollbar */
.sidebar {
    scrollbar-color: var(--green) transparent;
    scrollbar-width: thin;
}

.sidebar.show {
    left: 0;
}

.sidebar h3 {
    color: var(--text);
    margin-bottom: 15px;
    font-size: 20px;
}

/* Search Container */
.search-container {
    position: relative;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 20px;
    width: 18px;
    height: 18px;
    pointer-events: none;
    opacity: 0.6;
    filter: brightness(1.2);
}

.search-input {
    width: 100%;
    padding: 10px 35px 10px 38px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    transition: all 0.2s;
    outline: none;
}

.search-input::placeholder {
    color: var(--sub);
}

.search-input:focus {
    border-color: var(--green);
    background: rgba(255, 255, 255, 0.15);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--sub);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    transition: all 0.2s;
}

.clear-search-btn:hover {
    color: var(--text);
    transform: scale(1.2);
}

/* Hide non-matching items */
.playlist-song.hidden,
.category-header.hidden {
    display: none !important;
}

.sidebar div {
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    color: var(--sub);
    transition: background .2s;
}

.sidebar div:hover {
    background: rgba(255, 255, 255, .1);
}

.sidebar div.active {
    background: var(--green);
    color: #000;
    font-weight: bold;
}

/* Category Header Styling */
.sidebar .category-header {
    padding: 14px 40px 14px 15px !important;
    color: #fff !important;
    background: linear-gradient(135deg, var(--green) 0%, #169c46 100%) !important;
    font-weight: bold !important;
    font-size: 15px !important;
    margin-top: 15px !important;
    margin-bottom: 10px !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    border-radius: 12px !important;
    cursor: grab !important;
    position: relative !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 12px rgba(29, 185, 84, 0.3) !important;
    border: 2px solid transparent !important;
}

.sidebar .category-header:hover {
    transform: translateX(5px) scale(1.02) !important;
    box-shadow: 0 6px 20px rgba(29, 185, 84, 0.5) !important;
}

.sidebar .category-header.dragging {
    opacity: 0.6 !important;
    cursor: grabbing !important;
    transform: scale(1.08) rotate(3deg) !important;
    box-shadow: 0 10px 30px rgba(29, 185, 84, 0.6) !important;
    z-index: 1000 !important;
    border: 2px dashed #fff !important;
}

.sidebar .category-header.drag-over {
    border: 3px solid #ffd700 !important;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%) !important;
    color: #000 !important;
    transform: translateY(-5px) !important;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.5) !important;
}

/* Drag handle indicator */
.sidebar .category-header::before {
    content: '⋮⋮';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.9);
    font-size: 22px;
    font-weight: bold;
    letter-spacing: -2px;
    opacity: 1;
    transition: all 0.3s ease;
}

.sidebar .category-header:hover::before {
    color: #fff;
    right: 10px;
    animation: dragHint 0.8s ease infinite;
}

@keyframes dragHint {
    0%, 100% {
        transform: translateY(-50%);
    }
    50% {
        transform: translateY(-45%);
    }
}

.sidebar .category-header.dragging::before {
    content: '↕';
    font-size: 24px;
    animation: none;
}

/* Playlist Song Styling */
.sidebar .playlist-song {
    padding-left: 20px !important;
    margin-bottom: 8px !important;
    font-size: 13px !important;
    transition: all 0.2s ease !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-left: 3px solid transparent !important;
    position: relative !important;
}

/* Favourite icon in playlist */
.sidebar .playlist-song .fav-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #ff6b6b;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar .playlist-song.favourite .fav-icon {
    opacity: 1;
}

.sidebar .playlist-song:hover {
    color: var(--green) !important;
    background: rgba(29, 185, 84, 0.1) !important;
    transform: translateX(5px) !important;
    border-left-color: var(--green) !important;
}

.sidebar .playlist-song.active {
    color: var(--green) !important;
    background: rgba(29, 185, 84, 0.25) !important;
    font-weight: 600 !important;
    border-left-color: var(--green) !important;
}

/* Player */
.player {
    width: 380px;
    max-width: 100%;
    background: var(--card);
    border-radius: 25px;
    padding: 25px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .7);
    position: relative;
    animation: fadeIn 0.5s ease-in;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Top buttons */
.mode-toggle,
.playlist-toggle {
    position: absolute;
    top: 15px;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform .2s;
    z-index: 10;
}

.mode-toggle:hover,
.playlist-toggle:hover {
    transform: scale(1.1);
}

.mode-toggle {
    left: 15px;
}

.playlist-toggle {
    right: 15px;
    font-size: 26px;
    color: var(--text);
}

.undo-button {
    position: absolute;
    top: 15px;
    right: 50px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--sub);
    transition: transform .2s, color .2s;
}

.undo-button:hover {
    transform: scale(1.15) rotate(-15deg);
    color: var(--green);
}

.undo-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mode-toggle img {
    width: 26px;
    filter: invert(1);
}

body.light .mode-toggle img {
    filter: invert(0);
}

/* Disc */
.cover-wrap {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.cover {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
    transition: transform 0.3s ease, background-image 0.5s ease;
    animation: spin 6s linear infinite;
    animation-play-state: paused;
}

.cover.playing {
    animation-play-state: running;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Song info */
.song-info {
    text-align: center;
    margin: 15px 0 10px 0;
    position: relative;
    padding: 0 30px;
}

.song-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.song-info h3 {
    font-size: 20px;
    margin-bottom: 0;
    transition: opacity 0.3s ease;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.song-info p {
    color: var(--sub);
    font-size: 14px;
    margin-top: 5px;
    transition: opacity 0.3s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Favourite Button */
.btn-favourite-inline {
    background: none;
    border: none;
    cursor: pointer;
    transition: all .3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.btn-favourite-inline:hover {
    transform: translateY(-50%) scale(1.2);
}

.btn-favourite-inline svg {
    transition: all .3s ease;
}

.btn-favourite-inline .heart-outline {
    stroke: var(--sub);
}

.btn-favourite-inline.active .heart-outline {
    display: none;
}

.btn-favourite-inline.active .heart-filled {
    display: block !important;
    color: #ff6b6b;
}

.btn-favourite-inline:hover .heart-outline {
    stroke: #ff6b6b;
}

.btn-favourite-inline.active:hover .heart-filled {
    filter: brightness(1.2);
}

.btn-favourite-inline.active .heart-filled {
    animation: heartBeat 0.4s ease;
}

/* Waveform */
.wave-container {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    height: 60px;
}

#wave {
    display: block;
    max-width: 100%;
}

/* Progress */
.progress-container {
    margin-top: 15px;
}

.progress {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 20px;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

body.light .progress {
    background: #ddd;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1db954, #1ed760);
    transition: width .1s linear;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s;
}

.progress:hover .progress-bar::after {
    opacity: 1;
}

/* Time */
.time {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--sub);
    margin-top: 6px;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-top: 20px;
}

.btn {
    background: none;
    border: none;
    color: var(--sub);
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.btn:hover {
    color: var(--text);
    transform: scale(1.1);
}

.btn svg {
    display: block;
}

.play {
    background: var(--green);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
}

.play svg {
    color: #000;
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.play .play-icon {
    margin-left: 0px;
}

.play:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(29, 185, 84, .4);
}

.play:active {
    transform: scale(0.98);
}

/* Volume */
.volume {
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.volume img {
    width: 26px;
    filter: invert(1);
}

body.light .volume img {
    filter: invert(0);
}

.volume input {
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 6px;
    border-radius: 10px;
    background: linear-gradient(to right, var(--green) 100%, #333 0%);
    cursor: pointer;
    outline: none;
}

body.light .volume input {
    background: linear-gradient(to right, var(--green) 100%, #ccc 0%);
}

.volume input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 10px rgba(30, 215, 96, .8);
    cursor: pointer;
}

.volume input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 10px rgba(30, 215, 96, .8);
    cursor: pointer;
    border: none;
}


/* ========== MOBILE RESPONSIVE STYLES ========== */

/* Tablets and smaller laptops */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .player {
        width: 100%;
        max-width: 400px;
        padding: 20px;
        border-radius: 20px;
    }
    
    .cover {
        width: 200px;
        height: 200px;
    }
    
    .sidebar {
        width: 240px;
        left: -250px;
    }
    
    .song-info h3 {
        font-size: 18px;
    }
    
    .song-info p {
        font-size: 13px;
    }
    
    #wave {
        width: 250px;
    }
}

/* Mobile phones (landscape) */
@media (max-width: 640px) and (orientation: landscape) {
    body {
        padding: 5px;
        align-items: flex-start;
        padding-top: 10px;
    }
    
    .player {
        width: 100%;
        max-width: 90vw;
        padding: 15px;
        border-radius: 15px;
    }
    
    .cover-wrap {
        margin-top: 10px;
    }
    
    .cover {
        width: 140px;
        height: 140px;
    }
    
    .song-info {
        margin: 10px 0 5px 0;
    }
    
    .song-info h3 {
        font-size: 16px;
    }
    
    .song-info p {
        font-size: 12px;
        margin-top: 3px;
    }
    
    .wave-container {
        height: 40px;
        margin: 10px 0;
    }
    
    #wave {
        width: 200px;
        height: 40px;
    }
    
    .controls {
        gap: 20px;
        margin-top: 10px;
    }
    
    .play {
        width: 50px;
        height: 50px;
    }
    
    .btn svg {
        width: 20px;
        height: 20px;
    }
    
    .volume {
        margin-top: 10px;
    }
    
    .volume input {
        width: 100px;
    }
}

/* Mobile phones (portrait) */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .loading-credits .version {
        font-size: 12px;
    }
    
    .loading-credits .creator {
        font-size: 11px;
    }
    
    .player {
        width: 100%;
        max-width: 100%;
        padding: 20px 15px;
        border-radius: 20px;
    }
    
    .mode-toggle,
    .playlist-toggle {
        top: 10px;
    }
    
    .mode-toggle {
        left: 10px;
    }
    
    .playlist-toggle {
        right: 10px;
        font-size: 24px;
    }
    
    .mode-toggle img {
        width: 22px;
    }
    
    .cover-wrap {
        margin-top: 15px;
    }
    
    .cover {
        width: 180px;
        height: 180px;
    }
    
    .song-info {
        margin: 12px 0 8px 0;
        padding: 0 25px;
    }
    
    .song-info h3 {
        font-size: 17px;
    }
    
    .song-info p {
        font-size: 13px;
    }
    
    .btn-favourite-inline svg {
        width: 18px;
        height: 18px;
    }
    
    .wave-container {
        height: 50px;
        margin: 12px 0;
    }
    
    #wave {
        width: 100%;
        max-width: 280px;
        height: 50px;
    }
    
    .progress-container {
        margin-top: 12px;
    }
    
    .controls {
        gap: 25px;
        margin-top: 15px;
    }
    
    .play {
        width: 56px;
        height: 56px;
    }
    
    .play svg {
        width: 24px;
        height: 24px;
    }
    
    .btn {
        padding: 6px;
    }
    
    .btn svg {
        width: 22px;
        height: 22px;
    }
    
    .volume {
        margin-top: 15px;
        gap: 10px;
    }
    
    .volume img {
        width: 22px;
    }
    
    .volume input {
        width: 120px;
    }
    
    
    .sidebar {
        width: 80%;
        max-width: 280px;
        left: -100%;
    }
    
    .sidebar h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .search-input {
        font-size: 12px;
        padding: 9px 32px 9px 36px;
    }
    
    .search-icon {
        width: 16px;
        height: 16px;
        left: 15px;
    }
    
    .sidebar .category-header {
        font-size: 13px !important;
        padding: 12px 35px 12px 12px !important;
    }
    
    .sidebar .playlist-song {
        font-size: 12px !important;
        padding: 8px 8px 8px 15px !important;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .loading-credits .version {
        font-size: 11px;
    }
    
    .loading-credits .creator {
        font-size: 10px;
    }
    
    .player {
        padding: 18px 12px;
        border-radius: 18px;
    }
    
    .cover {
        width: 160px;
        height: 160px;
    }
    
    .song-info h3 {
        font-size: 16px;
    }
    
    .song-info p {
        font-size: 12px;
    }
    
    #wave {
        width: 100%;
        max-width: 240px;
        height: 45px;
    }
    
    .controls {
        gap: 20px;
    }
    
    .play {
        width: 52px;
        height: 52px;
    }
    
    .play svg {
        width: 22px;
        height: 22px;
    }
    
    .btn svg {
        width: 20px;
        height: 20px;
    }
    
    .volume input {
        width: 100px;
    }
    
}

/* Prevent text selection on touch devices */
@media (hover: none) and (pointer: coarse) {
    .player,
    .sidebar,
    .controls,
    .progress {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Larger touch targets for mobile */
    .btn,
    .play,
    .mode-toggle,
    .playlist-toggle,
    .btn-favourite-inline {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Improve progress bar touch interaction */
    .progress {
        height: 8px;
        padding: 5px 0;
    }
    
    .progress-bar::after {
        width: 14px;
        height: 14px;
        opacity: 1;
    }
}

/* Dark mode adjustments for mobile */
@media (prefers-color-scheme: dark) {
    body {
        background: var(--bg);
    }
}