/* ILC File Sharing — couche spécifique de la charte ILC Pro (après ilc-pro.css). */

:root:not(#ilc-a):not(#ilc-b) body.ilc-pro.ilc-sharing {

  /* Utilisateur connecté dans la sidebar */
  & .sideUser.user-badge-panel {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    padding: 10px 12px !important;
    border: 1px solid var(--ux-border) !important;
    border-radius: var(--ux-r-lg) !important;
    background: var(--ux-surface-2) !important;
    box-shadow: none !important;
    color: var(--ux-text) !important;
    font: 600 13px/1.3 var(--ux-font) !important;
  }
  & .sideUser.user-badge-panel[hidden] { display: none !important; }
  & .user-badge-avatar {
    width: 30px !important;
    height: 30px !important;
    flex: 0 0 30px;
    display: grid;
    place-items: center;
    border: 0 !important;
    border-radius: 50% !important;
    background: var(--ux-brand-soft) !important;
    color: var(--ux-brand-text) !important;
    font: 700 13px/1 var(--ux-font) !important;
    box-shadow: none !important;
  }
  & #panelUserText { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Carte fichiers */
  & .filesPanel { display: flex; flex-direction: column; gap: 12px; padding: 14px !important; }
  & .filesPanel .table-wrap { border-radius: var(--ux-r) !important; }

  /* Fil d'Ariane */
  & .breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 !important; padding: 0 !important; background: none !important; border: 0 !important; }
  & .breadcrumbs .crumb {
    min-height: 30px !important;
    padding: 0 10px !important;
    border: 1px solid transparent !important;
    border-radius: var(--ux-r-sm) !important;
    background: transparent !important;
    color: var(--ux-text-2) !important;
    font: 500 13px/1 var(--ux-font) !important;
    box-shadow: none !important;
  }
  & .breadcrumbs .crumb:hover { background: var(--ux-surface-3) !important; color: var(--ux-text) !important; }
  & .breadcrumbs .crumb:last-child { color: var(--ux-text) !important; font-weight: 600 !important; }
  & .breadcrumbs .crumb.drag-over { border-color: var(--ux-brand) !important; background: var(--ux-brand-soft) !important; }

  /* Tableau des fichiers */
  & .file-table td:first-child { font-weight: 500; }
  & .file-table td:first-child :is(.ilc-ico, svg) { color: var(--ux-brand-text) !important; }
  & .file-table .linklike, & .file-table .nav-item {
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    color: var(--ux-text) !important;
    font: 600 13.5px/1.3 var(--ux-font) !important;
    cursor: pointer;
  }
  & .file-table .nav-item:hover { color: var(--ux-brand-text) !important; text-decoration: underline; }
  & .file-table td:last-child { white-space: nowrap; }
  & .file-table td:last-child .btn + .btn { margin-left: 4px; }
  & .file-table tr.drag-over-target td { background: var(--ux-brand-soft) !important; }
  & .file-table tr.is-dragging td { opacity: .5; }

  /* Import : barre de progression */
  & .upload-progress-wrap { flex: 1 1 220px; min-width: 200px; padding: 6px 10px; border: 1px solid var(--ux-border); border-radius: var(--ux-r); background: var(--ux-surface-2) !important; }
  & .upload-progress-head { display: flex; justify-content: space-between; color: var(--ux-text-2) !important; font-size: 12px; }
  & .upload-progress-bar { height: 6px; margin-top: 6px; border-radius: 999px; background: var(--ux-surface-3) !important; overflow: hidden; }
  & .upload-progress-fill { height: 100%; border-radius: 999px; background: var(--ux-brand) !important; box-shadow: none !important; }

  /* Modale de confirmation / saisie */
  & .app-modal-dialog { padding: 0 !important; overflow: hidden; }
  & .app-modal-message { margin: 0 !important; padding: 16px 20px 0 !important; color: var(--ux-text-2) !important; }
  & #appModalForm { padding: 0 !important; }
  & .app-modal-input-wrap { display: flex; flex-direction: column; gap: 6px; padding: 14px 20px 0; }
  & .app-modal-input-wrap[hidden] { display: none !important; }
  & .app-modal-error { color: var(--ux-red) !important; font-size: 12.5px; }
  & .app-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding: 12px 20px !important;
    border-top: 1px solid var(--ux-border);
    background: var(--ux-surface-2) !important;
  }

  /* Toasts */
  & .toast-stack .toast { color: var(--ux-text) !important; }
}

@media (max-width: 760px) {
  :root:not(#ilc-a):not(#ilc-b) body.ilc-pro.ilc-sharing {
    & .headerActions .btn span { display: none; }
    & .file-table thead { display: none; }
    & .file-table, & .file-table tbody, & .file-table tr, & .file-table td { display: block; width: 100%; }
    & .file-table tr { padding: 10px 12px; border-bottom: 1px solid var(--ux-border); }
    & .file-table tbody td { padding: 2px 0 !important; border: 0 !important; }
    & .file-table td:nth-child(2), & .file-table td:nth-child(4) { display: none; }
    & .file-table td:last-child { padding-top: 8px !important; white-space: normal; }
  }
}

/* Stockage du serveur (carte en bas de la sidebar) */
:root:not(#ilc-a):not(#ilc-b) body.ilc-pro.ilc-sharing {
  & .storageCard {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-r-lg);
    background: var(--ux-surface-2);
    color: var(--ux-text);
    font: 400 12.5px/1.35 var(--ux-font);
    &[hidden] { display: none; }
  }
  & .storageHead { display: flex; align-items: center; gap: 7px; color: var(--ux-text-2); font-weight: 600; font-size: 12px; }
  & .storageHead .ilc-ico { width: 16px; height: 16px; flex: 0 0 16px; color: var(--ux-brand-text) !important; }
  & .storageDisk:not(:empty) {
    margin-left: auto;
    padding: 1px 7px;
    border: 1px solid var(--ux-border-strong);
    border-radius: 999px;
    color: var(--ux-muted);
    font: 600 11px/1.5 var(--ux-mono);
  }
  & .storageBar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--ux-surface-3); box-shadow: inset 0 0 0 1px var(--ux-border); }
  & .storageBar > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--ux-brand);
    transition: width .5s var(--ux-ease), background-color .2s;
  }
  & .storageCard.is-warn .storageBar > span { background: var(--ux-orange); }
  & .storageCard.is-crit .storageBar > span { background: var(--ux-red); }
  & .storageMain { color: var(--ux-text-2); font-variant-numeric: tabular-nums; }
  & .storageMain b { color: var(--ux-text); font-weight: 700; }
  & .storageStats { display: grid; gap: 4px; margin: 0; }
  & .storageStats > div { display: flex; justify-content: space-between; gap: 8px; }
  & .storageStats dt { color: var(--ux-muted); }
  & .storageStats dd { margin: 0; color: var(--ux-text); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
  & .storageCard.is-warn #storageFree { color: var(--ux-orange); }
  & .storageCard.is-crit #storageFree { color: var(--ux-red); }
}
:root:not(#ilc-a):not(#ilc-b) body.ilc-pro.ilc-sharing {
  & .sideNav [hidden], & .storageStats > div[hidden] { display: none !important; }
}

/* Aperçu des fichiers texte (modale large, lecture seule) */
:root:not(#ilc-a):not(#ilc-b) body.ilc-pro.ilc-sharing {
  & .viewer-dialog:not(#ilc-c) {
    display: flex;
    flex-direction: column;
    width: min(1100px, 100%) !important;
    max-width: none !important;
    height: min(86vh, 900px);
  }
  & .viewer-heading { display: grid; gap: 2px; min-width: 0; }
  & .viewer-heading h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  & .viewer-meta { margin: 0; color: var(--ux-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
  & .viewer-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--ux-border);
    background: var(--ux-surface-2);
  }
  & .viewer-readonly { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; color: var(--ux-muted); font-size: 12.5px; }
  & .viewer-readonly .ilc-ico { width: 15px; height: 15px; color: var(--ux-brand-text) !important; }
  & #viewerWrap[aria-pressed="true"]:not(#ilc-c) { border-color: var(--ux-brand-ring) !important; background: var(--ux-brand-soft) !important; color: var(--ux-brand-text) !important; }
  & .viewer-notice {
    margin: 12px 20px 0;
    padding: 9px 12px;
    border: 1px solid var(--ux-orange-bd);
    border-radius: var(--ux-r);
    background: var(--ux-orange-bg);
    color: var(--ux-orange);
    font-size: 13px;
    &[hidden] { display: none; }
  }
  & .viewer-content {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 16px 20px;
    overflow: auto;
    background: var(--ux-input);
    color: var(--ux-text);
    font: 400 13px/1.55 var(--ux-mono);
    tab-size: 4;
    white-space: pre;
    outline: 0;
    &.is-wrapped { white-space: pre-wrap; overflow-wrap: anywhere; }
    &.is-loading, &.is-error { display: grid; place-items: center; font-family: var(--ux-font); color: var(--ux-muted); }
    &.is-error { color: var(--ux-red); }
  }
  & .file-table .previewable { cursor: pointer; }
  & .file-table .previewable:hover { color: var(--ux-brand-text) !important; text-decoration: underline; }
}
@media (max-width: 760px) {
  :root:not(#ilc-a):not(#ilc-b) body.ilc-pro.ilc-sharing {
    & .viewer-modal { padding: 0 !important; align-items: end; }
    & .viewer-dialog:not(#ilc-c) { height: calc(100dvh - var(--ilc-corporate-bar-height) - 12px); }
    & .viewer-toolbar .btn { flex: 1 1 0; justify-content: center; }
    & .viewer-readonly { flex: 1 0 100%; }
    & .viewer-content { padding: 12px 14px; font-size: 12.5px; }
  }
}
