/* ============================================================
   MÉDIATHÈQUE — CSS global
   ============================================================ */

/* ---- Body / Layout ---- */
body {
    background: #f1f5f9;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ---- Navbar ---- */
.navbar { min-height: 54px; flex-shrink: 0; }
.navbar .form-control::placeholder { color: #6c757d; }
.navbar .form-control:focus { background: #1e293b; color: #f1f5f9; border-color: #3b82f6; box-shadow: 0 0 0 .2rem rgba(59,130,246,.25); }

/* ---- Layout body (sidebar + main) ---- */
#layout-body {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}
#layout-body.sidebar-right { flex-direction: row-reverse; }

/* Main content scrollable */
#main-wrapper { overflow-y: auto; }

/* ---- Sidebar persistante ---- */
.app-sidebar {
    width: 220px;
    min-width: 220px;
    background: #212529;
    flex-shrink: 0;
    transition: width .2s ease, min-width .2s ease;
    overflow: hidden;
}
.app-sidebar.sidebar-collapsed {
    width: 52px;
    min-width: 52px;
}

/* Liens de navigation */
.sidebar-link {
    color: rgba(255,255,255,.72);
    transition: background .1s, color .1s;
    white-space: nowrap;
}
.sidebar-link:hover:not(.sidebar-active) {
    background: rgba(255,255,255,.07);
    color: #fff;
}
.sidebar-active {
    background: rgba(59,130,246,.22);
    color: #fff;
    font-weight: 600;
}
.sidebar-icon {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

/* Quand collapsed : masquer les labels */
.app-sidebar.sidebar-collapsed .sidebar-label,
.app-sidebar.sidebar-collapsed .sidebar-title,
.app-sidebar.sidebar-collapsed .sidebar-label-btn span,
.app-sidebar.sidebar-collapsed .sidebar-footer .sidebar-label {
    display: none;
}
.app-sidebar.sidebar-collapsed .sidebar-new-btn {
    padding-left: .5rem;
    padding-right: .5rem;
    justify-content: center !important;
}
.app-sidebar.sidebar-collapsed .sidebar-controls {
    justify-content: center;
}
.app-sidebar.sidebar-collapsed .sidebar-footer .d-flex.align-items-center {
    justify-content: center;
}
.app-sidebar.sidebar-collapsed .sidebar-footer .d-flex.gap-2.mt-2 {
    flex-direction: column;
    gap: .25rem !important;
}

/* Contrôles sidebar */
.sidebar-controls { min-height: 38px; }

/* ---- Sidebar mobile (offcanvas) ---- */
.offcanvas { width: 270px; }
.nav-icon { font-size: 1rem; width: 1.4rem; text-align: center; }
.active-link { background: rgba(59,130,246,.2); border-radius: 6px; font-weight: 600; }
.offcanvas .nav-link:hover:not(.active-link) { background: rgba(255,255,255,.06); border-radius: 6px; }

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    body { overflow: auto; height: auto; }
    #layout-body { overflow: visible; }
    #main-wrapper { overflow: visible; }
}

/* ---- Avatar ---- */
.avatar-circle {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg,#3b82f6,#6366f1);
    color: #fff; font-weight: 700; font-size: .95rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.avatar-circle-lg {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg,#3b82f6,#6366f1);
    color: #fff; font-weight: 700; font-size: 1.5rem;
    display: flex; align-items: center; justify-content: center;
}
.avatar-sm {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg,#3b82f6,#6366f1);
    color: #fff; font-weight: 700; font-size: .7rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ---- Cards ---- */
.card { border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
.card-title {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: #64748b; margin-bottom: .6rem;
}
.card-title::after {
    content: ''; display: block; height: 2px; width: 26px;
    background: #3b82f6; margin-top: .2rem; border-radius: 2px;
}
.kpi-card { transition: transform .15s; }
.kpi-card:hover { transform: translateY(-2px); }
.kpi-icon { font-size: 1.4rem; }

/* ---- Login ---- */
.login-card {
    width: 100%; max-width: 400px; padding: 2rem;
    background: #1e293b; border: 1px solid #334155;
    border-radius: 14px; box-shadow: 0 25px 50px rgba(0,0,0,.4);
}
.login-logo {
    width: 60px; height: 60px; background: linear-gradient(135deg,#3b82f6,#6366f1);
    border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.7rem; color: #fff;
}
.login-card .form-control { color: #fff !important; }
.login-card .form-control::placeholder { color: #64748b; }
.login-card .form-control:focus { background-color: #0f172a !important; border-color: #3b82f6; box-shadow: 0 0 0 .2rem rgba(59,130,246,.25); }

/* ---- Table œuvres ---- */
#oeuvre-table td { vertical-align: middle; }
.cover-placeholder {
    width: 56px; height: 72px; background: #f1f5f9; border-radius: 4px;
    display: flex; align-items: center; justify-content: center; color: #94a3b8;
}
.link-hover:hover { color: #3b82f6 !important; }

/* ---- Relations ---- */
.relation-box {
    border: 1px solid #e2e8f0; border-radius: 8px;
    padding: .5rem; background: #f8fafc;
}
.relation-list {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
    max-height: 240px; overflow-y: auto; padding: .2rem;
}
.relation-row {
    display: flex; align-items: center; gap: .6rem;
    padding: .3rem .5rem; border-radius: 5px;
    cursor: pointer; user-select: none; transition: background .1s;
}
.relation-row:hover   { background: #eff6ff; }
.relation-row.selected { background: #dbeafe; }
.relation-row label   { cursor: pointer; font-size: .88rem; flex-grow: 1; margin: 0; }
.relation-row input[type=checkbox] {
    appearance: none; -webkit-appearance: none;
    width: 17px; height: 17px; border: 2px solid #cbd5e1; border-radius: 4px;
    flex-shrink: 0; cursor: pointer; transition: all .1s;
    display: flex; align-items: center; justify-content: center;
}
.relation-row input[type=checkbox]:hover  { border-color: #3b82f6; }
.relation-row input[type=checkbox]:checked { background: #3b82f6; border-color: #3b82f6; }
.relation-row input[type=checkbox]:checked::after { content:'✓'; color:#fff; font-size:10px; font-weight:900; }

/* Texte surligné lors du filtrage */
mark.relation-highlight {
    background: #fef08a; color: inherit;
    padding: 0 1px; border-radius: 2px;
    font-weight: 600;
}
/* Ligne vide quand aucun résultat */
.relation-empty {
    padding: .5rem; text-align: center;
    color: #94a3b8; font-size: .82rem;
    font-style: italic;
}
/* Hint sous le champ de recherche */
.relation-hint {
    font-size: .75rem;
    min-height: 1.1em;
    line-height: 1.3;
}

/* ---- Cover dropzone ---- */
#cover-dropzone {
    border: 2px dashed #cbd5e1; border-radius: 8px; cursor: pointer;
    background: #f8fafc; min-height: 110px; padding: .75rem;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .15s, background .15s;
}
#cover-dropzone:hover { border-color: #3b82f6; background: #eff6ff; }
.drop-hint { text-align: center; }

/* ---- OCR Progress ---- */
.progress { border-radius: 10px; }

/* ---- Search highlight ---- */
mark { background: rgba(253,224,71,.5); border-radius: 3px; padding: 0 2px; }

/* ---- Responsive ---- */
@media (max-width: 576px) {
    main.container-fluid { padding-left: .75rem; padding-right: .75rem; }
}

/* ---- Purple badge (Bootstrap n'a pas bi-purple natif) ---- */
.text-purple { color: #7c3aed; }

/* ── Bibliothèque (page collections / tuiles) ────────────────────────── */
.collection-card {
    transition: transform .18s ease, box-shadow .18s ease;
    cursor: pointer;
}
.collection-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(0,0,0,.14) !important;
}
.collection-card-title {
    font-size: .85rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.oeuvre-tile {
    transition: transform .18s ease, box-shadow .18s ease;
    cursor: pointer;
}
.oeuvre-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(0,0,0,.14) !important;
}
.oeuvre-tile-link:focus .oeuvre-tile,
.oeuvre-tile-link:focus-visible .oeuvre-tile {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
.oeuvre-tile-cover {
    position: relative;
    height: 210px;
    overflow: hidden;
    background: linear-gradient(135deg, #1e293b, #334155);
    flex-shrink: 0;
}
.oeuvre-tile-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}
.oeuvre-tile-badges {
    position: absolute;
    top: .4rem;
    right: .4rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    align-items: flex-end;
}
.oeuvre-tile-title {
    font-size: .82rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.oeuvre-tile-authors {
    font-size: .72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #6c757d;
    margin-top: 1px;
}
.oeuvre-tile-stars {
    font-size: .65rem;
    color: #f59e0b;
    margin-top: 2px;
    letter-spacing: .03em;
}
