/*
 * Explorateur de documents (views/Fichiers.php, web/js/fichiers.js).
 */

:root {
    --fx-bord: #e3ddd3;
    --fx-fond: #faf8f5;
    --fx-texte: #2b2622;
    --fx-gris: #8a8178;
    --fx-accent: #7a4a1e;
    --fx-ok: #3c8d40;
    --fx-danger: #b03a2e;
}

.fx {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    color: var(--fx-texte);
    margin-bottom: 30px;
}

/* --- Barre laterale -------------------------------------------------------- */

.fx-side {
    flex: 0 0 280px;
    background: #fff;
    border: 1px solid var(--fx-bord);
    border-radius: 10px;
    padding: 14px 10px;
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.fx-side-entete { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 6px; }
.fx-titre { font-size: 20px; margin: 0; }
.fx-titre .glyphicon { color: var(--fx-accent); margin-right: 4px; }
.fx-side-fermer { display: none; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--fx-gris); }

.fx-groupe { margin-top: 12px; }
.fx-groupe-titre {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--fx-gris);
    font-weight: 600;
    padding: 0 6px 4px;
}
.fx-groupe-nb { background: var(--fx-fond); border-radius: 8px; padding: 0 6px; margin-left: 3px; }
.fx-filtre { margin: 2px 0 6px; border-radius: 16px; }

.fx-espaces { list-style: none; margin: 0; padding: 0; }
.fx-espaces.replie:not(.filtre) .fx-sans-doc:not(.fx-visible) { display: none; }
.fx-espace {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 6px;
    color: var(--fx-texte);
    font-size: 13px;
}
.fx-espace:hover, .fx-espace:focus { background: var(--fx-fond); color: var(--fx-texte); text-decoration: none; }
.fx-espace.active { background: var(--fx-accent); color: #fff; }
.fx-espace-icone {
    flex: 0 0 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    background: var(--fx-fond);
    color: var(--fx-accent);
    overflow: hidden;
}
.fx-espace-icone img { width: 100%; height: 100%; object-fit: cover; }
.fx-espace.active .fx-espace-icone { background: rgba(255,255,255,.2); color: #fff; }
.fx-espace-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-espace-nom small { display: block; font-size: 11px; color: var(--fx-gris); overflow: hidden; text-overflow: ellipsis; }
.fx-espace.active .fx-espace-nom small { color: rgba(255,255,255,.75); }
.fx-espace-nb, .fx-tag {
    font-size: 11px;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--fx-fond);
    color: var(--fx-gris);
}
.fx-tag { background: #f3e6d8; color: var(--fx-accent); font-weight: 600; }
.fx-espace.active .fx-espace-nb, .fx-espace.active .fx-tag { background: rgba(255,255,255,.25); color: #fff; }
.fx-voir { padding-left: 6px; }
.fx-aide { font-size: 12px; color: var(--fx-gris); margin: 14px 6px 0; }

/* --- Zone principale ------------------------------------------------------- */

.fx-main {
    flex: 1;
    min-width: 0;
    min-height: 60vh;
    position: relative;
    background: #fff;
    border: 1px solid var(--fx-bord);
    border-radius: 10px;
}
.fx-barre {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--fx-bord);
}
.fx-barre .fx-btn-espaces { display: none; }
.fx-fil { flex: 1 1 200px; min-width: 0; font-size: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.fx-fil a { color: var(--fx-accent); }
.fx-fil [aria-current] { font-weight: bold; color: var(--fx-texte); }
.fx-fil-sep { color: var(--fx-gris); }
.fx-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fx-recherche { position: relative; }
.fx-recherche .glyphicon { position: absolute; left: 9px; top: 8px; color: var(--fx-gris); font-size: 12px; }
.fx-recherche input { padding-left: 27px; width: 170px; border-radius: 15px; }
.fx-vues .btn.active { background: var(--fx-accent); border-color: var(--fx-accent); color: #fff; box-shadow: none; }
.fx-ecriture { display: none; gap: 6px; }
.fx.ecriture .fx-ecriture { display: inline-flex; }
#fx-fichiers { display: none !important; }

.fx-contenu { padding: 8px 14px 16px; outline: none; }
.fx-chargement, .fx-vide { text-align: center; color: var(--fx-gris); padding: 60px 10px; }
.fx-vide .glyphicon { font-size: 40px; opacity: .5; }
.fx-vide p { margin: 10px 0 0; font-size: 15px; }
.fx-vide .fx-vide-aide { font-size: 13px; }
.fx-spinner {
    display: inline-block;
    width: 16px; height: 16px;
    vertical-align: -3px;
    border: 3px solid var(--fx-bord);
    border-top-color: var(--fx-accent);
    border-radius: 50%;
    animation: fx-tourne .8s linear infinite;
}
@keyframes fx-tourne { to { transform: rotate(360deg); } }

/* Liste */
.fx-items { list-style: none; margin: 0; padding: 0; }
.fx-liste .fx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    border-bottom: 1px solid #f1ede7;
    border-radius: 6px;
}
.fx-liste .fx-item:hover { background: var(--fx-fond); }
.fx-item-lien { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--fx-texte); }
.fx-item-lien:hover, .fx-item-lien:focus { color: var(--fx-accent); text-decoration: none; }
.fx-item-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-dossier .fx-item-nom { font-weight: 600; }
.fx-item-icone {
    flex: 0 0 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--fx-fond);
    color: var(--fx-gris);
    font-size: 15px;
}
.fx-g-dossier { color: #c98a12; background: #fdf3df; }
.fx-g-pdf { color: #b03a2e; background: #fbe9e7; }
.fx-g-image { color: #2e7d8a; background: #e2f2f4; }
.fx-g-texte { color: #2f5aa8; background: #e6edf9; }
.fx-g-tableur { color: #2e7d32; background: #e5f3e6; }
.fx-g-presentation { color: #c4571b; background: #fbebe1; }
.fx-g-archive, .fx-g-audio, .fx-g-video { color: #6a4c93; background: #efe9f6; }
.fx-item-meta { display: flex; gap: 16px; font-size: 12px; color: var(--fx-gris); white-space: nowrap; }
.fx-item-taille { min-width: 90px; text-align: right; }
.fx-item-date { min-width: 76px; }
.fx-item-actions { display: flex; gap: 4px; min-width: 84px; justify-content: flex-end; opacity: .35; transition: opacity .15s; }
.fx-item:hover .fx-item-actions, .fx-item:focus-within .fx-item-actions { opacity: 1; }
.fx-btn-suppr:hover { color: var(--fx-danger); }

/* Vignettes */
.fx-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding-top: 8px; }
.fx-grille .fx-item {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--fx-bord);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow .15s;
}
.fx-grille .fx-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.fx-grille .fx-item-lien { flex-direction: column; gap: 6px; padding: 10px 8px 4px; text-align: center; }
.fx-grille .fx-item-icone { flex: none; width: 100%; height: 96px; font-size: 34px; }
.fx-grille .fx-vignette img { width: 100%; height: 100%; object-fit: cover; }
.fx-grille .fx-item-nom { max-width: 100%; font-size: 13px; }
.fx-grille .fx-item-meta { justify-content: center; padding: 0 6px 8px; }
.fx-grille .fx-item-date { display: none; }
.fx-grille .fx-item-taille { min-width: 0; text-align: center; }
.fx-grille .fx-item-actions { position: absolute; top: 6px; right: 6px; min-width: 0; opacity: 0; }

/* Depot */
.fx-depot {
    display: none;
    position: absolute;
    inset: 0;
    border: 3px dashed var(--fx-accent);
    border-radius: 10px;
    background: rgba(250,248,245,.94);
    color: var(--fx-accent);
    font-size: 18px;
    font-weight: 600;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    pointer-events: none;
    z-index: 5;
}
.fx-depot .glyphicon { font-size: 48px; }
.fx-main.survol .fx-depot { display: flex; }

/* Envois en cours */
.fx-envois:empty { display: none; }
.fx-envois { padding: 8px 14px 0; display: flex; flex-direction: column; gap: 4px; }
.fx-envoi { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.fx-envoi-nom { flex: 0 1 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-envoi-progression { flex: 1; height: 6px; border-radius: 3px; background: var(--fx-fond); overflow: hidden; }
.fx-envoi-barre { display: block; height: 100%; width: 0; background: var(--fx-accent); transition: width .2s; }
.fx-envoi-etat { flex: 0 0 auto; min-width: 60px; color: var(--fx-gris); }
.fx-envoi.ok .fx-envoi-barre { background: var(--fx-ok); width: 100%; }
.fx-envoi.ok .fx-envoi-etat { color: var(--fx-ok); }
.fx-envoi.erreur .fx-envoi-barre { background: var(--fx-danger); width: 100%; }
.fx-envoi.erreur .fx-envoi-etat { color: var(--fx-danger); }

/* Apercu */
.fx-apercu {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(20,17,14,.88);
    display: flex;
    flex-direction: column;
}
.fx-apercu[hidden] { display: none; }
.fx-apercu-barre { display: flex; align-items: center; gap: 6px; padding: 10px 14px; color: #fff; }
.fx-apercu-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fx-apercu-corps { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 14px 14px; }
.fx-apercu-corps img, .fx-apercu-corps video { max-width: 100%; max-height: 100%; object-fit: contain; }
.fx-apercu-corps iframe { width: 100%; max-width: 1100px; height: 100%; border: 0; background: #fff; border-radius: 4px; }
body.fx-modal { overflow: hidden; }

/* Notifications */
.fx-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    opacity: 0;
    z-index: 10001;
    padding: 10px 18px;
    border-radius: 8px;
    background: var(--fx-texte);
    color: #fff;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
    transition: opacity .25s, transform .25s;
    max-width: calc(100vw - 32px);
}
.fx-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.fx-toast.ok { background: var(--fx-ok); }
.fx-toast.erreur { background: var(--fx-danger); }

/* --- Mobile ---------------------------------------------------------------- */

@media (max-width: 991px) {
    .fx-side {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 300px;
        max-width: 85vw;
        max-height: none;
        z-index: 10000;
        border-radius: 0;
        transform: translateX(-105%);
        transition: transform .2s;
        box-shadow: 4px 0 20px rgba(0,0,0,.2);
    }
    .fx.side-ouverte .fx-side { transform: none; }
    .fx.side-ouverte::after { content: ""; position: fixed; inset: 0; z-index: 9999; background: rgba(20,17,14,.4); }
    .fx-side-fermer, .fx-barre .fx-btn-espaces { display: inline-block; }
}
@media (max-width: 767px) {
    .fx-barre { padding: 10px; }
    .fx-contenu { padding: 6px 8px 12px; }
    .fx-recherche input { width: 130px; }
    .fx-item-date { display: none; }
    .fx-liste .fx-item { flex-wrap: wrap; gap: 4px 10px; }
    .fx-liste .fx-item-meta { order: 3; flex-basis: 100%; padding-left: 42px; }
    .fx-liste .fx-item-taille { text-align: left; }
    .fx-item-actions { opacity: 1; min-width: 0; }
    .fx-grille .fx-item-actions { opacity: 1; }
}

/* Annulation d'un envoi en cours */
.fx-envoi-annuler { border: 0; background: none; color: var(--fx-gris); font-size: 18px; line-height: 1; padding: 0 4px; }
.fx-envoi-annuler:hover { color: var(--fx-danger); }

/* Parties et jeux sans document : estompes ; ceux qui en ont ressortent. */
.fx-vide-docs .fx-espace:not(.active) { color: #b3aba1; }
.fx-vide-docs .fx-espace:not(.active) .fx-espace-icone { opacity: .45; filter: grayscale(1); }
.fx-vide-docs .fx-espace:not(.active) .fx-espace-nom small { color: #c9c2b8; }
.fx-vide-docs .fx-espace:not(.active) .fx-tag { opacity: .6; }
.fx-vide-docs .fx-espace:hover, .fx-vide-docs .fx-espace:focus { color: var(--fx-texte); }
.fx-vide-docs .fx-espace:hover .fx-espace-icone, .fx-vide-docs .fx-espace:focus .fx-espace-icone { opacity: 1; filter: none; }
.fx-repliable .fx-espace-nb { background: var(--fx-accent); color: #fff; font-weight: 600; }

/* Miniatures (1re page des PDF, images) : posees sur l'icone, qui reste en
   secours si la miniature ne se charge pas. */
.fx-item-icone { position: relative; overflow: hidden; }
.fx-item-icone img { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .2s; }
.fx-item-icone.fx-vignette img { opacity: 1; }
.fx-item-icone.fx-vignette { background: #fff; box-shadow: inset 0 0 0 1px var(--fx-bord); }
.fx-item-icone.fx-vignette > .glyphicon { visibility: hidden; }
.fx-liste .fx-item-icone.fx-vignette { flex-basis: 34px; width: 34px; height: 44px; margin: -6px 0; }
.fx-liste .fx-item-icone img { object-fit: cover; object-position: top; }
.fx-grille .fx-item-icone { height: 150px; }
.fx-grille .fx-item-icone img, .fx-grille .fx-vignette img { object-fit: contain; }
.fx-grille .fx-g-pdf.fx-vignette { background: #f4f1ec; }
