/* PDF Viewer - Styles principaux */

.pdfv-viewer {
    position: relative;
    margin: 20px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #f9f9f9;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Barre d'outils */
.pdfv-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
}

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

.pdfv-toolbar-fixed {
    position: sticky;
    top: 0;
    z-index: 100;
}

.pdfv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.pdfv-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.pdfv-btn:active {
    background: #e0e0e0;
    transform: translateY(1px);
}

.pdfv-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Boutons spécifiques */
.pdfv-zoom-in,
.pdfv-zoom-out,
.pdfv-zoom-fit {
    font-weight: bold;
    font-size: 16px;
}

.pdfv-fullscreen {
    font-size: 18px;
}

.pdfv-download {
    color: #28a745;
}

.pdfv-print {
    color: #007bff;
}

/* Conteneur du canvas */
.pdfv-canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    height: 600px; /* Taille fixe pour éviter le redimensionnement */
    background: #f5f5f5;
    overflow: auto;   /* Permettre le scroll/panning quand on zoome */
}

/* Hauteur maximale dynamique basée sur l'attribut data-max-height */
.pdfv-viewer[data-max-height] .pdfv-canvas-container {
    max-height: attr(data-max-height);
}

/* Fallback pour les navigateurs qui ne supportent pas attr() */
.pdfv-viewer[data-max-height="80vh"] .pdfv-canvas-container {
    max-height: 80vh;
}

.pdfv-viewer[data-max-height="70vh"] .pdfv-canvas-container {
    max-height: 70vh;
}

.pdfv-viewer[data-max-height="60vh"] .pdfv-canvas-container {
    max-height: 60vh;
}

.pdfv-viewer[data-max-height="50vh"] .pdfv-canvas-container {
    max-height: 50vh;
}

.pdfv-canvas {
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #fff;
    transition: none; /* Éviter les transitions qui interfèrent avec le zoom */
}

/* Mode fit : canvas s'adapte au conteneur */
.pdfv-viewer[data-mode="fit"] .pdfv-canvas {
    max-width: 100%;
    height: auto;
}

/* Mode free : canvas garde sa taille fixe */
.pdfv-viewer[data-mode="free"] .pdfv-canvas {
    max-width: none;
}

/* Mode pan (glisser-déposer) */
.pdfv-viewer[data-panning="true"] {
    cursor: grabbing;
}

.pdfv-viewer[data-panning="true"] .pdfv-canvas-container {
    cursor: grabbing;
}

.pdfv-viewer[data-mode="free"] .pdfv-canvas-container {
    cursor: grab;
}

.pdfv-viewer[data-mode="free"] .pdfv-canvas-container:hover {
    cursor: grab;
}

/* Canvas en mode pan */
.pdfv-viewer[data-mode="free"] .pdfv-canvas {
    cursor: grab;
    transition: transform 0.1s ease-out;
}

.pdfv-viewer[data-panning="true"] .pdfv-canvas {
    cursor: grabbing;
    transition: none; /* Pas de transition pendant le pan */
}

/* Mode multipage */
.pdfv-multipage .pdfv-canvas-container {
    display: block;
    overflow-y: auto;
    max-height: 80vh;
}

/* Hauteur maximale pour le mode multipage */
.pdfv-viewer[data-max-height] .pdfv-multipage .pdfv-canvas-container {
    max-height: attr(data-max-height);
}

/* Fallback pour multipage */
.pdfv-viewer[data-max-height="80vh"] .pdfv-multipage .pdfv-canvas-container {
    max-height: 80vh;
}

.pdfv-viewer[data-max-height="70vh"] .pdfv-multipage .pdfv-canvas-container {
    max-height: 70vh;
}

.pdfv-viewer[data-max-height="60vh"] .pdfv-multipage .pdfv-canvas-container {
    max-height: 60vh;
}

.pdfv-viewer[data-max-height="50vh"] .pdfv-multipage .pdfv-canvas-container {
    max-height: 50vh;
}

.pdfv-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.pdfv-page {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.pdfv-page:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pdfv-page canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.pdfv-page-number {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.pdfv-page.loading {
    background: #f5f5f5;
    border-style: dashed;
}

.pdfv-page.loading::after {
    content: 'Chargement...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
}

/* Pagination */
.pdfv-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #ddd;
    font-size: 14px;
    color: #666;
}

.pdfv-page-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdfv-current-page,
.pdfv-total-pages {
    font-weight: 600;
    color: #333;
}

/* Mode plein écran */
.pdfv-viewer.pdfv-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border: none;
    border-radius: 0;
    margin: 0;
}

.pdfv-viewer.pdfv-fullscreen .pdfv-canvas-container {
    flex: 1;
    min-height: 0;
}

.pdfv-viewer.pdfv-fullscreen .pdfv-canvas {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
}

/* États de chargement et d'erreur */
.pdfv-viewer.loading::before {
    content: "Chargement du PDF...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 8px;
    z-index: 10;
    font-weight: 500;
    color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pdfv-error {
    color: #d63638;
    background: #fef7f1;
    border: 1px solid #d63638;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    margin: 20px;
}

/* Responsive design */
@media (max-width: 768px) {
    .pdfv-viewer {
        margin: 15px 0;
        border-radius: 6px;
    }
    
    .pdfv-toolbar {
        padding: 8px 12px;
        gap: 6px;
    }
    
    .pdfv-btn {
        min-width: 32px;
        height: 32px;
        padding: 6px;
        font-size: 12px;
    }
    
    .pdfv-canvas-container {
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .pdfv-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .pdfv-btn {
        justify-content: center;
        min-width: auto;
    }
}

/* Accessibilité */
.pdfv-btn:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Animations */
.pdfv-viewer {
    transition: all 0.3s ease;
}

.pdfv-btn {
    transition: all 0.2s ease;
}

/* Support des thèmes sombres */
@media (prefers-color-scheme: dark) {
    .pdfv-viewer {
        background: #2d2d2d;
        border-color: #444;
        color: #fff;
    }
    
    .pdfv-toolbar,
    .pdfv-pagination {
        background: #3d3d3d;
        border-color: #444;
        color: #fff;
    }
    
    .pdfv-btn {
        background: #4d4d4d;
        border-color: #555;
        color: #fff;
    }
    
    .pdfv-btn:hover {
        background: #5d5d5d;
        border-color: #666;
    }
    
    .pdfv-canvas-container {
        background: #1d1d1d;
    }
    
    .pdfv-error {
        background: #3d1d1d;
        border-color: #d63638;
        color: #ff6b6b;
    }
}

/* Accessibilité et focus */
.pdfv-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.3);
}

.pdfv-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.pdfv-btn:active {
    background: #e0e0e0;
    transform: translateY(1px);
}

/* Raccourcis clavier visibles */
.pdfv-btn[data-shortcut]::after {
    content: attr(data-shortcut);
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #666;
    background: #fff;
    padding: 2px 4px;
    border-radius: 2px;
    border: 1px solid #ddd;
    white-space: nowrap;
}

/* Navigation clavier améliorée */
.pdfv-viewer:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Indicateurs d'état pour lecteurs d'écran */
.pdfv-btn[aria-pressed="true"] {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

/* Support des préférences de réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
    .pdfv-btn {
        transition: none;
    }
    
    .pdfv-btn:active {
        transform: none;
    }
}
