html, body {
    margin-top: 20px;
    height: auto;
    overflow-y: auto;
    font-family: Arial, sans-serif;
}

/* Smooth Fade-In Effect */
body {
    opacity: 0;
    animation: fadeIn 1s ease-in-out forwards;
    /* Default Light Mode */
    background-color: white;
    color: black;
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out;
}

/* If dark mode is enabled, override before fade-in */
body.dark-mode {
    background-color: black;
    color: white;
}

/* Dark Mode Styles for Song List */
body.dark-mode #songList {
    background-color: #222; /* Dark background */
}

body.dark-mode #songList .list-group-item {
    background-color: #333; /* Darker shade for items */
    color: white; /* White text */
    border-bottom: 1px solid white !important;
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out, border-color 0.8s ease-in-out;
}

body.dark-mode #songList .list-group-item:hover {
    background-color: #444; /* Lighter shade on hover */
}

body.dark-mode #songList .list-group-item.selected {
    background-color: #007bff; /* Keep blue for selected */
    color: white;
}

/* Ensure text inside song list elements also adapts */
body.dark-mode #songList .song,
body.dark-mode #songList .author {
    color: white !important;
    transition: color 0.8s ease-in-out;
}

/* Keyframe Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Dark Mode */
body.dark-mode {
    background-color: black;
    color: white;
}

/* Dark Mode for Cards */
.card {
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out;
}

.card.dark-mode {
    background-color: #222;
    color: white;
}

/* Dark Mode Toggle Button */
#darkModeToggle {
    background-color: black;
    color: white;
    padding: 10px 15px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out, transform 0.1s ease-in-out;
}

/* Dark Mode - Toggle to White */
body.dark-mode #darkModeToggle {
    background-color: white;
    color: black;
}

/* Click Animation (Shrink Effect) */
#darkModeToggle:active {
    transform: scale(0.9); /* Shrinks when clicked */
}

/* Default Light Mode */
box-icon {
    fill: #333; /* Default dark gray color */
    transition: fill 0.8s ease-in-out;
}

/* Dark Mode */
body.dark-mode box-icon {
    fill: #ddd !important; /* Lighter color for dark mode */
}

.btn-dark-mode-toggle {
    background-color: black !important;
    color: white !important;
    border: 2px solid black !important;
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out, border 0.8s ease-in-out, opacity 0.8s ease-in-out !important;
    opacity: 1;
}

/* Dark Mode - Fade to White */
body.dark-mode .btn-dark-mode-toggle {
    background-color: white !important;
    color: black !important;
    border: 2px solid white !important;
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out, border 0.8s ease-in-out, opacity 0.8s ease-in-out;
}

/* Fade Effect */
.btn-dark-mode-toggle:hover {
    opacity: 0.7;
    transition: opacity 0.8s ease-in-out;
}

body.dark-mode .btn-dark-mode-toggle:hover {
    opacity: 0.7;
    transition: opacity 0.8s ease-in-out;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding-bottom: 20px;
}

/* 🎵 Music Player Card */
.music-player {
    width: 350px;
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

/* 🎵 Center Album Art */
.album-art-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 250px; /* Maximum size */
    margin: 0 auto; /* Center the container */
}

#albumArt {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1; /* Maintain square aspect ratio */
    object-fit: cover;
    border-radius: 50%;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
    max-width: 250px; /* Maximum size */
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .album-art-container {
        max-width: 200px; /* Smaller on mobile */
    }
    
    #albumArt {
        max-width: 200px; /* Smaller on mobile */
    }
}

@media (max-width: 576px) {
    .album-art-container {
        max-width: 150px; /* Even smaller on very small screens */
    }
    
    #albumArt {
        max-width: 150px; /* Even smaller on very small screens */
    }
}

/* 🎵 Controls */
.controls {
    padding-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}        

/* Play/Pause Button */
#playPauseBtn, #prevBtn, #nextBtn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: #007bff;
    color: white;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, transform 0.1s;
    padding: 10px;
    line-height: 1; /* Ensures vertical centering */
    flex-shrink: 0; /* Prevent shrinking */
}

/* Auto-play and Repeat controls container */
.d-flex.justify-content-between.align-items-center.mt-3 {
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 15px;
    justify-content: space-between !important;
}

/* Auto-play toggle - always on left side */
.auto-play-toggle {
    order: 1; /* Force to left side */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Repeat button section - always on right side */
.d-flex.align-items-center.gap-2 {
    order: 2; /* Force to right side */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Default layout - items in row */
.auto-play-toggle,
.d-flex.align-items-center.gap-2 {
    flex-direction: row;
    flex-wrap: nowrap;
}

/* Text labels */
.auto-play-toggle span,
.d-flex.align-items-center.gap-2 span {
    font-size: 12px;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
}

/* Switch and button styling */
.switch {
    margin-bottom: 2px;
}

#repeatBtn {
    margin-bottom: 2px;
}

/* For larger screens - switch to horizontal layout */
@media (min-width: 1025px) {
    .auto-play-toggle,
    .d-flex.align-items-center.gap-2 {
        flex-direction: row;
        gap: 10px;
    }
    
    .auto-play-toggle span,
    .d-flex.align-items-center.gap-2 span {
        font-size: 14px;
    }
}

/* For medium screens - keep text below but adjust spacing */
@media (max-width: 1024px) and (min-width: 769px) {
    .auto-play-toggle,
    .d-flex.align-items-center.gap-2 {
        gap: 3px;
    }
    
    .auto-play-toggle span,
    .d-flex.align-items-center.gap-2 span {
        font-size: 11px;
    }
}

/* For very small screens - make text even smaller */
@media (max-width: 400px) {
    .auto-play-toggle span,
    .d-flex.align-items-center.gap-2 span {
        font-size: 10px;
    }
}

/* Responsive adjustments for medium screens */
@media (max-width: 992px) {
    .auto-play-toggle span,
    .d-flex.align-items-center.gap-2 span {
        font-size: 13px;
    }
}


/* Ensure text doesn't overflow */
.song-title, .author-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

#playPauseBtn:active, #prevBtn:active, #nextBtn:active {
    transform: scale(0.9);
}        

#playPauseBtn:hover, #prevBtn:hover, #nextBtn:hover {
    background: #0056b3;
}

.progress-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    touch-action: none; /* Prevent browser scrolling on touch */

}

.progress {
    width: 95%;
    height: 6px;
    background: #ddd;
    border-radius: 5px;
    position: relative;
    cursor: pointer;
    margin: 5px auto;
    display: block;
    -webkit-user-select: none; /* Disable selection on iOS */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.time-display {
    display: flex;
    justify-content: space-between;
    width: 95%;
    font-size: 12px;
    margin-top: 2px; /* Reduce space between progress bar and time */
}


/* 🎵 Song Selector */
select {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
    margin-top: 10px;
    cursor: pointer;
}

/* 🎵 Hide YouTube Player */
.player-container {
    display: flex;
    gap: 20px;
}

.song-selector {
    width: 800px;
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

/* 🎵 Error Message */
#errorMessage {
    color: red;
    font-size: 14px;
    margin-top: 10px;
    display: none;
}

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

.rotate {
    animation: rotate 5s linear infinite;
}

.rotate-paused {
    animation-play-state: paused;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px; /* Adjust spacing */
}

.volume-control input[type="range"] {
    flex-grow: 1; /* Makes slider take available space */
}

/* Remove border from the song list container */
#songList {
    border: none !important;
    border-radius: 0 !important;
}

/* Add horizontal lines between songs */
#songList .list-group-item {
    border-bottom: 1px solid #ddd !important; /* Light grey separator */
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    padding: 10px 15px; /* Adjust spacing for better readability */
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out, border-color 0.8s ease-in-out;
}

/* Remove border from the last item to avoid extra line */
#songList .list-group-item:last-child {
    border-bottom: none !important;
}

#songList li {
    display: flex;
    justify-content: space-between; /* Creates left-right separation */
    align-items: center;
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
    transition: background 0.3s;
}

#songList li:last-child {
    border-bottom: none;
}

#songList li:hover {
    background: #f0f0f0;
}

#songList li.selected {
    background: #007bff;
    color: white;
    font-weight: bold;
}

.song {
    flex: 1;
    text-align: left;  /* Align song name to the left */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

.author {
    flex: 1;
    text-align: right; /* Align author name to the right */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

#background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(20px); /* Adjust blur intensity */
    z-index: -1; /* Send background behind everything */
    transition: background-image 0.5s ease-in-out;
}

/* 🎵 Auto-Play Toggle Styling */
.auto-play-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: bold;
}

/* 🎵 Switch Container */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 25px;
}

/* 🎵 Hide Default Checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* 🎵 Slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 25px;
}

/* 🎵 Slider Circle */
.slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

/* 🎵 Toggle ON */
.switch input:checked + .slider {
    background-color: #007bff;
}

/* 🎵 Move Circle when ON */
.switch input:checked + .slider::before {
    transform: translateX(24px);
}

/* 🎵 Repeat Button Styling */
/* 🎵 Controls Container */
.controls-container {
    display: flex;
    align-items: center;
    justify-content: center; /* Center horizontally */
    gap: 15px; /* Adjust spacing */
    margin-top: 10px;
}

/* 🎵 Auto-Play Toggle */
.auto-play-toggle, .repeat-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: bold;
}

/* 🎵 Repeat Button */
/* Add scale animation effect */
#repeatBtn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    background: #ccc;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s; /* Smooth animation */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Active state (when clicked) */
#repeatBtn:active {
    transform: scale(0.9); /* Slight shrink effect */
}

/* Active styling when repeat mode is on */
#repeatBtn.active {
    background: #007bff; /* Blue when active */
    transform: scale(1.1); /* Slight increase in size */
    transition: background 0.3s, transform 0.1s;
}

#nowPlaying {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
    line-height: 0.8; /* Reduce line height to bring text closer */
}

#nowPlaying .status {
    font-size: 20px;
    font-weight: bold;
    display: block;
    margin-bottom: 2px; /* Reduce space below "Now Playing" */
}

#nowPlaying .song-title {
    transition: color 0.8s ease-in-out; /* Smooth transition */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    /* Fix descender cutoff issue */
    line-height: 1.0; /* Ensure enough space for descenders */
    padding-bottom: 2px; /* Prevent letters like "g, j, y" from being cut off */
    display: inline-block; /* Ensure proper text alignment */
    
    font-size: 18px;
    font-weight: bold;
    display: block;
    margin-bottom: 2px; /* Reduce space below Song Name */
}

/* Smooth transition for song title and author name */
#nowPlaying .author-name,
#songList .author { /* Apply to second card */
    transition: color 0.8s ease-in-out, opacity 0.5s ease-in-out !important;
}

/* Dark Mode Colors */
body.dark-mode #nowPlaying .song-title,
body.dark-mode #nowPlaying .author-name {
    color: white !important; /* Ensure both elements turn white in dark mode */
}

/* Light Mode Colors (Fix transition when turning OFF dark mode) */
body:not(.dark-mode) #nowPlaying .song-title {
    color: black; /* Match original light mode text color */
}

body:not(.dark-mode) #nowPlaying .author-name {
    color: #666 !important;
}

#nowPlaying .author-name {
    font-size: 14px;
    font-weight: normal;
    color: #666;
    display: block;
}        

/* Default Light Mode */
.author-name {
    color: #666; /* Light mode text */
    transition: color 0.8s ease-in-out; /* Smooth transition */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    /* Fix descender cutoff issue */
    line-height: 1.0; /* Ensure enough space for descenders */
    padding-bottom: 2px; /* Prevent letters like "g, j, y" from being cut off */
    display: inline-block; /* Ensure proper text alignment */
}

/* Dark Mode */
body.dark-mode .author-name {
    color: #bbb !important; /* Lighter text for dark mode */
}

/* Dark mode support for empty playlist and footer */
body.dark-mode .text-muted {
    color: #aaa !important; /* brighter gray for readability */
}

body.dark-mode .list-group-item.text-muted {
    background-color: transparent !important;
    border: none !important;
    color: #aaa !important;
}

body.dark-mode .text-muted a {
    color: #bbb !important;  /* links lighter gray */
}

body.dark-mode .text-muted a:hover {
    color: #fff !important;  /* hover = white */
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding-top: 20px;
    max-width: 300px;
    position: relative;
    touch-action: none; /* Prevent browser scrolling when adjusting volume */
}

.volume-bar-container {
    position: relative;
    width: 100%;
    height: 8px;
    background: #ddd;
    border-radius: 5px;
    overflow: hidden;
}

.volume-thumb {
    position: absolute;
    top: 50%;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 3px solid #007bff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: left 0.1s ease-in-out;
    box-shadow: 0px 0px 6px rgba(0, 123, 255, 0.5);
}

/* Make thumb slightly overflow progress bar */
.volume-bar-container {
    position: relative;
    width: 100%;
    height: 10px; /* Make bar slightly thicker */
    background: #ddd;
    border-radius: 5px;
    overflow: visible; /* Allow thumb to overflow */
}

.volume-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #007bff; /* Filled color */
    border-radius: 5px;
    transition: width 0.1s ease-in-out;
    box-shadow: none; /* Remove any shadow */
}

#volumeControl {
    -webkit-appearance: none;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    height: 8px;
    background: transparent; /* Hide default bar */
    z-index: 2; /* Keep it on top */
    cursor: pointer;
    opacity: 0; /* Hide the default slider */
}


/* Prevent color change on click */
#volumeControl:focus, 
#volumeControl:active {
    background: #aaa !important; /* Force grey */
}

/* Chrome, Safari, Edge */
#volumeControl::-webkit-slider-runnable-track {
    background: #aaa; /* Default grey */
    height: 6px;
    border-radius: 5px;
}

#volumeControl::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #666; /* Darker grey thumb */
    border-radius: 50%;
    cursor: pointer;
    margin-top: -4px;
}

/* Firefox */
#volumeControl::-moz-range-track {
    background: #aaa; /* Default grey */
    height: 6px;
    border-radius: 5px;
}

#volumeControl::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #666; /* Darker grey thumb */
    border-radius: 50%;
    cursor: pointer;
}

/* Prevent background color change on click in all browsers */
#volumeControl:focus::-webkit-slider-runnable-track,
#volumeControl:active::-webkit-slider-runnable-track {
    background: #aaa !important; /* Stays grey */
}

#volumeControl:focus::-moz-range-track,
#volumeControl:active::-moz-range-track {
    background: #aaa !important; /* Stays grey */
}

#playerContainer {
    width: 100%; 
    min-height: 200px; 
    display: flex;
    justify-content: center;
    align-items: center;
}

#player {
    width: 100%;
    max-width: 260px;
    height: 150px;
}

#playerContainer iframe {
    width: 260px;
    height: 170px;
    border-radius: 10px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
}

#togglePlayerBtn {
    background-color: #007bff;
    border-color: #007bff;
    transition: transform 0.1s ease-in-out;
}

#togglePlayerBtn:hover {
    background-color: #0056b3; /* Darker shade for hover effect */
    border-color: #0056b3;
}

#togglePlayerBtn:active {
    transform: scale(0.9); /* Shrink effect on click */
}

.card {
    border: none !important;
    box-shadow: none !important; /* Removes shadow if needed */
}

/* 🎵 General Button Styling */
.card .btn {
    transition: transform 0.1s ease-in-out, background-color 0.3s;
}

/* 🎵 Click Animation (Shrink Effect) */
.card .btn:active {
    transform: scale(0.9);
}

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

.rotate {
    animation: rotate 5s linear infinite;
}

.rotate-paused {
    animation-play-state: paused;
}