/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    padding-bottom: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

header h1 {
    color: #1DB954; /* Spotify green */
    margin-bottom: 10px;
}

/* Section Styles */
.section {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section h2 {
    margin-bottom: 15px;
    color: #333;
}

/* Collapsible Section Styles */
.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.collapsible-header .toggle-icon {
    transition: transform 0.3s ease;
}

collapsible-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-top: 15px;
}

.collapsible-content.collapsed {
    max-height: 0;
    padding-top: 0;
}

/* Collapse button styling */
.collapse-button {
    display: block;
    margin: 20px auto 5px;
    padding: 8px 15px;
    background-color: #f0f0f0;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.collapse-button:hover {
    background-color: #e0e0e0;
    color: #333;
}

/* Form Elements */
.input-group {
    display: flex;
    margin-bottom: 10px;
}

input[type="text"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

button {
    padding: 10px 15px;
    background-color: #1DB954; /* Spotify green */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #1ed760;
}

.button {
    display: inline-block;
    text-decoration: none;
    padding: 10px 15px;
    background-color: #1DB954; /* Spotify green */
    color: white;
    border-radius: 4px;
    text-align: center;
    transition: background-color 0.3s;
}

.button:hover {
    background-color: #1ed760;
}

/* Disabled button state */
.button.disabled {
    pointer-events: none;
    opacity: 0.7;
    background-color: #999;
    cursor: not-allowed;
}

/* Hints and Small Text */
.hint {
    font-size: 14px;
    color: #777;
    margin-top: 10px;
}

/* Player Controls */
#player-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

#player-controls a,
#player-controls button {
    text-align: center;
    width: 100%;
}

/* Button States for Start Playing/Play Next/Restart Playback */
#start-playing {
    padding: 30px;
    font-size: 24px;
    font-weight: bold;
    border-radius: 15px;
    background-color: #1DB954; /* Spotify green */
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    width: 100%;
    display: block;
}

/* Different background colors for the three states */
#start-playing.initial-state {
    background-color: #1DB954; /* Spotify green for Start Playing */
}

#start-playing.next-state {
    background-color: #1DB954; /* Same Spotify green for Play Next */
}

#start-playing.restart-state {
    background-color: #f0ad4e; /* Orange for Restart Playback */
}

#start-playing:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

#start-playing.initial-state:hover {
    background-color: #1ed760;
}

#start-playing.next-state:hover {
    background-color: #1ed760; /* Same hover color for Play Next */
}

#start-playing.restart-state:hover {
    background-color: #f3bd6a;
}

#start-playing:active {
    transform: scale(0.98);
}

/* Make the button even bigger on mobile devices */
@media (max-width: 600px) {
    #start-playing {
        padding: 40px;
        font-size: 28px;
        margin-bottom: 15px;
    }
}

/* Initially hide the next song button */
#next-song {
    display: none;
    background-color: #1DB954;
    color: white;
}

#next-song:hover {
    background-color: #1ed760;
    transform: scale(1.05);
}

ol li {
    list-style-position: inside;
}

/* Song Info */
.reveal-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.reveal-item {
    text-align: center;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
}

/* Info icon and tooltip styling */
.info-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background-color: #777;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    margin-left: 5px;
    cursor: pointer;
    position: relative;
}

.info-icon:hover {
    background-color: #555;
}

.tooltip-text {
    visibility: hidden;
    width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 100;
    bottom: 30px;
    left: 50%;
    margin-left: -125px;
    opacity: 0;
    transition: opacity 0.2s, visibility 0s;
    font-weight: normal;
    font-size: 13px;
    pointer-events: none;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.info-icon:hover .tooltip-text,
.tooltip-text.visible {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.2s;
}

.hidden-info {
    margin-top: 10px;
    font-weight: bold;
    color: #333;
    visibility: hidden;
}

.hidden-info.revealed {
    visibility: visible;
    animation: fadeIn 0.5s;
}

/* Reveal button styling */
.reveal-all-btn {
    display: block;
    margin: 20px auto;
    padding: 12px 25px;
    font-size: 18px;
    background-color: #5f7d95; /* Changed from jarring purple to a subtle blue-gray */
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reveal-all-btn:hover {
    background-color: #7191a8; /* Lighter shade for hover state */
    transform: scale(1.05);
}

.reveal-all-btn.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    margin: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.reveal-all-btn.overlay:hover {
    background-color: #7191a8;
    transform: translate(-50%, -50%) scale(1.05);
}

.song-details-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 25px;
    position: relative; /* For absolute positioning of the reveal button */
}

.song-detail {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: none;
}

.song-detail.blurred {
    filter: blur(8px);
}

/* Add transition only for the unblurring */
.song-detail:not(.blurred) {
    transition: filter 0.5s ease;
}

.song-detail h4 {
    margin-bottom: 10px;
    color: #666;
    font-weight: 500;
}

/* Playlist History */
#saved-playlists {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

/* Recently Played Section */
#recently-played {
    transition: all 0.3s ease;
}

.recently-played-container {
    margin-top: 10px;
}

.scrollable-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    background-color: #f9f9f9;
    /* Hide scrollbar by default, show only when scrolling */
    scrollbar-width: thin; /* For Firefox */
    scrollbar-color: transparent transparent; /* For Firefox */
}

/* Show scrollbar when hovering or while scrolling */
.scrollable-list:hover,
.scrollable-list:focus,
.scrollable-list:active {
    scrollbar-color: #1DB954 #f1f1f1; /* For Firefox */
}

/* Scrollbar styling for the recently played list */
.scrollable-list::-webkit-scrollbar {
    width: 8px;
    background-color: transparent; /* Make scrollbar track transparent by default */
}

.scrollable-list:hover::-webkit-scrollbar,
.scrollable-list:focus::-webkit-scrollbar,
.scrollable-list:active::-webkit-scrollbar {
    background-color: #f1f1f1; /* Show scrollbar track on hover/interaction */
}

.scrollable-list::-webkit-scrollbar-track {
    border-radius: 8px;
    background-color: transparent; /* Make track transparent by default */
}

.scrollable-list:hover::-webkit-scrollbar-track,
.scrollable-list:focus::-webkit-scrollbar-track,
.scrollable-list:active::-webkit-scrollbar-track {
    background-color: #f1f1f1; /* Show track on hover/interaction */
}

.scrollable-list::-webkit-scrollbar-thumb {
    background-color: transparent; /* Make thumb transparent by default */
    border-radius: 8px;
}

.scrollable-list:hover::-webkit-scrollbar-thumb,
.scrollable-list:focus::-webkit-scrollbar-thumb,
.scrollable-list:active::-webkit-scrollbar-thumb {
    background-color: #1DB954; /* Show thumb on hover/interaction */
}

.scrollable-list::-webkit-scrollbar-thumb:hover {
    background-color: #19a449;
}

.recent-song-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    transition: background-color 0.2s ease;
}

.recent-song-item:last-child {
    border-bottom: none;
}

.recent-song-item:hover {
    background-color: #f0f0f0;
}

/* Styles for indicating recency */
.recent-song-item[data-recency="1"] {
    background-color: #edfaef;
    border-left: 4px solid #1DB954;
    font-weight: bold;
}

.recent-song-item[data-recency="2"] {
    background-color: #f2fcf4;
    border-left: 3px solid #45cd71;
}

.recent-song-item[data-recency="3"] {
    background-color: #f7fdf8;
    border-left: 2px solid #7ddd9b;
}

.recent-song-item .recency-indicator {
    margin-right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    color: white;
}

.recent-song-item[data-recency="1"] .recency-indicator {
    background-color: #1DB954;
}

.recent-song-item[data-recency="2"] .recency-indicator {
    background-color: #45cd71;
}

.recent-song-item[data-recency="3"] .recency-indicator {
    background-color: #7ddd9b;
}

.recent-song-info {
    flex: 1;
    word-wrap: break-word; /* Enable word wrapping */
    font-size: 14px;
}

#played-songs-list {
    list-style: none;
}

#played-songs-list li {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

#played-songs-list li:last-child {
    border-bottom: none;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    color: #777;
}

/* Utility Classes */
.hidden {
    display: none;
}

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

/* Responsive Design */
@media (max-width: 600px) {
    .input-group {
        flex-direction: column;
    }
    
    .input-group input {
        margin-bottom: 10px;
    }
    
    #player-controls {
        flex-direction: column;
    }
    
    .reveal-container {
        grid-template-columns: 1fr;
    }

    .song-details-container {
        grid-template-columns: 1fr;
    }

    .country-chip {
        padding: 9px 16px;
        font-size: 15px;
    }

    #country-chips {
        gap: 8px;
    }

    .playlist-card {
        width: 158px;
        height: 292px;
    }

    .vinyl-disc {
        width: 130px;
        height: 130px;
        overflow: visible;
    }

    .vinyl-flag {
        font-size: 24px;
    }

    .vinyl-info h3 {
        font-size: 11px;
    }

    .vinyl-stats {
        font-size: 10.5px;
    }
}

/* iOS Instructions Image */
.screenshot {
    display: block;
    width: 50%;
    margin: 15px auto;
}

.example-link {
    color: #1DB954;
    cursor: pointer;
    text-decoration: underline;
}

.example-link:hover {
    color: #1ed760;
    text-decoration: underline;
}

/* Success Message */
.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 15px;
    margin-top: 15px;
    border-radius: 8px;
    border-left: 5px solid #28a745;
    animation: fadeInSlide 0.5s ease-out;
}

.success-message p {
    margin: 0;
}

.success-message strong {
    font-weight: bold;
}

/* Playlist Gallery Styles */
#playlists-container {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 14px;
    padding: 12px 8px 16px;
    margin: 0 -20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #e8e8e8 transparent;
    align-items: flex-start;
}

#playlists-container::-webkit-scrollbar {
    height: 4px;
}

#playlists-container::-webkit-scrollbar-track {
    background: transparent;
}

#playlists-container::-webkit-scrollbar-thumb {
    background: #e8e8e8;
    border-radius: 2px;
}

#playlist-filters {
    margin-bottom: 20px;
}

#playlist-search {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s ease;
}

#playlist-search:focus {
    outline: none;
    border-color: #1DB954;
}

#country-chips {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

#country-chips::-webkit-scrollbar {
    display: none;
}

.country-chip {
    flex-shrink: 0;
    border-radius: 20px;
    padding: 7px 15px;
    border: 1.5px solid #ddd;
    background: #fafafa;
    color: #444;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
}

.country-chip:hover {
    border-color: #1DB954;
    color: #1DB954;
    background-color: #f0faf3;
}

.country-chip.active {
    background-color: #1DB954;
    color: white;
    border-color: #1DB954;
}

.country-chip.active:hover {
    background-color: #1ed760;
    border-color: #1ed760;
}

#playlist-count {
    font-size: 13px;
    color: #999;
    margin-top: 4px;
}

.playlist-card.filter-hidden {
    display: none;
}

#no-filter-results {
    flex: 0 0 auto;
    min-width: 200px;
    text-align: center;
    padding: 20px;
    color: #666;
}

.playlist-card {
    flex: 0 0 auto;
    width: 182px;
    height: 320px;
    scroll-snap-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 10px;
    background: #fff;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    position: relative;
    border: 2.5px solid transparent;
}

.playlist-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.11);
}

.playlist-card.selected {
    border-color: #1DB954;
    box-shadow: 0 0 0 1px #1DB954, 0 8px 20px rgba(29, 185, 84, 0.18);
    transform: translateY(-4px);
}

.vinyl-disc {
    width: 152px;
    height: 152px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    overflow: visible;
    box-shadow: 0 4px 14px rgba(0,0,0,0.22);
    transition: box-shadow 0.25s ease;
}

.vinyl-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.playlist-card:hover .vinyl-disc {
    box-shadow: 0 6px 22px rgba(0,0,0,0.3);
}

.playlist-card.selected .vinyl-disc {
    box-shadow: 0 0 0 3px #1DB954, 0 4px 14px rgba(0,0,0,0.22);
}

.vinyl-flag {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    line-height: 1;
    pointer-events: none;
    user-select: none;
}

.vinyl-info {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
    overflow: hidden;
}

.vinyl-info h3 {
    font-size: 12.5px;
    font-weight: 600;
    color: #333;
    line-height: 1.35;
    margin: 0;
    padding: 0 4px;
    width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vinyl-stats {
    font-size: 11.5px;
    color: #aaa;
    display: flex;
    flex-direction: column;
    gap: 1px;
    align-items: center;
}

.vinyl-played {
    color: #1DB954;
    font-weight: 600;
}

.playlist-reset-btn {
    background: transparent;
    border: 1.5px solid #e8e8e8;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    margin-top: 2px;
    position: static;
}

.playlist-reset-btn:hover {
    background: #fff5e0;
    border-color: #f0ad4e;
}

#add-playlist-btn {
    margin-bottom: 15px;
}

#add-playlist-form {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    border-left: 3px solid #1DB954;
}

#add-playlist-form h3 {
    margin-top: 0;
    margin-bottom: 15px;
}

#no-playlists-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    color: #666;
}

.default-playlists-link {
    color: #1DB954;
    font-weight: bold;
    text-decoration: underline;
    cursor: pointer;
}

.default-playlists-link:hover {
    color: #1ed760;
    text-decoration: underline;
}

@keyframes fadeInSlide {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animated arrow indicator */
.scroll-indicator {
    display: block;
    text-align: center;
    margin-top: 10px;
    animation: bounce 1.5s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.shuffle-icon {
    width: 14px;
    height: 14px;
    filter: invert(55%);
    transition: filter 0.2s ease;
}

.playlist-reset-btn:hover .shuffle-icon {
    filter: invert(40%) sepia(1) saturate(1.5) hue-rotate(20deg);
}

/* Delay Slider Styling */
.slider-container {
    margin: 20px 0;
    padding: 15px;
    background-color: #f7f7f7;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.slider-container label {
    display: block;
    margin-bottom: 10px;
    color: #333;
    font-weight: 500;
}

#delay-value {
    color: #1DB954;
    font-weight: bold;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    margin: 10px 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1DB954;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: background-color 0.15s ease;
}

.slider::-webkit-slider-thumb:hover {
    background: #1ed760;
}

.slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1DB954;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: background-color 0.15s ease;
    border: none;
}

.slider::-moz-range-thumb:hover {
    background: #1ed760;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

/* Button icon styling */
.button-icon {
    width: 40px;
    height: 40px;
    vertical-align: middle;
    position: relative;
    top: -2px;
    margin-right: 10px;
    filter: brightness(0) invert(1); /* Makes the icon white to match button text */
}

/* Different colors for button states */
#start-playing.initial-state .button-icon,
#start-playing.next-state .button-icon {
    filter: brightness(0) invert(1); /* White icons for green buttons */
}

#start-playing.restart-state .button-icon {
    filter: brightness(0) invert(1); /* White icon for orange button */
}

/* Make the button icon even bigger on mobile devices */
@media (max-width: 600px) {
    .button-icon {
        width: 48px;
        height: 48px;
        top: -3px;
    }
}