/* ============================================================
   Médiathèque & sélecteur — style Apple Photos (flat, sombre).
   ============================================================ */
.med,
.vw-overlay,
.pick-overlay {
    --ap-bg: #1c1c1e;
    --ap-card: #2c2c2e;
    --ap-card-hover: #3a3a3c;
    --ap-blue: #5a5a5c;
    --ap-red: #ff453a;
    --ap-text: #f5f5f7;
    --ap-text2: #98989d;
}

.med {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 22px;
    padding: 0 40px;
    align-items: flex-start;
    color: var(--ap-text);
}

/* ————— Colonne collections ————— */
.med-side {
    width: 230px;
    flex-shrink: 0;
    background: var(--ap-bg);
    border-radius: 16px;
    padding: 16px 12px;
}
.med-side-titre {
    margin: 0 0 12px 8px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--ap-text2);
    font-weight: 600;
}
.med-side-liste {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.med-side-row {
    display: flex;
    align-items: center;
    gap: 2px;
}
.med-side-item {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    background: none !important;
    border: none;
    color: var(--ap-text);
    text-align: left;
    padding: 9px 10px !important;
    margin: 0 !important;
    width: 100% !important;
    border-radius: 9px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s ease;
}
.med-side-item:hover {
    background: var(--ap-card) !important;
}
.med-side-item.actif {
    background: var(--ap-blue) !important;
    color: #fff;
}
.med-badge-nb {
    font-size: 0.75rem;
    color: var(--ap-text2);
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 1px 8px;
    min-width: 20px;
    text-align: center;
}
.med-side-item.actif .med-badge-nb {
    color: #fff;
    background: rgba(255, 255, 255, 0.25);
}
.med-side-actions {
    display: flex;
    gap: 0;
}
.med-side-actions button {
    background: none !important;
    border: none;
    color: var(--ap-text2);
    cursor: pointer;
    padding: 6px !important;
    width: auto !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    border-radius: 6px;
}
.med-side-actions button:hover {
    color: var(--ap-text);
    background: var(--ap-card) !important;
}
.med-side-rename {
    width: 100%;
    padding: 9px 10px;
    border-radius: 9px;
    border: 1px solid var(--ap-blue);
    background: #000;
    color: #fff;
    font-size: 0.95rem;
}
.med-side-nouvelle {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.med-side-nouvelle input {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    border-radius: 9px;
    border: none;
    background: var(--ap-card);
    color: #fff;
    font-size: 0.9rem;
}

/* Bouton primaire Apple (bleu) */
.med-btn-primaire {
    background: var(--ap-blue) !important;
    color: #fff !important;
    border: none;
    border-radius: 10px;
    padding: 9px 16px !important;
    margin: 0 !important;
    width: auto !important;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s ease;
}
.med-btn-primaire:hover {
    filter: brightness(1.1);
}
.med-btn-primaire:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ————— Zone principale ————— */
.med-main {
    flex: 1;
    min-width: 0;
}
.med-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.med-vue-titre {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--ap-text);
}
.med-file {
    color: var(--ap-text2);
    font-size: 0.85rem;
    max-width: 240px;
}
/* Zone de téléversement (style « cadre pointillé » comme les fichiers produits) */
.med-upload {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    border: 2px dashed #48484a;
    border-radius: 12px;
    color: var(--ap-text2);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: border-color 0.12s ease, color 0.12s ease;
}
.med-upload:hover { border-color: #8e8e93; color: #c7c7cc; }
.med-upload svg { flex-shrink: 0; display: block; }
.med-check {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ap-text2);
    font-size: 0.9rem;
    cursor: pointer;
}
.med-check input {
    accent-color: var(--ap-blue);
}
.med-vide {
    color: var(--ap-text2);
    padding: 30px 0;
}

/* ————— Grille de tuiles (carrées, fluides) ————— */
.med-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    /* Hauteur de ligne fixe : fiable en grille (aspect-ratio / padding-% ne
       dimensionnent PAS les lignes auto, surtout dans un conteneur overflow). */
    grid-auto-rows: 160px;
    gap: 14px;
}
.med-tuile {
    position: relative;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100%;
    border: none;
    background: var(--ap-card);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.med-tuile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* Léger voile gris au survol (par-dessus l'image, sous les badges) */
.med-tuile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(200, 200, 205, 0.18);
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 1;
    pointer-events: none;
}
.med-tuile:hover::before { opacity: 1; }
.med-tuile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
    z-index: 1;
}
.med-tuile-libre {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #fff;
    background: rgba(48, 209, 88, 0.9); /* vert Apple */
    padding: 2px 8px;
    border-radius: 20px;
    z-index: 2;
    pointer-events: none;
}

/* ============================================================
   Viewer plein écran (style Apple Photos)
   ============================================================ */
.vw-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.vw-close {
    position: absolute;
    top: 20px;
    right: 24px;
    z-index: 3;
    background: rgba(120, 120, 128, 0.32);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: background 0.15s ease;
}
.vw-close:hover {
    background: rgba(120, 120, 128, 0.55);
}
.vw-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    background: rgba(120, 120, 128, 0.28);
    border: none;
    color: #fff;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: background 0.15s ease;
}
.vw-nav:hover {
    background: rgba(120, 120, 128, 0.5);
}
.vw-prev { left: 24px; }
.vw-next { right: 24px; }

.vw-scene {
    position: relative;
    max-width: 92vw;
    max-height: 78vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.vw-img {
    max-width: 92vw;
    max-height: 78vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

/* Panneaux flottants (Gérer / Partager) */
.vw-panneau {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 44, 46, 0.82);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 16px;
    padding: 14px;
    min-width: 260px;
    max-width: min(520px, 88vw);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.vw-panneau-titre {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ap-text2);
    margin-bottom: 10px;
}
.vw-panneau-vide {
    color: var(--ap-text2);
    font-size: 0.9rem;
}
.vw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.vw-chip {
    background: rgba(120, 120, 128, 0.28);
    border: none;
    color: #fff;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease;
}
.vw-chip:hover {
    background: rgba(120, 120, 128, 0.45);
}
.vw-chip.actif {
    background: var(--ap-blue);
}
.vw-panneau-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    color: #fff;
    padding: 12px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    transition: background 0.15s ease;
}
.vw-panneau-action:hover {
    background: rgba(120, 120, 128, 0.3);
}

/* Barre d'actions du bas (pilule flottante) */
/* Modal Gérer / Partager (viewer médiathèque) — propre et centré. */
.vwm-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.vwm-modal {
    background: #1c1c1e;
    border-radius: 18px;
    width: min(380px, 100%);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #f5f5f7;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.vwm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #2c2c2e;
}
.vwm-header h3 { margin: 0; font-size: 1.1rem; }
.vwm-close {
    width: 32px !important;
    height: 32px;
    padding: 0 !important;
    margin: 0 !important;
    border: none;
    border-radius: 50%;
    background: rgba(120, 120, 128, 0.3) !important;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.vwm-close::after { content: none; }
.vwm-close:hover { background: rgba(120, 120, 128, 0.5) !important; }
.vwm-body {
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vwm-vide { color: #98989d; margin: 8px 4px; }
.vwm-coll,
.vwm-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px 14px !important;
    background: #2c2c2e !important;
    color: #fff !important;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    text-align: left;
    text-decoration: none;
}
.vwm-coll { justify-content: space-between; }
.vwm-coll::after,
.vwm-action::after { content: none; }
.vwm-coll:hover,
.vwm-action:hover { background: #3a3a3c !important; }
.vwm-coll.actif { background: #3a3a3c !important; }
.vwm-check { color: #30d158; font-weight: bold; flex-shrink: 0; }
.vwm-action svg { flex-shrink: 0; }

.vw-bar {
    position: absolute;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    gap: 6px;
    background: rgba(30, 30, 32, 0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.vw-bar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.72rem;
    min-width: 68px;
    transition: background 0.15s ease;
}
.vw-bar-btn:hover {
    background: rgba(120, 120, 128, 0.3);
}
.vw-bar-btn.actif {
    background: rgba(120, 120, 128, 0.45);
}
.vw-bar-suppr {
    color: var(--ap-red);
}
.vw-bar-suppr:hover {
    background: rgba(255, 69, 58, 0.18);
}

/* ============================================================
   Sélecteur (modal) — style Apple, sans plein écran
   ============================================================ */
.pick-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.pick-modal {
    background: var(--ap-bg);
    border-radius: 20px;
    width: min(960px, 100%);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--ap-text);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.pick-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
}
.pick-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}
.pick-close {
    background: rgba(120, 120, 128, 0.28);
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}
.pick-close:hover {
    background: rgba(120, 120, 128, 0.5);
}
.pick-barre {
    display: flex;
    gap: 10px;
    padding: 0 22px 16px;
    flex-wrap: wrap;
}
.pick-barre select,
.pick-barre input {
    padding: 9px 12px;
    border-radius: 10px;
    border: none;
    background: var(--ap-card);
    color: #fff;
    font-size: 0.9rem;
}
.pick-barre input {
    flex: 1;
    min-width: 140px;
}
.pick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    grid-auto-rows: 130px;   /* hauteur de ligne fixe (fiable en conteneur scrollable) */
    gap: 12px;
    padding: 0 22px 22px;
    overflow-y: auto;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .med {
        flex-direction: column;
        padding: 0 16px;
    }
    .med-side {
        width: 100%;
    }
    .vw-scene, .vw-img { max-width: 96vw; }
}

/* ============================================================
   Apparence (backgrounds éditables)
   ============================================================ */
.apparence {
    flex: 1;
    min-width: 0;
    padding: 0 40px;
}
.apparence-intro {
    color: #bbb;
    margin-bottom: 24px !important;
    max-width: 700px;
}
.apparence-liste {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.apparence-item {
    display: flex;
    gap: 18px;
    background-color: #1a1a1a;
    border-radius: 12px;
    padding: 14px;
    align-items: center;
}
.apparence-apercu {
    width: 220px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    background-color: #222;
    flex-shrink: 0;
}
.apparence-infos {
    flex: 1;
    min-width: 0;
}
.apparence-infos h3 {
    margin: 0 0 6px;
    font-size: 1.15em;
}
.apparence-chemin {
    color: #888;
    font-size: 0.8em;
    margin-bottom: 12px !important;
    word-break: break-all;
}
.apparence-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.apparence-actions .btn-sauvegarder {
    width: auto !important;
    margin: 0 !important;
    padding: 10px 16px !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    border-radius: 10px;
}
.btn-reinit {
    background-color: #333 !important;
    color: white;
    width: auto !important;
    margin: 0 !important;
    padding: 10px 16px !important;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.btn-reinit::after { content: none; }
.btn-reinit:hover {
    background-color: #444 !important;
}
@media (max-width: 768px) {
    .apparence {
        padding: 0 16px;
    }
    .apparence-item {
        flex-direction: column;
        align-items: stretch;
    }
    .apparence-apercu {
        width: 100%;
    }
}

/* ============================================================
   Doublons (style Apple)
   ============================================================ */
.dbl {
    /* Embarqué dans .med-main (déjà dans le padding de .med) → pas de padding propre. */
    min-width: 0;
    color: var(--ap-text);
    --ap-card: #2c2c2e;
    --ap-blue: #5a5a5c;
    --ap-text: #f5f5f7;
    --ap-text2: #98989d;
}
.dbl-entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.dbl-info {
    color: var(--ap-text2);
    max-width: 720px;
}
.dbl-groupes {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.dbl-groupe {
    background: #1c1c1e;
    border-radius: 16px;
    padding: 16px;
}
.dbl-groupe-tete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: 0.95rem;
    color: var(--ap-text2);
}
.dbl-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.dbl-photo {
    position: relative;
    width: 150px;
    height: 150px;
    padding: 0 !important;
    margin: 0 !important;
    border: 3px solid transparent;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: var(--ap-card);
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.dbl-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.dbl-photo:hover {
    transform: translateY(-2px);
}
.dbl-photo.gardee {
    border-color: #30d158; /* vert Apple = gardée */
}
.dbl-photo-usage {
    position: absolute;
    bottom: 6px;
    left: 6px;
    font-size: 0.68rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 7px;
    border-radius: 20px;
    pointer-events: none;
}
.dbl-photo-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #fff;
    background: #30d158;
    padding: 2px 8px;
    border-radius: 20px;
    pointer-events: none;
}
/* Bouton "Doublons" en haut de la sidebar médiathèque.
   `!important` neutralise la règle globale button{} du site (padding/width/margin/overflow). */
.med-doublons {
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    width: 100% !important;
    padding: 10px 12px !important;
    margin: 0 0 16px !important;
    border: none;
    background: var(--ap-card);
    border-radius: 10px;
    color: var(--ap-text);
    text-align: left;
    text-decoration: none;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    overflow: hidden;
    transition: background 0.15s ease;
}
.med-doublons::after { content: none; }
.med-doublons:hover {
    background: var(--ap-card-hover);
}
.med-doublons.actif {
    background: var(--ap-blue);
    color: #fff;
}
.med-doublons-ico {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: block;
}

/* ============================================================
   Survol : pas de soulignement (on supprime la barre du button::after
   global dans toute la médiathèque) — on garde les autres effets de hover.
   ============================================================ */
.med button::after,
.pick-overlay button::after,
.vw-overlay button::after,
.vwm-overlay button::after {
    content: none;
}
