/* style.css */

/* Basic Resets & Global Styles */
body {
    font-family: 'Segoe UI', Arial, sans-serif; /* Modern, clean font */
    margin: 0;
    background-color: #121212; /* Dark background */
    color: #e0e0e0; /* Light text for readability */
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Full viewport height */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Header Styling */
.header {
    background-color: #1a1a1a; /* Slightly lighter dark for header */
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); /* Subtle shadow */
    position: fixed; /* Keep header at top */
    width: 100%;
    top: 0;
    left: 0;
    z-index: 150; /* Above sidebar, below modals */
    box-sizing: border-box; /* Include padding in width */
}

.logo {
    margin: 0;
    color: #1DB954; /* Spotify green */
    font-size: 1.8em;
    font-weight: bold;
    letter-spacing: -0.5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    font-size: 0.95em;
    color: #b3b3b3;
}

.user-info button {
    background-color: #333; /* Darker button for login/logout */
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 25px; /* Pill shape */
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.user-info button:hover {
    background-color: #555;
    transform: translateY(-1px);
}
.user-info button:active {
    transform: translateY(0);
}


/* Sidebar Navigation */
.sidebar {
    background-color: #000; /* Pure black for sidebar */
    width: 220px; /* Slightly wider sidebar */
    padding: 20px 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.4);
    position: fixed;
    height: 100%;
    top: 0;
    left: 0;
    padding-top: 80px; /* Space for fixed header */
    z-index: 100;
    box-sizing: border-box;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    padding: 12px 25px; /* More horizontal padding */
    cursor: pointer;
    transition: background-color 0.2s ease, border-left-color 0.2s ease;
    border-left: 5px solid transparent;
    font-weight: 500;
}

.sidebar li:hover {
    background-color: #282828;
    border-left-color: #1DB954; /* Highlight with green */
}

/* Main Content Area */
.main-content {
    margin-left: 240px; /* Space for sidebar + some gap */
    padding: 20px;
    flex-grow: 1;
    min-height: calc(100vh - 160px); /* Adjust for header and player bar */
    padding-top: 90px; /* Space for fixed header */
    padding-bottom: 90px; /* Space for fixed player */
    box-sizing: border-box;
}

.content-section {
    background-color: #1e1e1e; /* Dark content background */
    border-radius: 10px; /* More rounded corners */
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.content-section h2 {
    color: #fff;
    font-size: 1.8em;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.search-bar input {
    flex-grow: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #333;
    background-color: #282828;
    color: #fff;
    font-size: 1em;
}

.search-bar button {
    background-color: #1DB954;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.search-bar button:hover {
    background-color: #1ed760;
    transform: translateY(-1px);
}
.search-bar button:active {
    transform: translateY(0);
}


/* Track List (for All Songs, Playlists, Album Songs) */
.track-list {
    display: flex;
    flex-direction: column;
    gap: 12px; /* Slightly more space */
}

.track-item {
    background-color: #282828;
    padding: 12px 18px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.track-item:hover {
    background-color: #3a3a3a;
}

.track-item img {
    width: 60px; /* Slightly larger cover art */
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.track-info {
    flex-grow: 1;
}

.track-title {
    font-weight: bold;
    color: #fff;
    font-size: 1.1em;
}

.track-artist-album {
    font-size: 0.95em;
    color: #b3b3b3;
}

.track-duration {
    font-size: 0.9em;
    color: #b3b3b3;
    min-width: 45px; /* Ensure consistent width for duration */
    text-align: right;
}

.track-item .add-to-playlist-btn,
.track-item .remove-from-playlist-btn {
    background-color: #535353;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
    flex-shrink: 0; /* Prevent buttons from shrinking */
}
.track-item .add-to-playlist-btn:hover,
.track-item .remove-from-playlist-btn:hover {
    background-color: #727272;
}
.track-item .remove-from-playlist-btn {
    background-color: #dc3545; /* Red for remove */
}
.track-item .remove-from-playlist-btn:hover {
    background-color: #c82333;
}


/* Playlists Section */
.playlist-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.playlist-item {
    background-color: #282828;
    padding: 15px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-weight: bold;
    font-size: 1.1em;
}

.playlist-item:hover {
    background-color: #3a3a3a;
}

.delete-button {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95em;
    margin-bottom: 20px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.delete-button:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}
.delete-button:active {
    transform: translateY(0);
}


/* Player Bar */
.player-bar {
    background-color: #282828;
    padding: 15px 25px;
    display: flex;
    flex-direction: column; /* Changed to column to stack controls and progress bar */
    align-items: center;
    justify-content: space-between;
    gap: 10px; /* Reduced gap */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.4);
    z-index: 150;
    box-sizing: border-box;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%; /* Take full width of player-bar */
    justify-content: flex-start; /* Align items to the start */
}

.player-controls button {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.8em; /* Larger icons */
    cursor: pointer;
    transition: color 0.2s ease, transform 0.1s ease;
}

.player-controls button:hover {
    color: #1DB954;
    transform: scale(1.1);
}
.player-controls button:active {
    transform: scale(1.0);
}

.player-info {
    display: flex; /* Use flex to arrange cover, text, artist img, bio */
    align-items: center;
    flex-grow: 1;
    gap: 15px; /* Space between elements in player-info */
    min-width: 0; /* Allow content to shrink */
}

.player-title {
    font-weight: bold;
    font-size: 1.2em;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-artist {
    font-size: 1em;
    color: #b3b3b3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-cover-art {
    width: 70px; /* Larger cover art in player */
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    flex-shrink: 0; /* Prevent from shrinking */
}

/* --- NYA STYLING REGLER FÖR ARTIST INFO I SPELAREN --- */
.player-artist-img {
    width: 50px; /* Mindre storlek för artistbild i spelaren */
    height: 50px;
    border-radius: 50%; /* Rund */
    object-fit: cover;
    border: 1px solid #444; /* Lätt ram */
    flex-shrink: 0; /* Förhindra att den krymper */
    margin-left: 0; /* Reset margin from previous examples */
}

.player-artist-bio {
    font-size: 0.75em; /* Mindre text för biografin */
    color: #a0a0a0;
    max-height: 60px; /* Begränsa höjden, lägg till scroll om det behövs */
    overflow-y: auto;
    flex-grow: 1; /* Låter den ta upp plats */
    padding-right: 10px; /* Lite padding om scrollen aktiveras */
    margin-left: 0; /* Reset margin */
}

.volume-bar {
    width: 120px; /* Slightly wider volume bar */
    -webkit-appearance: none;
    height: 6px; /* Thicker bar */
    background: #535353;
    outline: none;
    opacity: 0.9;
    transition: opacity .2s;
    border-radius: 3px;
    margin-left: auto; /* Push to the right */
}

.volume-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px; /* Larger thumb */
    height: 18px;
    border-radius: 50%;
    background: #1DB954;
    cursor: pointer;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.volume-bar::-moz-range-thumb { /* Firefox */
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1DB954;
    cursor: pointer;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}


.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    color: #b3b3b3;
    width: 100%; /* Take full width of player-bar */
}

#progress-bar {
    flex-grow: 1;
    -webkit-appearance: none;
    height: 6px; /* Thicker bar */
    background: #535353;
    outline: none;
    opacity: 0.9;
    transition: opacity .2s;
    border-radius: 3px;
}

#progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px; /* Larger thumb */
    height: 18px;
    border-radius: 50%;
    background: #1DB954;
    cursor: pointer;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}
#progress-bar::-moz-range-thumb { /* Firefox */
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1DB954;
    cursor: pointer;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}


/* Modals */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 200; /* Sit on top of everything */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.7); /* Black w/ opacity */
    display: flex; /* Use flexbox for centering */
    justify-content: center;
    align-items: center;
    padding-top: 0; /* Remove padding-top from original */
}

.modal-content {
    background-color: #282828;
    padding: 35px; /* More padding */
    border: 1px solid #444;
    width: 90%; /* Responsive width */
    max-width: 550px; /* Max width */
    border-radius: 12px; /* More rounded corners */
    position: relative;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    text-align: center;
    animation: fadeIn 0.3s ease-out; /* Simple animation */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-button {
    color: #aaa;
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 32px; /* Larger close button */
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-button:hover,
.close-button:focus {
    color: white;
}

.modal-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #444; /* Separator */
    padding-bottom: 10px;
}

.modal-tabs button {
    background-color: #3a3a3a; /* Darker tab button */
    color: #fff;
    border: none;
    padding: 12px 25px;
    cursor: pointer;
    font-size: 1.05em;
    border-radius: 8px 8px 0 0; /* Rounded top corners */
    margin: 0 2px;
    transition: background-color 0.2s ease;
}

.modal-tabs button:hover {
    background-color: #555;
}
.modal-tabs button:not(:hover) {
    opacity: 0.8; /* Dim inactive tabs slightly */
}


.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 18px; /* More space between inputs */
}

.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content input[type="email"],
.modal-content select {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #555;
    background-color: #333;
    color: #fff;
    font-size: 1em;
    outline: none; /* Remove default outline */
}
.modal-content input[type="text"]:focus,
.modal-content input[type="password"]:focus,
.modal-content input[type="email"]:focus,
.modal-content select:focus {
    border-color: #1DB954; /* Highlight on focus */
    box-shadow: 0 0 0 2px rgba(29, 185, 84, 0.3);
}


.modal-content button[type="submit"],
.modal-content button#confirm-add-to-playlist-btn {
    background-color: #1DB954;
    color: white;
    border: none;
    padding: 14px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.modal-content button[type="submit"]:hover,
.modal-content button#confirm-add-to-playlist-btn:hover {
    background-color: #1ed760;
    transform: translateY(-1px);
}
.modal-content button[type="submit"]:active,
.modal-content button#confirm-add-to-playlist-btn:active {
    transform: translateY(0);
}


/* --- NEW CSS for Artist/Album Grid Views --- */
.hidden {
    display: none !important; /* Forces element to be hidden */
}

/* Grid layout for artists and albums */
.grid-view {
    display: grid;
    /* Responsive columns: auto-fill available space, min width 150px, max 1fr */
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 25px; /* More space between items */
    padding: 20px 0;
}

/* Individual item within the grid (artist or album) */
.grid-item {
    background-color: #282828; /* Slightly lighter dark background */
    border-radius: 10px; /* Consistent rounded corners */
    padding: 20px; /* More padding */
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); /* Clearer shadow */
}

.grid-item:hover {
    background-color: #3a3a3a; /* Darker on hover */
    transform: translateY(-5px); /* Lift effect on hover */
}

.grid-item img {
    width: 120px; /* Larger images */
    height: 120px;
    object-fit: cover;
    border-radius: 8px; /* Consistent with other content */
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.grid-item .name {
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
    font-size: 1.15em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.grid-item .sub-info {
    font-size: 0.95em;
    color: #b3b3b3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.back-button {
    background-color: #535353;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px; /* Pill shape */
    cursor: pointer;
    font-size: 0.95em;
    margin-bottom: 25px; /* Space below the button */
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.back-button:hover {
    background-color: #727272;
    transform: translateY(-1px);
}
.back-button:active {
    transform: translateY(0);
}


/* Responsive Adjustments for Smaller Screens */
@media (max-width: 992px) {
    .main-content {
        margin-left: 20px; /* Reduce left margin for smaller screens */
        padding-top: 100px; /* Adjust if header is taller */
        padding-bottom: 100px; /* Adjust if player is taller */
    }
    .sidebar {
        width: 180px; /* Slightly narrower sidebar */
    }
    .grid-view {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
    .grid-item img {
        width: 90px;
        height: 90px;
    }
    .player-cover-art {
        width: 50px;
        height: 50px;
    }
    .player-controls button {
        font-size: 1.5em;
    }
    .volume-bar {
        width: 100px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start; /* Align logo and user info to start */
        gap: 10px;
        padding: 15px;
    }
    .user-info {
        width: 100%;
        justify-content: center; /* Center buttons */
    }
    .sidebar {
        position: relative; /* Make sidebar flow naturally */
        width: 100%;
        height: auto;
        padding: 10px 0;
        box-shadow: none;
        padding-top: 0; /* No need for fixed header space */
    }
    .sidebar ul {
        display: flex;
        flex-wrap: wrap; /* Allow nav items to wrap */
        justify-content: center;
        gap: 5px;
    }
    .sidebar li {
        border-left: none; /* Remove left border */
        border-bottom: 3px solid transparent; /* Use bottom border for highlight */
        padding: 10px 15px;
    }
    .sidebar li:hover {
        border-left-color: transparent;
        border-bottom-color: #1DB954;
    }

    .main-content {
        margin-left: 0; /* No fixed sidebar space */
        padding: 15px;
        padding-top: 15px; /* Adjust for non-fixed header */
        padding-bottom: 100px; /* Space for player */
    }

    .player-bar {
        flex-direction: column;
        align-items: center;
        padding: 15px;
        left: 0;
        transform: translateX(0); /* Ensure no translateX from sidebar fix */
        gap: 10px;
    }
    .player-controls {
        flex-wrap: wrap; /* Allow controls to wrap */
        justify-content: center;
        width: 100%; /* Take full width */
    }
    .player-info {
        /* When flex-direction is column, flex-grow doesn't help centering */
        text-align: center;
        width: 100%; /* Center info */
        margin-bottom: 10px;
        /* For player-info to be centered in mobile, you might need to adjust based on its parent's flex behavior */
        justify-content: center; /* Center player info elements */
        flex-wrap: wrap; /* Allow elements inside player-info to wrap */
    }
    .player-cover-art, .player-artist-img {
        margin-bottom: 10px; /* Add space when elements stack */
    }
    .player-artist-bio {
        text-align: center; /* Center bio text in mobile */
        max-height: none; /* Allow full height in mobile if needed */
        overflow-y: visible; /* Prevent scrollbar in mobile if text is short */
        padding-right: 0; /* Remove padding */
    }
    .volume-bar {
        width: 80%; /* Wider volume bar for touch */
        margin-left: 0; /* Center it */
    }
    .progress-container {
        width: 100%;
    }
    #progress-bar {
        width: 100%;
    }
    .modal-content {
        width: 95%; /* Even wider for small screens */
        padding: 20px;
    }
    .grid-view {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    .grid-item {
        padding: 10px;
    }
    .grid-item img {
        width: 80px;
        height: 80px;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .header .logo {
        font-size: 1.5em;
    }
    .user-info button {
        padding: 8px 12px;
        font-size: 0.8em;
    }
    .sidebar li {
        padding: 8px 10px;
        font-size: 0.9em;
    }
    .content-section h2 {
        font-size: 1.5em;
    }
    .search-bar input, .search-bar button {
        padding: 8px;
        font-size: 0.9em;
    }
    .track-item {
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
        gap: 10px;
    }
    .track-item img {
        margin-right: 0;
    }
    .track-info {
        flex-basis: 100%;
        text-align: center;
    }
    .track-duration, .track-item .add-to-playlist-btn, .track-item .remove-from-playlist-btn {
        flex-basis: auto;
        width: auto;
    }
    .player-controls button {
        font-size: 1.3em;
    }
}