/* Gestionnaire de fichiers – thème sombre (inspiré de dashboard.css) */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: row;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #e2e8f0;
  background: #0f172a;
  overflow: hidden;
}

[hidden] { display: none !important; }

/* Header */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 56px;
  padding: 0 1.25rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

.header__left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.header__logo {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  overflow: hidden;
}

.header__logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.header__logo-img.is-loaded {
  display: block;
}

.header__logo-img:not(.is-loaded) {
  display: none;
}

.header__logo-placeholder {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #64748b;
}

.header__logo-placeholder.is-hidden {
  display: none;
}

.header__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header__right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.header__nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: #a5b4fc;
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.header__nav-link:hover {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
}

.header__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header__username {
  font-size: 0.875rem;
  color: #cbd5e1;
}

.header__logout {
  padding: 0.4rem 0.85rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #e2e8f0;
  background: #334155;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.header__logout:hover {
  background: #475569;
}

.header__logout:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

/* Badges de rôle */

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.role-badge--admin {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.45);
}

.role-badge--contributor {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.4);
}

.role-badge--user {
  background: rgba(100, 116, 139, 0.25);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.45);
}

/* Layout principal */

.files-main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Explorateur */

.explorer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  padding: 1rem 1.25rem;
  overflow: hidden;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.breadcrumb__item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.breadcrumb__link {
  padding: 0.2rem 0.45rem;
  color: #a5b4fc;
  background: transparent;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.breadcrumb__link:hover {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
}

.breadcrumb__sep {
  color: #475569;
  user-select: none;
}

.breadcrumb__current {
  padding: 0.2rem 0.45rem;
  color: #94a3b8;
}

/* Barre d'outils */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.toolbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #e2e8f0;
  background: #334155;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.toolbar__btn:hover {
  background: #475569;
}

.toolbar__btn:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

.toolbar__btn--link {
  color: #cbd5e1;
}

/* Message global */

.global-message {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.8125rem;
  border-radius: 6px;
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.global-message--success {
  background: rgba(74, 222, 128, 0.1);
  color: #86efac;
  border-color: rgba(74, 222, 128, 0.35);
}

/* Liste de fichiers */

.file-list-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #1e293b;
  overflow: hidden;
}

.file-list {
  height: 100%;
  overflow-y: auto;
}

.file-list__empty {
  margin: 0;
  padding: 3rem 1rem;
  text-align: center;
  font-size: 0.9375rem;
  color: #64748b;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  cursor: default;
  transition: background 0.12s;
}

.file-row:last-child {
  border-bottom: none;
}

.file-row:hover {
  background: rgba(51, 65, 85, 0.45);
}

.file-row.is-selected {
  background: rgba(99, 102, 241, 0.15);
  border-left: 3px solid #6366f1;
  padding-left: calc(1rem - 3px);
}

.file-row--folder {
  cursor: pointer;
}

.file-row__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  color: #94a3b8;
}

.file-row__icon--folder {
  color: #818cf8;
}

.file-row__icon--pdf {
  color: #f87171;
}

.file-row__icon--video {
  color: #60a5fa;
}

.file-row__icon--image {
  color: #4ade80;
}

.file-row__icon--pointcloud {
  color: #fbbf24;
}

.file-row__icon--archive {
  color: #fb923c;
}

.file-row__name {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-row__size,
.file-row__date {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: #64748b;
  width: 4.5rem;
  text-align: right;
}

.file-row__date {
  width: 9rem;
}

.file-row__actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
}

.file-row:hover .file-row__actions,
.file-row__actions:focus-within,
.file-row__actions.is-open {
  opacity: 1;
}

.file-row__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.file-row__action-btn:hover {
  background: #334155;
  color: #f1f5f9;
}

.file-row__action-btn:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 1px;
}

.file-row__action-btn--danger:hover {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

/* Overlay drag & drop */

.drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.85);
  border: 2px dashed #6366f1;
  border-radius: 10px;
  z-index: 10;
  pointer-events: none;
}

.drop-overlay.is-active {
  display: flex;
}

.drop-overlay__text {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: #a5b4fc;
}

/* Progression upload */

.upload-progress {
  margin-top: 0.75rem;
  height: 6px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  border-radius: 999px;
  transition: width 0.1s linear;
}

.upload-message {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  min-height: 1.25rem;
}

.upload-message--success {
  color: #4ade80;
}

.upload-message--error {
  color: #f87171;
}

/* Masquer actions d'écriture pour le rôle user */

body.role-user .toolbar__btn--write {
  display: none;
}

body.role-user .file-row__action-btn--write {
  display: none;
}

/* Panneau de détails */

.details-panel {
  display: flex;
  flex-direction: column;
  width: 0;
  min-width: 0;
  padding: 0;
  background: #1e293b;
  border-left: 1px solid transparent;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s, border-color 0.3s;
}

.details-panel.is-open {
  width: min(420px, 45vw);
  padding: 1.25rem;
  border-left-color: #334155;
  overflow-y: auto;
}

.details-panel__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.details-panel.is-open .details-panel__close {
  display: flex;
}

.details-panel.is-open {
  position: relative;
}

.details-panel__close:hover {
  background: #334155;
  color: #f1f5f9;
}

.details-panel__title {
  margin: 0 2rem 1rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #f1f5f9;
  word-break: break-word;
}

.details-meta {
  margin: 0 0 1.25rem;
  padding: 0;
}

.details-meta__row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  font-size: 0.8125rem;
}

.details-meta__row dt {
  margin: 0;
  color: #64748b;
}

.details-meta__row dd {
  margin: 0;
  color: #cbd5e1;
  text-align: right;
}

/* Aperçu */

.details-preview {
  margin-bottom: 1.5rem;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  overflow: hidden;
}

.details-preview__placeholder,
.details-preview__unavailable {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: #64748b;
}

.details-preview__iframe {
  display: block;
  width: 100%;
  height: 480px;
  border: none;
  background: #fff;
}

.details-preview__video {
  display: block;
  width: 100%;
  max-height: 360px;
  background: #000;
}

.details-preview__image {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #0f172a;
}

.details-preview__actions {
  padding: 0.75rem;
  text-align: center;
  border-top: 1px solid #334155;
}

/* Annotations */

.annotations__heading {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.annotations__list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.annotations__item {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
}

.annotations__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.annotations__meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.annotations__author {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #e2e8f0;
}

.annotations__date {
  font-size: 0.75rem;
  color: #64748b;
}

.annotations__text {
  margin: 0;
  font-size: 0.875rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
}

.annotations__delete {
  flex-shrink: 0;
  padding: 0.2rem 0.5rem;
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #f87171;
  background: transparent;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s;
}

.annotations__delete:hover {
  background: rgba(248, 113, 113, 0.12);
}

.annotations__empty {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: #64748b;
}

.annotation-form__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.annotation-form__input {
  display: block;
  width: 100%;
  margin-bottom: 0.65rem;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: #e2e8f0;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 6px;
  resize: vertical;
  min-height: 4rem;
}

.annotation-form__input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

/* Boutons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn--primary {
  background: #6366f1;
  color: #fff;
}

.btn--primary:hover {
  background: #4f46e5;
}

.btn--secondary {
  background: #334155;
  color: #e2e8f0;
}

.btn--secondary:hover {
  background: #475569;
}

.btn:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

/* Chargement */

.file-list--loading {
  opacity: 0.55;
  pointer-events: none;
}

/* Responsive */

@media (max-width: 768px) {
  .header {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    padding: 0.75rem 1rem;
  }

  .header__title {
    font-size: 1rem;
  }

  .files-main {
    flex-direction: column;
  }

  .details-panel.is-open {
    width: 100%;
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid #334155;
  }

  .file-row__date {
    display: none;
  }

  .file-row__actions {
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .header__username {
    display: none;
  }

  .toolbar__btn span.btn-label {
    display: none;
  }
}
