* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', sans-serif; }
body { display: flex; height: 100vh; background-color: #f4f4f9; }

/* --- SIDEBAR --- */
.sidebar { width: 250px; background-color: #1e1e2d; color: white; display: flex; flex-direction: column; padding: 20px; flex-shrink: 0; }
.logo { font-size: 24px; font-weight: bold; margin-bottom: 40px; color: #5b9bd5; }
.menu-item { padding: 15px; cursor: pointer; border-radius: 10px; margin-bottom: 10px; transition: 0.3s; display: flex; align-items: center; gap: 15px; }
.menu-item:hover { background-color: #2b2b40; }
.menu-item.active { background-color: #5b9bd5; color: white; }
.user-profile { margin-top: auto; padding-top: 20px; border-top: 1px solid #333; font-size: 0.9em; color: #aaa; }

/* --- MAIN CONTENT --- */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.top-bar { background: white; padding: 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* --- RECHERCHE --- */
.search-container { flex: 1; margin: 0 20px; display: flex; gap: 10px; }
.search-container input { padding: 10px; border-radius: 20px; border: 1px solid #ddd; width: 100%; max-width: 400px; background: #f9f9f9; }
.btn-search { padding: 0 20px; border-radius: 20px; border: none; background: #5b9bd5; color: white; cursor: pointer; transition: 0.2s; }
.btn-collection { padding: 0 20px; border-radius: 20px; border: 1px solid #ddd; background: white; color: #333; cursor: pointer; font-weight: bold; display: flex; align-items: center; gap: 8px; white-space: nowrap; transition: 0.2s; }

/* --- HEADER ACTIONS (Notifs & Settings) --- */
.header-actions {
    display: flex;
    gap: 10px;
    margin-left: 10px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%; /* Bouton parfaitement rond */
    background: white;
    border: 1px solid #ddd;
    color: #555;
    font-size: 1.1em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.btn-icon:hover {
    background-color: #5b9bd5;
    color: white;
    border-color: #5b9bd5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(91, 155, 213, 0.3);
}

/* Le petit point rouge de notification */
.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background-color: #e74c3c;
    border: 2px solid white;
    border-radius: 50%;
    display: none; /* Caché par défaut */
}

/* --- ZONE CONTENU --- */
.content-area { padding: 30px; overflow-y: auto; flex: 1; }

/* --- TOOLBAR --- */
.toolbar { background: white; padding: 15px; border-radius: 10px; margin-bottom: 20px; display: flex; gap: 15px; align-items: center; flex-wrap: wrap; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.toolbar select { padding: 8px; border: 1px solid #ddd; border-radius: 5px; background: #f9f9f9; cursor: pointer; }
.toolbar label { font-size: 0.9em; cursor: pointer; display: flex; align-items: center; gap: 5px; user-select: none; }
.count-badge {
    background-color: #5b9bd5; color: white; padding: 8px 15px; border-radius: 20px;
    font-weight: bold; font-size: 0.9em; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-left: auto; display: block;
}

/* --- CARTES --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
.card { background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: transform 0.2s; position: relative; }
.card:hover { transform: translateY(-5px); }

/* IMAGES */
.card img { 
    width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover;
    cursor: pointer; border-bottom: 1px solid #eee;
}
.card .vinyl-cover-img { aspect-ratio: 1 / 1; } /* Vinyle Carré */

.card-body { padding: 10px; }
.card-title { font-weight: bold; font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ACTIONS */
.card-actions { display: flex; gap: 5px; margin-top: 10px; }
.btn-action { flex: 1; border: none; padding: 5px; border-radius: 3px; cursor: pointer; color: white; font-size: 0.8em; }
.btn-edit { background: #f39c12; }
.btn-delete { background: #ff4d4d; }

/* --- BADGES & OVERLAYS --- */
.badge-container { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.badge { font-size: 0.7em; padding: 2px 6px; border-radius: 4px; color: white; }
.bg-4k { background: #333; border: 1px solid gold; color: gold; }
.bg-br { background: #007bff; }
.bg-dvd { background: #6c757d; }
.bg-steel { background: linear-gradient(45deg, #bdc3c7, #2c3e50); }

.poster-overlay {
    position: absolute; top: 5px; left: 5px; background: rgba(0, 0, 0, 0.8);
    color: white; font-size: 10px; font-weight: bold; padding: 2px 6px;
    border-radius: 4px; border: 1px solid rgba(255,255,255,0.3); z-index: 5;
}
.overlay-INT { background: #e67e22; }
.overlay-SAISON { background: #3498db; }
.overlay-COFFRET { background: #9b59b6; }

/* --- DASHBOARD (ACCUEIL) - GLOBAL --- */
.dashboard-stats {
    display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; width: 100%;
}
.stat-card {
    flex: 1; min-width: 200px; padding: 20px; border-radius: 12px; color: white;
    display: flex; align-items: center; gap: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.2s; cursor: pointer;
}
.stat-card:hover { transform: translateY(-5px); }
.stat-card i { font-size: 2.5em; opacity: 0.8; }
.stat-info h3 { font-size: 1.1em; font-weight: normal; opacity: 0.9; margin-bottom: 5px; }
.stat-info p { font-size: 2em; font-weight: bold; margin: 0; line-height: 1; }

.stat-movies { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.stat-series { background: linear-gradient(135deg, #3498db, #2980b9); }
.stat-vinyls { background: linear-gradient(135deg, #9b59b6, #8e44ad); }

/* Force la grille du dashboard */
#myCollection .grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px; width: 100%; margin-top: 20px;
}

/* --- MODALES --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 2000; display: none; justify-content: center; align-items: center; }
.modal { background: white; width: 90%; max-width: 800px; max-height: 90vh; border-radius: 10px; display: flex; overflow: hidden; position: relative; }
.modal-poster { width: 40%; object-fit: cover; }
.modal-info { padding: 30px; width: 60%; overflow-y: auto; }
.close-modal { position: absolute; top: 15px; right: 20px; font-size: 24px; cursor: pointer; color: #333; background: none; border: none; }
.form-group { margin-top: 20px; background: #f8f9fa; padding: 15px; border-radius: 8px; }
.radio-group { display: flex; gap: 15px; margin: 10px 0; }
.checkbox-group { margin: 5px 0; display: flex; gap: 20px; }
.btn-save { background: #28a745; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; width: 100%; font-size: 16px; margin-top: 10px; }

/* --- TOASTS --- */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #333; color: white; padding: 12px 24px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); display: flex; align-items: center; gap: 12px; font-weight: 500; animation: slideIn 0.3s forwards; }
.toast.success { background: #2ecc71; }
.toast.error   { background: #e74c3c; }
.toast.info    { background: #3498db; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }

/* =========================================
   📱 VERSION MOBILE (RESPONSIVE) - OPTIMISÉE
   ========================================= */
@media (max-width: 768px) {
    
    /* 1. Layout global vertical */
    body { flex-direction: column; }
    
    /* 2. La Sidebar devient une barre de navigation en bas (Bottom Bar) */
    .sidebar { 
        position: fixed; 
        bottom: 0; 
        left: 0; 
        width: 100%; 
        height: 60px; /* Plus fin pour laisser de la place */
        flex-direction: row; 
        justify-content: space-around; 
        padding: 0 10px; 
        z-index: 1000; 
        box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
        background: #1e1e2d; /* Fond opaque obligatoire */
    }
    .sidebar .logo, .sidebar .user-profile { display: none; }
    .menu-item { 
        flex-direction: column; 
        font-size: 0.65em; 
        gap: 2px; 
        padding: 8px; 
        background: transparent !important; 
        color: #888; 
        justify-content: center;
    }
    .menu-item i { font-size: 1.2em; margin-bottom: 2px; }
    .menu-item.active { color: #5b9bd5; }

    /* 3. Ajustement du contenu principal */
    .main-content { width: 100%; padding-bottom: 70px; } /* Marge pour ne pas cacher le bas */
    .content-area { padding: 15px; }

    /* 4. TOP BAR : On crée deux étages propres */
    .top-bar { 
        flex-direction: column; 
        gap: 15px; 
        padding: 15px; 
        background: white;
    }
    .top-bar h2 { display: none; } /* On cache le titre pour gagner de la place */

    /* ÉTAGE 1 : La Recherche (Tout en haut) */
    .search-container { 
        width: 100%; 
        margin: 0; 
        order: 1; 
    }
    
    /* ÉTAGE 2 : Les Actions (Notifications & Paramètres) en dessous */
    .header-actions {
        width: 100%;
        order: 2; 
        display: flex;
        justify-content: flex-end; /* Alignés à droite */
        gap: 15px; 
        padding-top: 10px;
        border-top: 1px solid #f0f0f0; 
    }

    /* On agrandit les boutons pour les pouces (Touch Friendly) */
    .btn-icon {
        width: 44px; 
        height: 44px;
        background: #f8f9fa;
        font-size: 1.2em;
    }

    /* Le bouton "Ma Collection" reste compact */
    .btn-collection { padding: 0 12px; font-size: 0; }
    .btn-collection i { font-size: 16px; margin: 0; }
    .btn-collection::after { content: "Coll."; font-size: 12px; margin-left: 5px; }


    /* --- RESTE DU CSS MOBILE (Filtres, Grille, Modales) --- */
    .btn-filter-mobile { display: block; width: 100%; padding: 12px; background: #fff; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 15px; text-align: left; }
    .toolbar { display: none !important; flex-direction: column; padding: 15px; gap: 15px; background: #f8f9fa; }
    .toolbar.mobile-open { display: grid !important; grid-template-columns: 1fr 1fr; animation: slideDown 0.3s; }
    .toolbar select, .toolbar label { width: 100%; grid-column: span 1; }
    #sortSelect, .toolbar label { grid-column: span 2; }
    
    /* Grille Mobile : 3 colonnes */
    .grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; }
    .card { background: transparent; box-shadow: none; }
    .card img { border-radius: 6px; }
    .card-body { padding: 4px 0 !important; text-align: center; }
    .card-title, .card-actions { display: none !important; }
    .badge-container { justify-content: center; gap: 2px; }
    .badge { font-size: 8px !important; padding: 2px 4px !important; }
    .count-badge { width: 100%; text-align: center; margin-left: 0; margin-bottom: 10px; order: -1; }

    /* Modales Mobile */
    .modal { width: 100%; height: 100%; border-radius: 0; flex-direction: column; overflow-y: auto; }
    .modal-poster { width: 100%; height: 250px; object-position: top; flex-shrink: 0; }
    .modal-info { width: 100%; padding-bottom: 120px !important; }
    .close-modal { background: white; border-radius: 50%; width: 40px; height: 40px; top: 10px; right: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.3); z-index: 10; }

    /* Logout Mobile */
    .mobile-logout { display: flex !important; color: #d9534f !important; }
}
/* PC par défaut */
.btn-filter-mobile { display: none; }
.mobile-logout { display: none !important; }