/* =====================================================================
   PEPMAN — Composant de dépôt des pièces jointes
   Dépôt intuitif : cartes de pièces, glisser-déposer, aperçu instantané,
   progression par fichier et état de conformité.
   ===================================================================== */

/* --- Tableau de bord de progression ------------------------------- */
.upload-summary {
    position: sticky;
    top: 62px;
    z-index: 40;
    background: var(--pepman-white);
    border: 1px solid var(--pepman-ink-200);
    border-radius: var(--pepman-radius-lg);
    padding: 16px 20px;
    margin-bottom: var(--pepman-gap-lg);
    box-shadow: var(--pepman-shadow-sm);
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.upload-summary__gauge {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 220px;
    flex: 1;
}

.upload-summary__percent {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--pepman-navy-800);
    line-height: 1;
    min-width: 62px;
}

.upload-summary__meta { flex: 1; min-width: 140px; }
.upload-summary__label { font-size: .8125rem; font-weight: 600; color: var(--pepman-ink-700); }
.upload-summary__hint { font-size: .75rem; color: var(--pepman-ink-500); margin-top: 3px; }

.upload-summary__chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.upload-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: .8125rem;
    font-weight: 600;
    border: 1px solid var(--pepman-ink-200);
    background: var(--pepman-ink-50);
    color: var(--pepman-ink-700);
}

.upload-chip--ok { background: var(--pepman-success-100); border-color: #a6f4c5; color: var(--pepman-success-600); }
.upload-chip--missing { background: var(--pepman-danger-100); border-color: #fda29b; color: var(--pepman-danger-600); }
.upload-chip--review { background: var(--pepman-info-100); border-color: #b2ddff; color: var(--pepman-info-600); }

/* --- Sections par catégorie -------------------------------------- */
.upload-category { margin-bottom: 34px; }

.upload-category__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--pepman-ink-200);
}

.upload-category__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--pepman-navy-800);
}

.upload-category__count {
    font-size: .75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--pepman-ink-100);
    color: var(--pepman-ink-500);
}

.upload-category__count--ok { background: var(--pepman-success-100); color: var(--pepman-success-600); }

/* --- Grille de cartes de pièces ---------------------------------- */
.upload-grid {
    display: grid;
    gap: var(--pepman-gap);
    grid-template-columns: 1fr;
    align-items: start;
}

/* --- Carte d'une pièce ------------------------------------------- */
.upload-card {
    background: var(--pepman-white);
    border: 1.5px solid var(--pepman-ink-200);
    border-radius: var(--pepman-radius-lg);
    overflow: hidden;
    transition: border-color var(--pepman-transition), box-shadow var(--pepman-transition),
        transform var(--pepman-transition);
    position: relative;
    display: flex;
    flex-direction: column;
}

.upload-card:hover { border-color: var(--pepman-navy-500); box-shadow: var(--pepman-shadow-sm); }

.upload-card--required { border-left: 4px solid var(--pepman-navy-600); }
.upload-card--optional { border-left: 4px solid var(--pepman-ink-200); }

.upload-card--complete { border-color: #cbd8e8; background: linear-gradient(180deg, var(--pepman-navy-50), #fff 55%); }
.upload-card--complete.upload-card--required { border-left-color: var(--pepman-navy-600); }

.upload-card--rejected { border-color: #cbd2dc; background: linear-gradient(180deg, var(--pepman-ink-50), #fff 55%); }
.upload-card--rejected.upload-card--required { border-left-color: var(--pepman-ink-500); }

.upload-card--dragover {
    border-color: var(--pepman-navy-500);
    border-style: dashed;
    background: var(--pepman-navy-50);
    transform: scale(1.012);
    box-shadow: 0 0 0 4px rgba(42, 99, 168, .12);
}

.upload-card--uploading { border-color: var(--pepman-info-600); }
.upload-card--error { border-color: var(--pepman-danger-600); animation: shake 320ms ease; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* En-tête de carte */
.upload-card__head {
    padding: 14px 16px 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-bottom: 1px solid var(--pepman-ink-100);
}

.upload-card__icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--pepman-navy-100);
    color: var(--pepman-navy-700);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.upload-card--complete .upload-card__icon,
.upload-card--rejected .upload-card__icon { background: var(--pepman-navy-100); color: var(--pepman-navy-700); }

.upload-card__titles { flex: 1; min-width: 0; }

.upload-card__title-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 8px;
}

.upload-card__title {
    margin: 0;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--pepman-ink-900);
    word-break: break-word;
}

.upload-card__tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 2px 8px;
    border-radius: 999px;
    margin: 0;
}

.upload-card__tag--required { background: var(--pepman-navy-100); color: var(--pepman-navy-700); }
.upload-card__tag--optional { background: var(--pepman-ink-100); color: var(--pepman-ink-500); }
.upload-card__tag--conditional { background: var(--pepman-ink-100); color: var(--pepman-ink-700); }

/* Corps de carte */
.upload-card__body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 12px; }

.upload-card__help {
    font-size: .75rem;
    line-height: 1.5;
    color: var(--pepman-ink-500);
    margin: 5px 0 0;
}

.upload-card__help--clamp {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.upload-card__more {
    background: none;
    border: 0;
    padding: 0;
    color: var(--pepman-navy-600);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.upload-card__titles > .upload-card__more { margin-top: 4px; }

/* Zone de dépôt */
.dropzone {
    border: 1.5px dashed var(--pepman-ink-200);
    border-radius: var(--pepman-radius);
    padding: 18px 14px;
    text-align: center;
    background: var(--pepman-ink-50);
    transition: border-color var(--pepman-transition), background var(--pepman-transition);
    cursor: pointer;
    display: block;
}

.dropzone:hover,
.upload-card--dragover .dropzone {
    border-color: var(--pepman-navy-500);
    background: var(--pepman-navy-50);
}

.dropzone__icon { color: var(--pepman-navy-500); margin-bottom: 6px; }
.upload-card--dragover .dropzone__icon { color: var(--pepman-navy-700); }

.dropzone__text {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--pepman-navy-700);
    margin: 0 0 3px;
}

.dropzone__hint { font-size: .6875rem; color: var(--pepman-ink-500); margin: 0; }

.dropzone input[type="file"] { display: none; }

/* --- Aperçus de fichiers déposés --------------------------------- */
.file-list { display: flex; flex-direction: column; gap: 9px; }

.file-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--pepman-ink-200);
    border-radius: var(--pepman-radius);
    background: var(--pepman-white);
    transition: border-color var(--pepman-transition), opacity var(--pepman-transition);
}

.file-item--rejected { border-color: #fda29b; background: #fffbfa; }

.file-item__thumb {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--pepman-ink-100);
    flex-shrink: 0;
    display: grid;
    place-items: center;
    cursor: zoom-in;
    border: 1px solid var(--pepman-ink-200);
}

.file-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.file-item__thumb--pdf { background: var(--pepman-white); color: var(--pepman-danger-600); cursor: default; }

.file-item__meta { flex: 1; min-width: 0; }

.file-item__name {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--pepman-ink-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item__sub {
    font-size: .6875rem;
    color: var(--pepman-ink-500);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.file-item__actions { display: flex; gap: 4px; flex-shrink: 0; }

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid var(--pepman-ink-200);
    background: var(--pepman-white);
    color: var(--pepman-ink-500);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all var(--pepman-transition);
    padding: 0;
}

.icon-btn:hover { border-color: var(--pepman-navy-500); color: var(--pepman-navy-700); background: var(--pepman-navy-50); }
.icon-btn--danger:hover { border-color: var(--pepman-danger-600); color: var(--pepman-danger-600); background: var(--pepman-danger-100); }

/* --- Progression d'un envoi ------------------------------------- */
.upload-progress {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 10px 12px;
    border-radius: var(--pepman-radius);
    background: var(--pepman-info-100);
    border: 1px solid #b2ddff;
}

.upload-progress__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .75rem;
    font-weight: 600;
    color: var(--pepman-info-600);
    gap: 8px;
}

.upload-progress__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-progress__bar { height: 5px; background: rgba(23, 92, 211, .2); border-radius: 999px; overflow: hidden; }

.upload-progress__fill {
    height: 100%;
    width: 0;
    background: var(--pepman-info-600);
    border-radius: 999px;
    transition: width 180ms linear;
}

/* --- Message d'erreur local ------------------------------------- */
.upload-error {
    display: flex;
    gap: 9px;
    padding: 10px 12px;
    border-radius: var(--pepman-radius);
    background: var(--pepman-danger-100);
    border: 1px solid #fda29b;
    color: #7a271a;
    font-size: .8125rem;
    line-height: 1.5;
}

.upload-error svg { flex-shrink: 0; margin-top: 1px; }

/* --- Note de vérification --------------------------------------- */
.review-note {
    font-size: .75rem;
    padding: 7px 10px;
    border-radius: var(--pepman-radius-sm);
    background: var(--pepman-danger-100);
    border-left: 3px solid var(--pepman-danger-600);
    color: #7a271a;
}

.review-note--ok { background: var(--pepman-success-100); border-left-color: var(--pepman-success-600); color: #054f31; }

/* --- Barre d'actions collante ----------------------------------- */
.upload-actions {
    position: sticky;
    bottom: 0;
    z-index: 40;
    margin-top: var(--pepman-gap-lg);
    padding: 16px 20px;
    background: var(--pepman-white);
    border: 1px solid var(--pepman-ink-200);
    border-radius: var(--pepman-radius-lg);
    box-shadow: 0 -4px 20px rgba(16, 24, 40, .09);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* --- Visionneuse plein écran ------------------------------------ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(10, 31, 60, .94);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.lightbox--open { display: flex; }

.lightbox__img {
    max-width: 100%;
    max-height: 88vh;
    border-radius: var(--pepman-radius);
    box-shadow: var(--pepman-shadow-lg);
}

.lightbox__close {
    position: absolute;
    top: 20px;
    right: 24px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.lightbox__close:hover { background: rgba(255, 255, 255, .28); }

.lightbox__caption {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, .9);
    font-size: .875rem;
    text-align: center;
    padding: 8px 16px;
    background: rgba(255, 255, 255, .12);
    border-radius: 999px;
    max-width: 90vw;
}

/* --- Responsive ------------------------------------------------- */
@media (max-width: 700px) {
    body[data-area="space"] .upload-grid { grid-template-columns: 1fr; }
    body[data-area="space"] .upload-summary { position: static; padding: 12px; gap: 12px; }
    body[data-area="space"] .upload-summary__gauge { min-width: 0; }
    body[data-area="space"] .upload-summary__chips { width: 100%; }
    body[data-area="space"] .upload-chip { padding: 5px 9px; font-size: .75rem; }
    body[data-area="space"] .upload-actions { position: static; box-shadow: none; }
    body[data-area="space"] .file-item { flex-wrap: wrap; }
    body[data-area="space"] .file-item__actions { margin-left: auto; }
}
