/* =============================================
   LISTE MEDIA - Styles unifiés home + liste
   ============================================= */

#listContainer {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 10px;
    box-sizing: border-box;
}

#listContainer h3 {
    color: #3f2f1f;
    margin-bottom: 15px;
    font-size: 1.2em;
}

/* FILTRES */
#listFilters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 10; /* Les enfants restent cliquables */
}

/* Ligne 2 : Boutons + Recherche qui prend TOUT le reste */
.filter-row-2 {
    display: flex;
    gap: 8px;
    background: #d6c49e;
    align-items: center;
}

.filter-row-2 .filter-btn {
    flex-shrink: 0; /* Empêche les boutons de rétrécir */
}

.filter-row-2 .search-wrapper {
    flex: 1; /* Prend TOUT l'espace restant */
    display: flex;
    gap: 4px;
    min-width: 0; /* Important pour flex */
}

.filter-row-2 .search-wrapper input {
    flex: 1;
    width: 100%;
    min-width: 0;
}

.filter-row-2 .search-wrapper button {
    flex-shrink: 0;
}

/* Ligne 3 : 3 Selects EXACTEMENT 1/3 chacun */
.filter-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Force 1/3 chacun */
    gap: 8px;
    background: #d6c49e;
}

.filter-row-3 .filter-select {
    width: 100%;
    min-width: 0; /* Évite le débordement */
}

#filterTitle {
    height: 36px;
    flex: 1;
    padding-left: 10px;
    padding-right: 40px;
    margin: 0;
    border-radius: 8px;
    border: 2px solid #bdbdbd;
    background: white;
    color: #333;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border 0.3s;
}

#filterTitle:focus {
    border-color: #979088;
}

#filterTitle::placeholder {
    color: #999;
}

.search-wrapper {
    position: relative;
}

.search-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.search-toggle:hover {
    background: rgba(0,0,0,0.1);
}

/* Barre de médias - toute la largeur */
.media-bar {
    display: flex;
    gap: 2px;
    margin: 0 0 3px;
    background: #d6c49e;
    position: sticky;
    top: 0;
    z-index: 11;
    width: 100%;
    box-sizing: border-box;
}

.media-btn {
    flex: 1;
    padding: 12px 4px;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: bold;
    color: #fbf3e4;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--theme-color);
    min-width: 0; /* Permet de rétrécir sur mobile */
    box-shadow: 2px 3px 1px rgba(0, 0, 0, 0.2); /* Effet rebondi */
    transform: translateY(0);
}

.media-btn[data-media=""] {
    background: #998658ad; /* Couleur pour "Tous" */
}

.media-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
}

.media-btn.active {
    box-shadow: inset 3px 3px 2px 1px rgba(0, 0, 0, 0.3); /* Effet enfoncé */
    transform: translateY(2px);
    border-color: rgba(0, 0, 0, 0.3);
}

/* Mobile : textes plus courts si besoin */
@media (max-width: 600px) {
    .media-btn {
        padding: 10px 2px;
        font-size: 0.75em;
    }
}

.filter-select {
    height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 2px solid #bdbdbd;
    background: white;
    color: #333;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: border 0.3s;
    margin: 0;
}

.filter-select:focus {
    border-color: #979088;
}

.filter-toggle-group {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: #f5e8cc;
    border-radius: 8px;
    border: 2px solid #bdbdbd;
    height: 42px;
    align-items: center;
    box-sizing: border-box;
}

.filter-btn {
    height: 36px;
    border: none;
    border-radius: 6px;
    background: #f5e8cc;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.15s;
    /* Relief 3D : ombre foncée en bas + lumière en haut */
    box-shadow: 
        0 3px 0 rgba(0, 0, 0, 0.15),
        0 1px 2px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.filter-btn:hover {
    background: linear-gradient(to bottom, #ffffff 0%, #f0e6ca 100%);
}

.filter-btn[data-active="true"] {
    /* Effet enfoncé : ombre inversée */
    background: linear-gradient(to bottom, #d6c49e 0%, #c8b68a 100%);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.25),
        inset 0 1px 2px rgba(0, 0, 0, 0.15);
    transform: translateY(2px);
}

#listCount {
    font-size: 13px;
    color: #5a4a3a;
    padding: 2px 0 8px 0;
    font-style: italic;
    position: relative;
}

.sort-icons {
    position: absolute;
    right: 0;
    top: 0;
    display: inline-flex;
    gap: 12px;
}

.sort-icon {
    cursor: pointer;
    font-size: 1.1em;
    color: #666;
    transition: all 0.2s;
}

.sort-icon:hover {
    color: #333;
    transform: scale(1.15);
}

/* LISTE */
#artworksList {
    list-style: none;
    padding: 0;
    margin: 0;
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #e2874a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 5px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.artwork-item {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.15);
}

.artwork-item:hover {
    filter: brightness(1.05);
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2);
}

/* Ligne du haut : boutons + contenu */
.item-top {
    display: flex;
    align-items: stretch;
    background: var(--theme-color);
}

/* Bouton UPDATE */
.item-update-btn {
    width: 46px;
    min-width: 46px;
    background: url('../img/update.png') no-repeat center center;
    background-size: 20px 20px;
    border: none;
    border-right: 2px solid rgba(0, 0, 0, 0.1);
    color: transparent;
    text-indent: -9999px;
    cursor: pointer;
    box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.item-update-btn:hover {
    filter: brightness(0.7);
}

/* Zone centrale */
.item-center {
    flex: 1;
    padding: 8px 6px 8px 12px;
    min-width: 0;
}

/* Ligne 1 : ciné + titre + année */
.item-line1 {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.item-cinema-icon {
    font-size: 0.9em;
    flex-shrink: 0;
}

.item-short-icon {
    font-size: 0.9em;
    opacity: 0.8;
}

.item-title {
    flex: 1;
    font-weight: bold;
    font-size: 1em;
    /*white-space: nowrap;*/
    /*overflow: hidden;*/
    /*text-overflow: ellipsis;*/
}

.item-year {
    font-size: 0.85em;
    flex-shrink: 0;
}

/* Ligne 2 : kiff + date vue + notes */
.item-line2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
}

.item-kiff-icon {
    flex-shrink: 0;
    font-size: 1.1em;
}

.item-viewdate {
    flex: 1;
}

.item-grades {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.grade-stars {
    letter-spacing: -1px;
}

.grade-movie-badge {
    background: white;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 0.8em;
    font-weight: bold;
}

/* Ligne 3 : créateurs */
.item-line3 {
    font-size: 0.8em;
}

.item-role {
    font-weight: bold;
}

/* Flèche */
.item-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    font-size: 0.7em;
}

.item-arrow.open {
    transform: rotate(180deg);
}

/* Bouton DETAIL */
.item-detail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    min-width: 46px;
    border: none;
    border-left: 2px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    padding: 0;
    box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
    background-color: inherit; /* Hérite de la couleur de item-top */
}

.item-detail-btn:hover {
    filter: brightness(0.7);
}

.item-media-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
    opacity: 0.9;
}

.item-detail-btn:hover .item-media-icon {
    opacity: 1;
}

/* Critique en dessous (toute la largeur) */
.item-critique {
    background: var(--theme-color);
    opacity: 0.95;
    padding: 0 12px;
    font-size: 0.85em;
    font-style: italic;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.item-critique.open {
    padding: 8px 12px;
    max-height: 300px;
}

/* BOUTON CHARGER PLUS */
#loadMoreBtn {
    display: block;
    margin: 20px auto;
    padding: 12px 35px;
    background: #f5e8cc;
    color: #3f2f1f;
    border: 2px solid #979088;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95em;
    font-weight: bold;
    transition: all 0.2s;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.15);
}

#loadMoreBtn:hover {
    background: #979088;
    color: white;
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2);
}

#loadMoreBtn:active {
    transform: scale(0.98);
}

/* BARRE DE PROGRESSION */
#loadingBar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 1000;
    display: none;
}

#loadingBarInner {
    height: 100%;
    width: 30%;
    background: #7a3e5b;
    border-radius: 2px;
    animation: loadingSlide 1.5s ease-in-out infinite;
}

@keyframes loadingSlide {
    0%   { margin-left: 0%; width: 30%; }
    50%  { margin-left: 40%; width: 40%; }
    100% { margin-left: 100%; width: 0%; }
}

/* PANNEAU DETAIL */
#detailOverlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
}

#detailPanel {
    position: fixed;
    top: 0; right: 0;
    width: 95%;
    max-width: 600px;
    height: 100%;
    background: var(--theme-color);
    z-index: 101;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-sizing: border-box;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

#detailPanel.open {
    transform: translateX(0);
}

#closePanelBtn {
    position: sticky;
    top: 0;
    float: right;
    background: #979088;
    border: none;
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3em;
    z-index: 1;
    transition: all 0.2s;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}

#closePanelBtn:hover {
    background: #7a3e5b;
    transform: scale(1.05);
}

#detailContent {
    margin-top: 15px;
    clear: both;
}

/* RESPONSIVE */
@media (max-width: 500px) {
    #listFilters {
        gap: 6px;
    }

    .filter-toggle {
        font-size: 13px;
        padding: 5px 8px;
    }

    #filterTitle, #filterMedia {
        font-size: 13px;
    }

    .item-center {
        padding: 8px 6px 8px 12px;
    }

    .item-line3 {
        font-size: 0.75em;
    }
}