@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

/* --- Styles généraux --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Poppins', sans-serif;
    color: #b3b3b3;
    background-color: #121212;
}

a {
    color: inherit;
    text-decoration: none;
}

.main-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* --- Header responsive et stylé --- */
.main-header {
    background-color: #000;
    color: #fff;
    padding: 15px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-wrap: wrap;
}

.back-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, color 0.2s ease;
}

.back-btn:hover {
    color: #1db954;
    transform: scale(1.1);
}

.main-header .logo {
    font-size: 24px;
    font-weight: 700;
    flex-shrink: 0;
    margin-right: auto; /* Pousse les autres éléments à droite sur grand écran */
}

.header-nav {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.header-nav a {
    font-weight: 600;
    transition: color 0.2s ease;
}

.header-nav a:hover {
    color: #1db954;
}

.search-bar {
    width: 300px;
    padding: 10px 15px;
    border-radius: 500px;
    border: none;
    background-color: #282828;
    color: #fff;
    outline: none;
    flex-grow: 1;
}

.search-bar::placeholder {
    color: #b3b3b3;
}

/* --- Contenu principal --- */
.content-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    background-color: #121212;
}

.top-bar {
    display: none;
}

.player-section {
    background-color: #181818;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    max-width: 900px;
    margin: 0 auto;
}

/* Correction pour l'iframe principale */
#main-player-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
}

#main-player,
#player-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#main-player {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

#player-thumbnail {
    z-index: 0;
}

#thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

#play-pause-btn {
    background-color: #1db954;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

#play-pause-btn:hover {
    transform: scale(1.1);
}

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

#volume-slider {
    width: 100px;
    cursor: pointer;
}

.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
}

#progress-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: #5a5a5a;
    border-radius: 5px;
    cursor: pointer;
    outline: none;
}

#progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 12px;
    width: 12px;
    background: #fff;
    border-radius: 50%;
    margin-top: -4px;
    cursor: pointer;
}

#current-time, #duration-time {
    font-size: 12px;
    color: #b3b3b3;
}

#loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #1db954;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

.hidden {
    display: none;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* --- Section Playlist --- */
.playlist-section {
    margin-top: 30px;
}

.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.playlist-item {
    background-color: #181818;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

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

.playlist-item img {
    width: 100%;
    border-radius: 4px;
    margin-bottom: 10px;
}

.playlist-item span {
    display: block;
    font-weight: 600;
    color: #fff;
}

.playlist-item small {
    color: #b3b3b3;
}

.hidden-search {
    opacity: 0;
    visibility: hidden;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
}

/* --- Section Détails : Styles améliorés --- */
.details-section {
    margin-top: 30px;
    max-width: 900px;
    margin: 30px auto 0 auto;
}

.details-card {
    display: flex;
    gap: 30px;
    background-color: #181818;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    align-items: center;
}

.details-card img {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.details-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.details-info h3 {
    color: #fff;
    font-size: 28px;
    margin-bottom: 8px;
}

.details-info p {
    color: #b3b3b3;
    margin-bottom: 20px;
}

.btn-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 12px 25px;
    border-radius: 500px;
    background-color: #1db954;
    color: #fff;
    text-align: center;
    font-weight: bold;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

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

/* --- Footer --- */
.main-footer {
    background-color: #181818;
    padding: 20px;
    text-align: center;
    color: #b3b3b3;
}

.footer-links {
    margin-bottom: 10px;
}

.footer-links a {
    margin: 0 10px;
    font-size: 14px;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: #1db954;
}

.copyright {
    font-size: 12px;
}

/* --- Réactivité --- */
@media (max-width: 768px) {
    .main-header {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        padding: 10px 15px;
        justify-content: flex-start;
    }

    .back-btn {
        margin-right: 10px; /* Ajoute un peu d'espace à droite du bouton */
    }

    .main-header .logo {
        margin-bottom: 0;
        flex-basis: auto;
        margin-right: auto;
    }

    .header-nav {
        flex-basis: auto;
        justify-content: flex-start;
        margin-bottom: 0;
        order: 2;
        margin-top: 10px;
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }

    .search-bar {
        order: 1;
        width: 100%;
        margin-top: 10px;
    }

    .content-area {
        padding: 10px;
    }

    .player-section {
        max-width: 100%;
    }

    .player-controls {
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .progress-bar-container {
        order: 1;
        flex-grow: 1;
        margin-top: 10px;
    }

    #play-pause-btn {
        order: 2;
    }

    .volume-control {
        order: 3;
    }

    .playlist-grid {
        grid-template-columns: 1fr;
    }

    .details-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px;
        gap: 20px;
    }

    .details-card img {
        width: 150px;
        height: 150px;
        margin-bottom: 0;
    }

    .details-info {
        gap: 10px;
    }
}