/* =========================================
   1. RESET & BASE
========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: #000;
    color: white;
    height: 100vh;
    overflow: hidden; /* Empêche le scroll global, on scroll dans main-content */
}

/* =========================================
   2. LAYOUT GLOBAL (GRILLE)
========================================= */
.app-container {
    display: grid;
    grid-template-areas: 
        "sidebar main"
        "player player";
    grid-template-columns: 240px 1fr;
    grid-template-rows: 1fr 90px; /* Le player fait 90px de haut */
    height: 100vh;
}

/* =========================================
   3. SIDEBAR (GAUCHE)
========================================= */
.sidebar {
    grid-area: sidebar;
    background-color: #000;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

nav li {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #b3b3b3;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}
/* Liens (pour la page ajouter.html) */
nav li a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
}

nav li:hover, nav li.active {
    color: white;
}

.sidebar-divider {
    height: 1px;
    background: #282828;
    margin: 10px 0;
}

/* =========================================
   4. MAIN CONTENT (CENTRE)
========================================= */
.main-content {
    grid-area: main;
    background: linear-gradient(180deg, #222 0%, #121212 20%);
    background-color: #121212;
    overflow-y: auto; /* Le scroll se fait ici */
    border-radius: 8px;
    margin: 8px 8px 0 0;
    position: relative;
}

/* Barre du haut (Flèches + Recherche) */
.top-bar {
    position: sticky;
    top: 0;
    background-color: rgba(18, 18, 18, 0.9);
    backdrop-filter: blur(10px);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.nav-arrows button {
    background: rgba(0,0,0,0.7);
    border: none;
    border-radius: 50%;
    color: white;
    width: 32px;
    height: 32px;
    cursor: pointer;
    margin-right: 8px;
}

/* Barre de recherche */
.search-container {
    flex: 1;
    margin: 0 20px;
    max-width: 400px;
}
#search-input {
    width: 100%;
    padding: 10px 20px;
    border-radius: 50px;
    border: none;
    background-color: #ffffff;
    color: #000;
    font-weight: 600;
    outline: none;
}

.content-padding {
    padding: 20px 32px 100px; /* Padding bas pour ne pas être caché par le player */
}

h1 {
    font-size: 2rem;
    margin-bottom: 25px;
    font-weight: 700;
}

.section-title {
    font-size: 1.5rem;
    margin: 40px 0 20px 0;
    font-weight: 700;
}

/* =========================================
   5. GRILLE MUSIQUES (CARTES)
========================================= */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
}

.music-card {
    background-color: #181818;
    padding: 16px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    cursor: pointer;
    position: relative;
}

.music-card:hover {
    background-color: #282828;
}

.card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.music-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

/* Bouton Play Vert (sur l'image au survol) */
.play-btn-overlay {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #1DB954;
    color: black;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    cursor: pointer;
}

.music-card:hover .play-btn-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* Bouton Coeur (Like) */
.like-btn-card {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    z-index: 50;
    transition: transform 0.2s, color 0.2s;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}
.like-btn-card:hover {
    transform: scale(1.2);
    color: white;
}
.like-btn-card.liked {
    color: #1DB954; /* Vert quand liké */
    opacity: 1;
}

/* --- TYPOGRAPHIE CARTE (TITRE ET ARTISTE) --- */
.music-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px; /* Espace sous le titre */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
}

.artist-name {
    font-size: 0.85rem; /* Plus petit */
    color: #b3b3b3;    /* Gris clair */
    margin: 0;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Petit effet : l'artiste devient blanc au survol de la carte */
.music-card:hover .artist-name {
    color: white;
    transition: color 0.3s;
}

/* Classe utilitaire pour cacher les cartes (Recherche/Filtre) */
.hidden-card {
    display: none !important;
}

/* =========================================
   6. CATÉGORIES (PARCOURIR)
========================================= */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
}

.category-card {
    height: 180px;
    border-radius: 8px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.category-card:hover {
    transform: scale(1.02);
}

.category-card h3 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* =========================================
   7. PLAYER BAR (BAS)
========================================= */
.player-bar {
    grid-area: player;
    background-color: #181818;
    border-top: 1px solid #282828;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 200;
}

.player-left {
    display: flex;
    align-items: center;
    width: 30%;
}
.player-left img {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    margin-right: 14px;
    object-fit: cover;
}
.player-info h4 { font-size: 0.9rem; margin-bottom: 4px; }
.player-info p { font-size: 0.7rem; color: #b3b3b3; }

.player-center {
    width: 40%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.player-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 8px;
}

.control-btn {
    background: none;
    border: none;
    color: #b3b3b3;
    cursor: pointer;
    font-size: 1.2rem;
}
.control-btn:hover { color: white; }

.play-pause-main {
    background-color: white;
    color: black;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}
.play-pause-main:hover { transform: scale(1.05); }

.progress-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}
.progress-bar {
    height: 4px;
    background-color: #535353;
    border-radius: 2px;
    flex-grow: 1;
}
.progress-fill {
    width: 0%;
    height: 100%;
    background-color: white;
    border-radius: 2px;
}

.player-right {
    width: 30%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* =========================================
   8. FORMULAIRE D'AJOUT
========================================= */
.add-section {
    background: #181818;
    padding: 30px;
    border-radius: 8px;
    margin-top: 0;
}
.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}
input[type="text"], input[type="url"] {
    background: #333;
    border: 1px solid transparent;
    border-radius: 4px;
    color: white;
    padding: 12px;
    width: 100%;
}
.file-inputs {
    display: flex;
    gap: 10px;
    width: 100%;
}
.custom-file-upload {
    background: #333;
    color: white;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    flex: 1;
    text-align: center;
    border: 1px dashed #555;
}
input[type="file"] { display: none; }

.spotify-btn {
    background-color: #1DB954;
    color: black;
    font-weight: 700;
    padding: 14px 32px;
    border-radius: 500px;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    margin-left: auto;
    display: block;
}

/* =========================================
   9. MODALE VINYLE & ANIMATIONS
========================================= */
#vinyl-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(15px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}
#vinyl-overlay.active {
    display: flex;
    opacity: 1;
}

.vinyl-modal-content {
    display: flex;
    align-items: center;
    gap: 60px;
    max-width: 1000px;
    width: 90%;
    padding: 20px;
}
.vinyl-left-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}
.vinyl-right-col {
    flex: 1;
    color: white;
}

#overlay-title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 15px;
}
.separator-green {
    width: 60px;
    height: 4px;
    background-color: #1DB954;
    margin-bottom: 25px;
}
#overlay-desc {
    font-size: 1.1rem;
    color: #ccc;
    line-height: 1.6;
    max-width: 450px;
}

/* --- BOUTON ECOUTER / STOP --- */
#start-listening-btn {
    background-color: #1DB954;
    color: black;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 18px 50px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s;
    box-shadow: 0 0 20px rgba(29, 185, 84, 0.4);
}
#start-listening-btn:hover {
    transform: scale(1.05);
}

/* ETAT STOP (ROUGE) */
#start-listening-btn.stop-mode {
    background-color: #e91429;
    color: white;
    box-shadow: 0 0 20px rgba(233, 20, 41, 0.4);
}
#start-listening-btn.stop-mode:hover {
    background-color: #ff1e32;
    transform: scale(1.05);
}

/* --- LA PLATINE ET LE VINYLE --- */
.turntable {
    width: 340px;
    height: 340px;
    background: #222;
    border-radius: 20px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid #333;
}
.platter {
    width: 310px;
    height: 310px;
    background: #111;
    border-radius: 50%;
    position: absolute;
    border: 2px solid #2a2a2a;
}
.vinyl-record {
    width: 290px;
    height: 290px;
    background: repeating-radial-gradient(circle at center, #111 0, #111 2px, #222 3px, #222 4px);
    border-radius: 50%;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    /* Position initiale : en l'air */
    transform: scale(1.3) translateY(-400px);
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.17, 0.84, 0.44, 1), opacity 0.5s;
}
.vinyl-label {
    width: 90px;
    height: 90px;
    background: #1DB954;
    border-radius: 50%;
    border: 3px solid #000;
    position: relative;
}
.vinyl-label::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 15px;
    height: 15px;
    background: #ccc;
    border-radius: 50%;
}
.tonearm {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 110px;
    height: 12px;
    background: #888;
    transform-origin: right center;
    transform: rotate(-35deg);
    border-radius: 6px;
    transition: transform 1s ease;
    z-index: 20;
}
.close-overlay {
    position: absolute;
    top: 30px;
    right: 40px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    opacity: 0.6;
    transition: 0.2s;
}
.close-overlay:hover { opacity: 1; transform: scale(1.1); }

/* CLASSE JS ANIMATION */
.vinyl-record.dropping { transform: scale(1) translateY(0); opacity: 1; }
.vinyl-record.spinning { animation: spin 3s linear infinite; }
.turntable.playing .tonearm { transform: rotate(-15deg); }

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

/* =========================================
   10. RESPONSIVE (MOBILE)
========================================= */
@media (max-width: 900px) {
    .vinyl-modal-content {
        flex-direction: column;
        text-align: center;
        gap: 30px;
    }
    .vinyl-right-col { text-align: center; }
    
    .sidebar { display: none; } /* On cache la sidebar sur mobile */
    .app-container {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "main"
            "player";
    }
    .separator-green { margin: 15px auto; }
}