body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f8ff; 
    padding: 10px;
    box-sizing: border-box;
}

/* ---------------------------------------------------------------------- */
/* --- GENERAL ET METADATA (Haut Droit) --- */
/* ---------------------------------------------------------------------- */

#metadataControls {
    position: fixed;
    top: 10px; 
    right: 10px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end; 
}

#toggleTagsButton {
    background-color: #add8e6;
    color: #333;
    border: 1px solid #a0b7c7;
    padding: 6px 10px; 
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    margin-bottom: 5px;
    transition: background-color 0.3s;
}

#toggleTagsButton:hover {
    background-color: #90c8d7;
}

#allMetadataDisplay {
    width: 200px; 
    max-height: 50vh; 
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.85);
    border: 1px solid #d4e0e8; 
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); 
    font-family: monospace;
    font-size: 0.7em; 
    overflow-y: auto; 
}

.hidden {
    display: none;
}

/* ---------------------------------------------------------------------- */
/* --- LECTEUR PRINCIPAL (Player Wrapper) --- */
/* ---------------------------------------------------------------------- */

.player-wrapper {
    display: flex;
    flex-direction: column; 
    align-items: center; 
    gap: 5px; 
    
    width: 90vw; 
    max-width: 750px; 
    position: relative; 
    box-sizing: border-box; 
    padding: 0; 
}

.player-and-controls {
    flex-grow: 0; 
    display: flex;
    flex-direction: column;
    width: 100%; 
    max-width: 750px;
    border: 5px solid #a9b9c9;
    border-radius: 5px; 
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); 
}

#audioPlayer {
    width: 100%; 
    height: 0; 
    padding-bottom: 66.625%;
    position: relative; 
    border-bottom: 5px solid #a9b9c9; 
    
    background-image: url('default_cover.jpg'); 

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #c0d9e9; 
    overflow: hidden;
    margin-bottom: 0;
}

/* NOUVEAU CONTENEUR pour aligner boutons et métadonnées */
.buttons-and-metadata-row {
    display: flex;
    align-items: center; 
    gap: 15px; 
    width: 100%;
}

/* MÉDONNÉES EN BAS À DROITE DES BOUTONS */
#metadataDisplay {
    flex-grow: 1; 
    width: auto;
    
    padding: 5px 10px; 
    background-color: rgba(224, 242, 247, 0.85); 
    color: #333; 
    font-family: sans-serif;
    border-radius: 4px; 
    box-sizing: border-box; 
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    
    font-size: 0.8em; 
    text-align: left;
    
    position: static; 
}

#metadataDisplay p {
    margin: 0;
    font-weight: normal; 
    text-align: left;
}

#trackTitle {
    font-weight: bold;
    font-size: 1.0em;
}


/* ---------------------------------------------------------------------- */
/* --- SÉLECTEURS DE FICHIERS --- */
/* ---------------------------------------------------------------------- */

input[type="file"] {
    display: none;
}

.file-selectors {
    display: flex; 
    position: static; 
    flex-direction: row; 
    justify-content: center;
    gap: 8px; 
    padding: 10px 0; 
    width: 100%;
    max-width: 750px; 
    flex-shrink: 0; 
    z-index: 5;
    margin-top: 5px; 
}

.custom-file-upload {
    display: inline-block;
    background-color: #8fbc8f;
    color: #333; 
    padding: 6px 8px; 
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    text-align: center;
    transition: background-color 0.3s;
    flex-grow: 1; 
}

.custom-file-upload:hover {
    background-color: #7ba37b;
}

/* NOUVEAU : Style spécifique pour le bouton de réinitialisation */
.reset-button {
    background-color: #f08080 !important; /* Couleur rouge clair */
    color: #333;
    border: none;
    transition: background-color 0.3s;
}

.reset-button:hover {
    background-color: #e96363 !important; /* Rouge un peu plus foncé au survol */
}


/* ---------------------------------------------------------------------- */
/* --- CONTROLES, DISQUE ET PROGRESSION --- */
/* ---------------------------------------------------------------------- */

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

#progressBarControls {
    width: 100%;
    padding: 0;
    background-color: #c3d6e8; 
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

#controls-main-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%; 
    gap: 10px;
    padding: 10px; 
    box-sizing: border-box;
}

.right-controls-stack {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 5px; 
}

#vinylDisc {
    width: 130px; 
    height: 130px;
    border-radius: 50%;
    border: 1px solid #111; 
    background-color: #e0f8ff; 
    
    background-image: url('image_disq.jpg');
    
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.1s linear, background-image 0.2s;
}

#vinylDisc.playing {
    animation: spin 5s linear infinite; 
}

#discCenter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 25px; 
    height: 25px;
    background-color: #e0f8ff; 
    border: 1px solid #111;
    border-radius: 50%;
    z-index: 2; 
}

.progress-details {
    display: flex;
    flex-direction: column; 
    gap: 8px; 
}

#timeDisplay {
    color: #333; 
    font-family: monospace;
    font-size: 1.0em; 
    margin-bottom: 3px; 
    text-align: center; 
}
/* --- PROGRESS BAR --- */

#progressBarContainer {
    width: 100%;
    height: 6px; /* Ajuster la hauteur de la barre de progression */
    
    /* CONSERVÉ : Le petit point de contraste vert foncé au début */
    background: linear-gradient(to right, 
        #006400 2px,   /* Vert foncé (bien visible) sur 2 pixels */
        #e0e0e0 2px    /* Gris clair pour le reste de la barre non remplie */
    );
    
    border-radius: 3px;
    margin-top: 10px;
    position: relative;
    cursor: default;
}

#progressBar {
    height: 100%;
    
    /* NOUVEAU/RÉTABLI : Le dégradé du vert clair au vert foncé */
    background: linear-gradient(to right, #90EE90, #006400); 
    
    border-radius: 3px;
    width: 0%;
    position: relative;
    transition: width 0.1s linear;
}

#seekHandle {
    position: absolute;
    right: -7px; 
    top: 50%; 
    transform: translateY(-50%); 
    z-index: 100;
    
    width: 14px;
    height: 14px;
    background-color: white;
    border: 3px solid #add8e6;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); 
    transition: opacity 0.1s ease-out; 
    opacity: 0; 
}

#progressBarContainer:hover #seekHandle {
    opacity: 1;
}

.grabbing-cursor #seekHandle {
    opacity: 0; 
}

.playback-buttons {
    display: flex;
    gap: 10px; 
    margin-top: 0; 
    padding: 0; 
    flex-shrink: 0;
}

.playback-buttons button {
    background-color: #add8e6; 
    border: none;
    color: #333; 
    padding: 8px 10px; 
    font-size: 1.2em; 
    cursor: pointer;
    border-radius: 4px;
    transition: box-shadow 0.3s, background-color 0.3s;
}

/* Style spécifique pour les boutons Play/Pause et Stop (carrés) */
#playPauseButton, #stopButton {
    width: 40px; 
    height: 40px; 
    padding: 0; 
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Style des icônes pour qu'elles soient centrées et visibles */
.playback-buttons button .icon {
    display: block;
    line-height: 1; 
    font-size: 1.5em; 
    margin: 0;
}

.playback-buttons button:disabled {
    background-color: #b0c4de;
    color: #6c757d;
    cursor: not-allowed;
    box-shadow: none;
    border: none;
}

.playback-buttons button:not(:disabled):hover {
    box-shadow: 0 0 15px rgba(173, 216, 230, 0.8);
    background-color: #90c8d7;
    border: none;
}


/* ---------------------------------------------------------------------- */
/* --- PLAYLIST --- */
/* ---------------------------------------------------------------------- */

#playlistContainer {
    width: 100%;
    max-width: 750px;
    padding: 15px;
    background-color: #e6f0fa; 
    border: 5px solid #a9b9c9;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    flex-shrink: 0; 
}

#playlistContainer h4 {
    margin-top: 0;
    color: #4682b4;
    border-bottom: 2px solid #c3d6e8;
    padding-bottom: 5px;
    font-size: 1.1em;
}

#playlistList {
    list-style-type: none;
    padding: 0;
    margin: 10px 0 15px 0;
    font-size: 0.9em;
    max-height: 200px; 
    overflow-y: auto;
}

#playlistList li {
    padding: 5px 0;
    border-bottom: 1px dotted #c3d6e8;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#playlistList li:hover {
    background-color: #d4e0e8;
    cursor: pointer;
}

/* Conteneur de la piste pour aligner l'image et le texte */
#playlistList li.playlist-item-with-thumb {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Style de la miniature */
.playlist-thumbnail {
    width: 30px;
    height: 30px; 
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Le texte du titre doit pouvoir être tronqué */
#playlistList li span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Boutons de navigation de la playlist */
.playlist-navigation {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.playlist-navigation button {
    flex-grow: 1;
    background-color: #add8e6;
    color: #333;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s;
}

.playlist-navigation button:hover:not(:disabled) {
    background-color: #90c8d7;
}

.playlist-navigation button:disabled {
    background-color: #b0c4de;
    color: #6c757d;
    cursor: not-allowed;
}


/* ---------------------------------------------------------------------- */
/* --- MEDIA QUERIES (Adaptatif) --- */
/* ---------------------------------------------------------------------- */

@media (max-width: 650px) {
    .player-wrapper {
        gap: 5px; 
        max-width: 95%; 
    }
    
    .player-and-controls,
    .file-selectors,
    #playlistContainer {
        width: 100%;
        max-width: 100%;
    }

    .file-selectors {
        padding: 5px 0;
        flex-wrap: wrap; 
    }
    
    .custom-file-upload {
        font-size: 0.75em; 
        padding: 8px 3px;
    }

    #vinylDisc {
        width: 80px;
        height: 80px;
    }

    /* Adapter les métadonnées sur mobile */
    .buttons-and-metadata-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .playback-buttons {
        width: 100%;
        justify-content: space-around;
    }
}