/* ======================================================
   documents.css — ENS-NDJ
   App Documents officiels (liste et détail).
   Chargé par documents/liste.html et documents/detail.html.
   ====================================================== */


/* ══════════════════════════════════════════════════════════════════════
   DOCUMENTS OFFICIELS
   Déplacé depuis main_core.css (lot B4, 21/11/2026) : ces règles
   ne s'appliquent qu'aux templates de cette page.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Documents spécifique (body.dark-mode) ── */
body.dark-mode .documents-filters { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); }

body.dark-mode .table-documents thead th { color: #fff !important; }

body.dark-mode .sidebar-card .list-group-item .badge { background: var(--color-background-light) !important; color: var(--color-text-secondary); }

body.dark-mode .viewer-content { background: #1e293b; }

body.dark-mode .viewer-unsupported { background: linear-gradient(135deg, #0f172a, #1e293b); }

body.dark-mode .copy-link-field .form-control { background: var(--color-background-light); border-color: var(--color-border); color: var(--color-text); }

.documents-page { min-height: 80vh; }

/* En-tete */
.documents-header { padding-bottom: 1rem; border-bottom: 2px solid var(--doc-primary); }

.documents-title {
    font-size: 1.5rem; font-weight: 700; color: var(--color-text);
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}

.documents-title i { color: var(--doc-primary); }

.documents-count {
    background: var(--doc-primary); color: #fff;
    font-size: 0.85rem; padding: 0.2rem 0.6rem; border-radius: 20px; font-weight: 500;
}

/* Filtres (sticky) */
.documents-filters {
    position: sticky; top: var(--doc-filters-top); z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.documents-filters .form-label { color: var(--color-text-muted); font-weight: 500; }

.active-filters small { color: var(--color-text-muted); }

.active-filters .badge a { text-decoration: none; font-weight: bold; }

/* Tableau */
.table-documents { margin-bottom: 0; }

.table-documents thead { background: linear-gradient(135deg, var(--doc-primary), #6366f1); }

.table-documents thead th {
    color: #fff; font-weight: 600; text-transform: uppercase;
    font-size: 0.75rem; letter-spacing: 0.5px; padding: 0.875rem 1rem;
    border: none; white-space: nowrap;
}

.table-documents tbody tr { border-bottom: 1px solid var(--color-border); }

.table-documents tbody tr:last-child { border-bottom: none; }

.table-documents td { padding: 0.875rem 1rem; vertical-align: middle; color: var(--color-text); }

/* Largeurs colonnes */
.th-categorie, .td-categorie { width: 140px; }

.th-annee, .td-annee { width: 80px; text-align: center; }

.th-titre, .td-titre { min-width: 250px; }

.th-actions, .td-actions { width: 200px; }

/* Titre document */
.doc-titre-link { font-weight: 500; color: var(--color-text); text-decoration: none; line-height: 1.4; display: block; }

/* Badge annee */
.annee-badge, .doc-mobile-year {
    display: inline-block; background: var(--color-background-light);
    color: var(--color-text-secondary); padding: 0.25rem 0.5rem;
    border-radius: 4px; font-weight: 600; font-size: 0.85rem;
}

/* Badges categories */
.badge-categorie {
    font-weight: 500; padding: 0.35rem 0.6rem; border-radius: 4px;
    font-size: 0.75rem; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 0.3rem; color: #fff;
}

/* Boutons actions */
.td-actions .btn-group { white-space: nowrap; }

.td-actions .btn { padding: 0.4rem 0.7rem; font-size: 0.8rem; }

.td-actions .btn i { font-size: 0.85rem; }

.td-actions .btn-text { margin-left: 0.3rem; }

/* Etat vide */
.empty-state { padding: 2rem; }

.empty-state i { font-size: 3rem; color: var(--color-text-muted); display: block; margin-bottom: 1rem; }

.empty-state p { color: var(--color-text-muted); margin-bottom: 1rem; }

/* Version mobile */
.documents-mobile-list { padding: 0; }

.document-mobile-card { padding: 1rem; border-bottom: 1px solid var(--color-border); }

.document-mobile-card:last-child { border-bottom: none; }

.doc-mobile-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }

.doc-mobile-title { margin-bottom: 0.5rem; font-weight: 500; line-height: 1.4; }

.doc-mobile-title a { color: var(--color-text); text-decoration: none; }

.doc-mobile-ref { display: block; color: var(--color-text-muted); margin-bottom: 0.75rem; }

.doc-mobile-actions { display: flex; gap: 0.5rem; }

.doc-mobile-actions .btn { flex: 1; text-align: center; }

.sidebar-header { background: var(--doc-primary); color: #fff; padding: 0.75rem 1rem; }

.sidebar-header h6 { display: flex; align-items: center; gap: 0.5rem; margin: 0; }

.sidebar-card .list-group-item {
    font-size: 0.9rem; padding: 0.6rem 1rem;
    border-color: var(--color-border); color: var(--color-text);
}

.sidebar-card .list-group-item.active { background-color: var(--doc-primary); border-color: var(--doc-primary); color: #fff; }

.sidebar-card .list-group-item .badge { font-size: 0.75rem; font-weight: 500; min-width: 28px; }

.sidebar-card .list-group-item.active .badge { background: rgba(255, 255, 255, 0.3) !important; color: #fff; }

/* Detail - En-tete */
.document-detail-header { padding-bottom: 1.5rem; border-bottom: 1px solid var(--color-border); }

.document-date { color: var(--color-text-muted); font-size: 0.9rem; }

.document-reference { color: var(--doc-primary); font-weight: 600; font-size: 0.95rem; }

.document-detail-title { font-size: 1.75rem; font-weight: 700; color: var(--color-text); line-height: 1.3; margin-bottom: 0.75rem; }

.document-description { font-size: 1rem; line-height: 1.6; }

/* Conteneur lecteur */
.document-viewer-container { border-radius: 8px; overflow: hidden; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); background: #1a1a2e; }

.viewer-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem; background: linear-gradient(135deg, #2d2d44, #1a1a2e); color: #fff;
}

.viewer-info { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }

.viewer-info i { font-size: 1.2rem; opacity: 0.8; }

.viewer-filename { font-weight: 500; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.viewer-filesize { opacity: 0.7; font-size: 0.85rem; }

.viewer-actions { display: flex; gap: 0.5rem; }

.viewer-actions .btn { padding: 0.4rem 0.6rem; }

/* Zone de contenu */
.viewer-content { position: relative; background: var(--color-background-light); }

.document-viewer-frame { width: 100%; height: 70vh; min-height: 500px; border: none; display: block; }

/* Fichier non previsable */
.viewer-unsupported {
    display: flex; align-items: center; justify-content: center;
    min-height: 400px; background: var(--color-background-light);
}

.unsupported-content { text-align: center; padding: 2rem; }

.unsupported-content i { font-size: 4rem; color: var(--doc-primary); margin-bottom: 1rem; opacity: 0.7; }

.unsupported-content h4 { color: var(--color-text); margin-bottom: 0.5rem; }

/* Carte actions */
.section-label {
    color: var(--color-text-muted); font-size: 0.85rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.75rem;
}

.section-label i { margin-inline-end: 0.5rem; }

/* Bouton telechargement */
.btn-download {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.75rem 1.25rem; border-radius: 8px; text-decoration: none;
}

.download-icon {
    width: 45px; height: 45px; background: rgba(255, 255, 255, 0.2);
    border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
}

.download-info { display: flex; flex-direction: column; align-items: flex-start; }

.download-action { font-weight: 600; font-size: 1rem; }

.download-meta { font-size: 0.8rem; opacity: 0.8; }

/* Boutons partage */
.share-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.btn-share {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 50%; border: none;
    cursor: pointer; color: #fff; font-size: 1.1rem;
}

.btn-share.whatsapp { background: #25D366; }

.btn-share.telegram { background: #0088cc; }

.btn-share.email { background: #ea4335; }

.btn-share.facebook { background: #1877f2; }

.btn-share.twitter { background: #1da1f2; }

.btn-share.copy { background: #6c757d; }

.btn-share.copy.copied { background: #28a745; }

/* Champ copie */
.copy-link-field { max-width: 350px; }

.copy-link-field .form-control { font-size: 0.8rem; background: var(--color-background-light); }

[dir="rtl"] .table-documents { text-align: right; }

[dir="rtl"] .td-annee { text-align: center; }

[dir="rtl"] .download-info { align-items: flex-end; }


@media (min-width: 1400px) {
    .th-titre, .td-titre { min-width: 350px; }
}

@media (max-width: 992px) {
    .documents-title { font-size: 1.25rem; }
    .td-actions .btn-text, .badge-text { display: none; }
    .th-categorie, .td-categorie { width: 120px; }
    .th-actions, .td-actions { width: 120px; }
}

@media (max-width: 768px) {
    .documents-header { text-align: center; }
    .documents-title { justify-content: center; }
    .documents-filters .row > div { margin-bottom: 0.5rem; }
    .document-detail-title { font-size: 1.4rem; }
    .document-viewer-frame { height: 50vh; min-height: 350px; }
    .viewer-toolbar { flex-direction: column; gap: 0.75rem; text-align: center; }
    .viewer-info { flex-wrap: wrap; justify-content: center; }
    .viewer-filename { max-width: 200px; }
    .btn-download { width: 100%; justify-content: center; }
    .share-buttons { justify-content: center; }
    .btn-share { width: 38px; height: 38px; font-size: 1rem; }
    .copy-link-field { max-width: 100%; }
}

@media (max-width: 576px) {
    .documents-page { padding-top: 1rem !important; padding-bottom: 1rem !important; }
    .documents-title { font-size: 1.1rem; }
    .documents-count { font-size: 0.75rem; padding: 0.15rem 0.4rem; }
    .documents-filters .card-body { padding: 0.75rem; }
    .document-mobile-card { padding: 0.875rem; }
    .doc-mobile-title { font-size: 0.95rem; }
    .doc-mobile-actions .btn { font-size: 0.8rem; padding: 0.4rem 0.6rem; }
    .badge-categorie { font-size: 0.7rem; padding: 0.25rem 0.4rem; }
    .document-detail-title { font-size: 1.2rem; }
    .document-viewer-frame { height: 40vh; min-height: 300px; }
    .viewer-unsupported { min-height: 250px; }
    .unsupported-content i { font-size: 3rem; }
    .download-icon { width: 40px; height: 40px; font-size: 1.1rem; }
}

@media (max-width: 360px) {
    .doc-mobile-actions { flex-direction: column; }
    .doc-mobile-actions .btn { width: 100%; }
}
