:root {
    --color-cyan: #00c6ff;
    --color-pink: #ff007f;
    --color-green: #00D084;
    --bg-light: #f8f9fa;
    --white: #ffffff;
        --text: #333;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--bg-light);
    margin: 0;
}

.container { max-width: 1300px; margin: 0 auto; padding: 20px; }

/* HEADER PUBLIC */
.public-header {
    background: var(--white);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-bottom: 3px solid var(--color-cyan);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1250px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.nav-and-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#select-collection-top {
    /* Dimensions et structure */
    min-width: 230px;
    height: 35px;
    padding: 0 15px;
    
    /* Couleurs et bordures */
    background-color: var(--white);
    border: 2px solid var(--color-cyan); /* Bordure affirmée */
    border-radius: 20px;
    
    /* Texte */
    font-family: 'Segoe UI', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #444;
    
    /* Curseur et interaction */
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    
    /* Suppression du style par défaut du navigateur */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    
    /* Ajout d'une petite flèche personnalisée via une image SVG en background */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2300c6ff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

/* Effet au survol */
#select-collection-top:hover {
    border-color: var(--color-pink);
    box-shadow: 0 4px 12px rgba(0, 198, 255, 0.15);
    transform: translateY(-1px);
}

/* Effet quand on clique dessus */
#select-collection-top:focus {
    border-color: var(--color-pink);
    box-shadow: 0 0 0 3px rgba(255, 0, 127, 0.1);
}

.btn-login-link {
    text-decoration: none;
    color: #888;
    font-size: 0.8rem;
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid #ddd;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.btn-login-link:hover { border-color: var(--color-pink); color: var(--color-pink); }

.btn-icon { display: none; }

/* Filtres */
.filter-bar { 
    max-width: 1200px; 
    margin: 20px auto; 
    padding: 0 20px; 
    display: flex; 
    flex-direction: column; 
    flex-wrap: wrap;
    gap: 10px; 
}
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-row input, .filter-row select { padding: 10px; border-radius: 8px; border: 1px solid #ddd; outline: none; flex: 1; min-width: 150px; }

/* --- ZONE DE TRI --- */
.sort-container {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Aligne le tri à droite */
    gap: 10px;
    margin: 20px 0;
    padding: 10px;
    background: #f8f9fa; /* Un fond gris très léger pour la distinguer */
    border-radius: 10px;
}

.sort-container label {
    font-weight: bold;
    font-size: 0.9rem;
    color: #666;
}

/* Style du menu déroulant de tri */
#sort-order {
    padding: 8px 12px;
    border: 2px solid var(--color-cyan); /* Utilise ta couleur principale */
    border-radius: 8px;
    background: white;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

#sort-order:hover {
    border-color: var(--color-dark);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}


/* GRILLE & CARTES (4 Colonnes) */
.items-grid { 
    max-width: 1250px; /* On élargit un tout petit peu le conteneur global */
    margin: 0 auto; 
    padding: 20px; 
    display: grid; 
    /* Le 240px permet de forcer le passage à 4 colonnes sur un écran classique */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
    gap: 15px; /* On réduit légèrement l'espace entre les cartes pour gagner de la place */
}

.item-card { 
    background: white; 
    border-radius: 12px; 
    padding: 12px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); 
    display: flex;
    flex-direction: column;
    /* On réduit ici pour éviter le vide excessif */
    min-height: 320px; 
    border-bottom: 4px solid #eee;
    transition: transform 0.2s;
}

.item-card img { 
    width: 100%; 
    height: 150px; /* On réduit un peu la hauteur de l'image */
    object-fit: contain; 
    margin-bottom: 10px; 
    border-radius: 10px; 
    background: #fafafa; 
}

.item-content { 
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
    gap: 2px; /* Espace serré entre les lignes de texte */
}

.item-card h4 { 
    margin: 5px 0 8px 0; 
    color: var(--text); 
    font-size: 0.95rem; 
    line-height: 1.2;
}

.item-card p { 
    margin: 2px 0; 
    font-size: 0.8rem; 
    color: #666; 
    border-left: 2px solid var(--color-cyan); /* Petite touche de couleur sur le côté */
    padding-left: 8px; 
}



/* --- ACTIONS (BOUTONS SANS CADRES) --- */
.card-actions { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-top: 15px; 
    padding-top: 15px; 
    border-top: 1px solid #f5f5f5; /* Ligne très discrète */
}

.btn-status { 
    border: none; /* Suppression du cadre */
    padding: 8px 16px; 
    border-radius: 12px; 
    font-size: 0.75rem; 
    font-weight: 700; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-status:active { transform: scale(0.95); }

select option:disabled {
    color: #ccc;
    font-style: italic;
    background-color: #f9f9f9;
}

.results-count {
    font-size: 0.9rem;
    color: #666;
    margin: 10px 0;
    padding: 5px 10px;
    border-left: 3px solid var(--color-cyan);
    background: #fdfdfd;
    font-weight: 500;
}

#current-count {
    color: var(--color-cyan);
    font-weight: bold;
    font-size: 1.1rem;
}

/* ============================================================
   HEADER PUBLIC - RESPONSIVE À SEUIL UNIQUE
   Seuil mesuré: largeur intrinsèque du header-content en nowrap
   (titre + select + bouton) ≈ 659px + ~30px de marge = 690px
   Le seuil bascule à 689px (2 lignes) / 690px (1 ligne).
   ============================================================ */
@media (max-width: 689px) {
    .header-content {
        flex-direction: column; /* Ligne 1 : titre seul */
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 10px;
        text-align: left;
    }

    .nav-and-actions {
        flex-direction: row; /* Ligne 2 : select + icône, sur la même ligne */
        flex-wrap: nowrap;
        width: 100%;
        gap: 10px;
    }

    #select-collection-top {
        flex: 1 1 auto; /* Le select prend l'espace restant */
        width: auto;
        max-width: none;
        min-width: 0;
    }

    .header-actions {
        flex-wrap: nowrap;
        flex-shrink: 0;
        width: auto;
    }

    /* Bouton rond, icône seule (le texte reste dans le DOM via .btn-label + title) */
    .btn-login-link {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .btn-login-link .btn-label {
        display: none;
    }

    .btn-icon {
        display: inline-block;
        font-size: 1.1rem;
        line-height: 1;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* 2 colonnes sur mobile */
        gap: 10px;
    }

    .item-card {
        padding: 10px;
        min-height: auto;
    }

    .item-card img {
        height: 120px; /* Images un peu plus petites */
    }

    .container {
        padding: 10px;
    }
}


/* Barre de filtres collante sous le header, à toutes les tailles d'écran.
   --header-height est injectée en JS (hauteur réelle du header, qui varie selon le breakpoint). */
.filter-bar {
    background-color: var(--bg-light);
    position: sticky;
    top: var(--header-height, 0px);
    z-index: 90; /* Juste en dessous du z-index du header (qui est à 100) */
}

/* ============================================================
   RÉORGANISATION DES FILTRES - PETIT ÉCRAN
   Ordre forcé : recherche seule / (possédé + marques) / (types + sous-types)
   / (séries + sous-séries) / tri seul — indépendamment de l'ordre DOM.
   ============================================================ */
@media (max-width: 700px) {
    .filter-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .filter-row,
    #dynamic-filters {
        display: contents;
    }

    .filter-row input,
    .filter-row select,
    #dynamic-filters select,
    .filter-bar > select {
        min-width: 0;
        flex: unset;
        width: 100%;
        box-sizing: border-box;
    }

    #filter-search    { grid-column: 1 / -1; order: 1; }
    #filter-possede   { order: 2; }
    #filter-marque    { order: 3; }
    #filter-type      { order: 4; }
    #filter-sousType  { order: 5; }
    #filter-serie     { order: 6; }
    #filter-sousSerie { order: 7; }
    #sort-order       { grid-column: 1 / -1; order: 8; }
}