body { background: #f5f6fa; }

.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
}
.login-body .card { border-radius: 12px; }

.navbar-brand { font-weight: 600; letter-spacing: 0.3px; }

.lib-switcher .nav-link {
  color: #495057;
  background: #fff;
  border: 1px solid #dee2e6;
  margin-right: 0.4rem;
}
.lib-switcher .nav-link.active {
  background: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

.card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 0;
  border-radius: 8px;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #eef1f4;
  padding: 0.85rem 1rem;
}

.table > :not(caption) > * > * {
  padding: 0.65rem 0.9rem;
}

.breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.btn-outline-secondary, .btn-outline-danger { border-color: #dee2e6; }
.btn-outline-secondary:hover { background: #f1f3f5; color: #212529; border-color: #ced4da; }

/* Ligne « dossier parent » */
.parent-row {
  background-color: #fafbfc;
}
.parent-row:hover {
  background-color: #f0f3f6;
}

/* Drag & drop */
.drag-row {
  cursor: grab;
}
.drag-row:active {
  cursor: grabbing;
}
.drag-row.dragging {
  opacity: 0.4;
}
.drop-target.drag-over {
  background-color: #cfe2ff !important;
  outline: 2px dashed #0d6efd;
  outline-offset: -3px;
}
.breadcrumb-item.drop-target {
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: background-color 0.15s;
}
.breadcrumb-item.drop-target.drag-over {
  background-color: #cfe2ff !important;
}

@media (max-width: 768px) {
  .container { padding-left: 0.6rem; padding-right: 0.6rem; }
  .lib-switcher { flex-wrap: wrap; }
  .lib-switcher .nav-link { font-size: 0.9rem; padding: 0.4rem 0.7rem; }
}

/* ─── Dark theme overrides ─────────────────────────────────────────── */
[data-bs-theme="dark"] body { background: #1a1d20; }

[data-bs-theme="dark"] .login-body {
  background: linear-gradient(135deg, #0d1b2a 0%, #1b2a3a 100%);
}

[data-bs-theme="dark"] .lib-switcher .nav-link {
  color: #dee2e6;
  background: #2b3035;
  border-color: #3a3f44;
}
[data-bs-theme="dark"] .lib-switcher .nav-link.active {
  background: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

[data-bs-theme="dark"] .card-header {
  background: #2b3035;
  border-bottom-color: #3a3f44;
}

[data-bs-theme="dark"] .btn-outline-secondary,
[data-bs-theme="dark"] .btn-outline-danger {
  border-color: #495057;
}
[data-bs-theme="dark"] .btn-outline-secondary:hover {
  background: #343a40;
  color: #f8f9fa;
  border-color: #6c757d;
}

[data-bs-theme="dark"] .parent-row { background-color: #23272b; }
[data-bs-theme="dark"] .parent-row:hover { background-color: #2b3035; }

[data-bs-theme="dark"] .drop-target.drag-over {
  background-color: #1c3257 !important;
  outline-color: #0d6efd;
}
[data-bs-theme="dark"] .breadcrumb-item.drop-target.drag-over {
  background-color: #1c3257 !important;
}

/* Theme switcher button group */
.theme-switcher .btn { line-height: 1; padding: 0.25rem 0.5rem; }

/* Table header (.table-light) — adapt to dark mode */
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > tr,
[data-bs-theme="dark"] .table-light > tr > th,
[data-bs-theme="dark"] .table-light > tr > td {
  --bs-table-bg: #2b3035;
  --bs-table-color: #dee2e6;
  --bs-table-border-color: #3a3f44;
  background-color: #2b3035;
  color: #dee2e6;
  border-color: #3a3f44;
}

/* ─── Miniatures & vue Grille ─────────────────────────────────────── */
.cover-thumb-list {
  width: 32px; height: 42px;
  object-fit: cover;
  border-radius: 3px;
  margin-right: 0.55rem;
  background: #e9ecef;
  vertical-align: middle;
  flex-shrink: 0;
}
[data-bs-theme="dark"] .cover-thumb-list { background: #343a40; }

.entry-name { display: inline-flex; align-items: center; min-width: 0; }
.entry-name .name-text { word-break: break-word; }

.view-switcher .btn { line-height: 1; }

.grid-view .grid-card {
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  background: var(--bs-body-bg);
  overflow: hidden;
  display: flex; flex-direction: column;
}
/* Animation hover uniquement avec une vraie souris (pas tactile iPad/iPhone) */
@media (hover: hover) and (pointer: fine) {
  .grid-view .grid-card {
    transition: transform .12s ease, box-shadow .12s ease;
  }
  .grid-view .grid-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
  }
}
.grid-view .grid-card .cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  background: #e9ecef;
  display: flex; align-items: center; justify-content: center;
}
[data-bs-theme="dark"] .grid-view .grid-card .cover-wrap { background: #343a40; }

.grid-view .grid-card .cover-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.grid-view .grid-card .cover-wrap .cover-placeholder {
  font-size: 2.6rem; color: var(--bs-secondary-color);
}
.grid-view .grid-card .cover-wrap .folder-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 0.7rem; padding: 0.1rem 0.45rem;
  border-radius: 999px; line-height: 1.2;
}
.grid-view .grid-card .body {
  padding: 0.55rem 0.6rem;
  font-size: 0.85rem;
  line-height: 1.25;
  flex: 1;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.grid-view .grid-card .body .name {
  word-break: break-word;
  hyphens: auto;
}
.grid-view .grid-card .body .meta {
  color: var(--bs-secondary-color);
  font-size: 0.72rem;
}
.grid-view .grid-card .body .actions {
  margin-top: auto;
  display: flex; justify-content: flex-end;
}
.grid-view .grid-card.drag-over {
  outline: 2px dashed #0d6efd;
  outline-offset: -3px;
}
.grid-view .parent-tile a {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; min-height: 140px;
  text-decoration: none; color: var(--bs-secondary-color);
  border: 1px dashed var(--bs-border-color);
  border-radius: 8px;
  font-size: 0.9rem;
}
.grid-view .parent-tile a:hover {
  background: var(--bs-tertiary-bg);
  color: var(--bs-emphasis-color);
}

/* Uniform card height in grid mode */
.grid-view .grid-card { height: 100%; }
.grid-view .grid-card .body .name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;     /* réserve la place de 2 lignes même quand le titre est court */
  line-height: 1.25;
}
.grid-view .parent-tile { height: 100%; }
.grid-view .parent-tile a { min-height: 0; }

/* Badge "dossier" en overlay sur la vignette en mode liste */
.thumb-wrap {
  position: relative;
  display: inline-block;
  margin-right: 0.55rem;
  vertical-align: middle;
  line-height: 0;
}
.thumb-wrap .cover-thumb-list { margin-right: 0; }
.folder-badge-list {
  position: absolute;
  bottom: -2px; right: -4px;
  background: #0d6efd;
  color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px;
  border: 2px solid var(--bs-body-bg);
  line-height: 1;
  pointer-events: none;
}
