/* ════════ Documents des chantiers (/chantiers/documents, chantiers-documents.js) ════════
   Explorateur et pièces de la messagerie : chantier-fichiers.css ; styles de base des composants : list.css */

:root {
    --cd-accent: #1e88e5;
    --cd-border: #e3e8ee;
    --cd-bg: #f5f7fa;
}

body {
    background: var(--cd-bg);
}

/* list.css (chargé pour les composants) fixe aussi main : la page garde sa mise en page sous le ruban */
main.full-height.cd-main {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100dvh;
    overflow: hidden;
}

/* ─ Mise en page : liste des chantiers | fichiers du chantier ─ */
.cd-app {
    flex: 1;
    min-height: 0;
    display: flex;
    width: 100%;
    background: #fff;
}

.cd-app.hidden,
.cd-none.hidden,
.cd-storage.hidden,
.cd-detail-inner.hidden,
.cd-empty.hidden {
    display: none;
}

.cd-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--cd-border);
}

.cd-sidebar-head {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--cd-border);
}

.cd-sidebar-head h1 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 700;
    color: #263238;
}

.cd-sidebar-head h1 .material-icons {
    color: #f9a825;
}

.cd-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border-radius: 10px;
    background: var(--cd-bg);
}

.cd-search .material-icons {
    font-size: 20px;
    color: #90a4ae;
}

.cd-search input {
    flex: 1;
    min-width: 0;
    height: 38px;
    border: none;
    background: none;
    outline: none;
    font: inherit;
    font-size: 14px;
}

.cd-show-done {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: #546e7a;
}

.cd-show-done span {
    font-size: 13px;
    color: #546e7a;
}

.cd-chantiers {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 6px;
}

.cd-list-empty {
    padding: 24px 12px;
    color: #90a4ae;
    font-size: 13px;
    text-align: center;
}

.cd-chantier {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-left: 3px solid var(--cd-color, transparent);
    border-radius: 8px;
    background: none;
    color: #263238;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.cd-chantier:hover {
    background: var(--cd-bg);
}

.cd-chantier.active {
    background: #e3f2fd;
}

.cd-chantier-icon {
    flex: none;
    font-size: 22px;
    color: #f9a825;
}

.cd-chantier-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cd-chantier-name {
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cd-chantier small {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    color: #78909c;
    font-size: 12px;
}

.cd-statut {
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 17px;
}

.cd-statut.prog { background: #fff3e0; color: #e65100; }
.cd-statut.cours { background: #e8f5e9; color: #2e7d32; }
.cd-statut.fini { background: #eceff1; color: #607d8b; }

/* Espace utilisé, en bas de la liste */
.cd-storage {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--cd-border);
    color: #455a64;
    font-size: 12px;
    text-decoration: none;
}

a.cd-storage[href]:hover {
    background: var(--cd-bg);
}

.cd-storage-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cd-storage-label > span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.cd-storage-label .material-icons {
    font-size: 16px;
    color: #64b5f6;
}

.cd-storage-label > b {
    color: #263238;
    font-weight: 600;
}

.cd-storage-bar {
    display: block;
    height: 6px;
    overflow: hidden;
    border-radius: 3px;
    background: #e3e9ed;
}

.cd-storage-bar > span {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--cd-accent);
}

.cd-storage[data-level="high"] .cd-storage-bar > span { background: #fb8c00; }
.cd-storage[data-level="full"] .cd-storage-bar > span { background: #e53935; }

/* ─ Fichiers du chantier choisi ─ */
.cd-detail {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
}

.cd-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #90a4ae;
    text-align: center;
}

.cd-empty .material-icons {
    font-size: 56px;
    color: #cfd8dc;
}

.cd-detail-inner {
    padding: 14px 24px 32px;
}

.cd-detail-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.cd-back {
    display: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: #455a64;
    cursor: pointer;
}

.cd-back:hover {
    background: var(--cd-bg);
}

.cd-detail-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cd-detail-title > span {
    overflow: hidden;
    font-size: 20px;
    font-weight: 700;
    color: #263238;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cd-detail-title > small {
    color: #78909c;
    font-size: 13px;
}

/* ─ Aucun chantier accessible ─ */
.cd-none {
    margin: 48px auto;
    padding: 0 16px;
    max-width: 480px;
    color: #455a64;
    text-align: center;
}

.cd-none > .material-icons {
    font-size: 56px;
    color: #b0bec5;
}

.cd-none > h1 {
    margin: 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: #263238;
}

/* ─ Téléphone : liste, puis fichiers du chantier choisi (bouton retour) ─ */
@media (max-width: 800px) {
    .cd-sidebar {
        width: 100%;
        border-right: none;
    }

    .cd-detail {
        display: none;
    }

    .cd-app.cd-has-detail .cd-sidebar {
        display: none;
    }

    .cd-app.cd-has-detail .cd-detail {
        display: block;
    }

    .cd-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .cd-detail-inner {
        padding: 10px 12px 24px;
    }
}

/* Ligne « Ce chantier » sous la jauge : espace occupé par le chantier affiché */
.cd-storage-site {
    margin-top: 2px;
    padding-top: 5px;
    border-top: 1px solid #eceff1;
}

.cd-storage-site i.material-icons {
    color: #ffb300 !important;
}
