/* Correction thème : empêche le conteneur parent de couper le viewer */
.box-wrapper:has(.pdfv-wrap) {
    overflow: visible !important;
}

/* =============================================
   PDF Viewer with TOC — Styles v2
   ============================================= */

.pdfv-wrap {
    display: flex;
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #f5f5f5;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    align-items: stretch;
}

/* ── Sidebar ── */
.pdfv-sidebar {
    width: 260px;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    transition: transform .3s ease;
    z-index: 10;
}

.pdfv-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.pdfv-close-sidebar {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    padding: 4px;
    line-height: 1;
}

/* ── TOC / Sommaire ── */
.pdfv-toc {
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}

/* Groupe */
.pdfv-toc-group {
    margin-bottom: 4px;
}

.pdfv-toc-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #999;
    cursor: pointer;
    user-select: none;
    gap: 6px;
}

.pdfv-toc-group-title:hover {
    color: #666;
}

.pdfv-toc-chevron {
    font-style: normal;
    font-size: 10px;
    transition: transform .2s;
    flex-shrink: 0;
}

.pdfv-toc-group.collapsed .pdfv-toc-chevron {
    transform: rotate(-90deg);
}

.pdfv-toc-items {
    list-style: none;
    margin: 0;
    padding: 0 0 4px;
    overflow: hidden;
    transition: max-height .25s ease;
}

.pdfv-toc-group.collapsed .pdfv-toc-items {
    max-height: 0 !important;
}

/* Item */
.pdfv-toc-item a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 18px;
    font-size: 13px;
    color: #444;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s, border-color .15s, color .15s;
    line-height: 1.4;
}

.pdfv-toc-item a:hover {
    background: #f0f4ff;
    color: #2a5bd7;
}

.pdfv-toc-item a.active {
    background: #eef2ff;
    border-left-color: #2a5bd7;
    color: #2a5bd7;
    font-weight: 600;
}

.pdfv-toc-icon {
    font-size: 12px;
    flex-shrink: 0;
    opacity: .5;
}

.pdfv-toc-item a.active .pdfv-toc-icon {
    opacity: 1;
}

/* ── Zone principale ── */
.pdfv-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Toolbar */
.pdfv-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.pdfv-toolbar-bottom {
    border-bottom: none;
    border-top: 1px solid #e0e0e0;
}

.pdfv-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 5px 10px;
    font-size: 14px;
    line-height: 1;
    transition: background .15s;
    color: #333;
}
.pdfv-btn:hover:not(:disabled) { background: #e0e0e0; }
.pdfv-btn:disabled { opacity: .4; cursor: default; }

.pdfv-page-info {
    font-size: 13px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pdfv-page-input {
    width: 46px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

.pdfv-zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.pdfv-zoom-level {
    font-size: 12px;
    color: #666;
    min-width: 38px;
    text-align: center;
}

/* Titre du document actif */
.pdfv-doc-title {
    padding: 6px 14px;
    font-size: 12px;
    color: #888;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 29px;
}

/* Canvas */
.pdfv-canvas-wrap {
    display: block;
    padding: 20px;
    position: relative;
    background: #888;
    box-sizing: border-box;
    overflow: auto;
}

.pdfv-canvas {
    display: none;
    box-shadow: 0 2px 16px rgba(0,0,0,.3);
    width: 100%;
    height: auto;
}

/* Placeholder (avant sélection) */
.pdfv-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    opacity: .7;
    pointer-events: none;
}

.pdfv-placeholder.hidden { display: none; }

/* Loading overlay */
.pdfv-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(136,136,136,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s;
}
.pdfv-loading-overlay.hidden { opacity: 0; pointer-events: none; }

.pdfv-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pdfv-spin .7s linear infinite;
}
@keyframes pdfv-spin { to { transform: rotate(360deg); } }

/* ── Hamburger ── */
.pdfv-hamburger {
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 9px;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.pdfv-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: #444;
    border-radius: 2px;
}

.pdfv-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 9;
}

/* ── Responsive ── */
@media (max-width: 680px) {
    .pdfv-hamburger { display: flex; }
    .pdfv-close-sidebar { display: block; }

    .pdfv-sidebar {
        position: absolute;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: 2px 0 12px rgba(0,0,0,.2);
    }
    .pdfv-sidebar.open { transform: translateX(0); }
    .pdfv-overlay.open { display: block; }
    .pdfv-toolbar { padding-left: 52px; }
}

.pdfv-error {
    color: #c0392b;
    padding: 12px;
    background: #fdf2f2;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    font-size: 14px;
}
