/**
 * PDF.js Viewer Styles
 * Interface moderne et responsive pour l'affichage des PDFs
 */

/* Conteneur principal */
.pdf-embed-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 30px 0;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.pdfjs-viewer-container {
    position: relative;
    width: 100%;
    background: #525659;
}

/* Barre d'outils */
.pdfjs-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #323639;
    border-bottom: 1px solid #1c1e20;
    flex-wrap: wrap;
    gap: 15px;
}

.pdfjs-controls-left,
.pdfjs-controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Boutons */
.pdfjs-btn {
    background: #474c50;
    border: 1px solid #5a5f63;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    text-decoration: none;
}

.pdfjs-btn:hover {
    background: #5a5f63;
    border-color: #6d7278;
}

.pdfjs-btn:active {
    background: #3a3f43;
    transform: scale(0.95);
}

.pdfjs-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pdfjs-btn:disabled:hover {
    background: #474c50;
    border-color: #5a5f63;
}

.pdfjs-btn span {
    font-size: 18px;
    line-height: 1;
}

/* Input de sélection de page */
.pdfjs-page-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #474c50;
    padding: 0 12px;
    border-radius: 4px;
    border: 1px solid #5a5f63;
}

.pdfjs-page-input {
    width: 50px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    padding: 8px 4px;
}

.pdfjs-page-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
}

/* Chrome/Safari - Retirer les flèches du input number */
.pdfjs-page-input::-webkit-outer-spin-button,
.pdfjs-page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox - Retirer les flèches du input number */
.pdfjs-page-input[type=number] {
    -moz-appearance: textfield;
}

.pdfjs-page-separator {
    color: #999;
    font-weight: normal;
}

.pdfjs-page-count {
    color: #ffffff;
    font-weight: bold;
    min-width: 30px;
}

/* Niveau de zoom */
.pdfjs-zoom-level {
    color: #ffffff;
    font-size: 14px;
    min-width: 50px;
    text-align: center;
}

/* Conteneur du canvas */
.pdfjs-canvas-container {
    position: relative;
    width: 100%;
    min-height: 500px;
    max-height: 750px;
    background: #525659;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
    padding: 20px;
}

/* Wrapper pour empiler les pages verticalement */
.pdfjs-pages-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    padding: 20px 0;
}

/* Conteneur de chaque page */
.pdfjs-page-container {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    background: white;
}

/* Canvas individuels */
.pdfjs-page-container .pdfjs-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Indicateur de chargement */
.pdfjs-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #ffffff;
    z-index: 10;
}

.pdfjs-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0071BF;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: pdfjs-spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes pdfjs-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message d'erreur */
.pdfjs-error {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #ff6b6b;
}

/* Mode plein écran */
.pdfjs-viewer-container:fullscreen {
    background: #525659;
}

.pdfjs-viewer-container:fullscreen .pdfjs-canvas-container {
    min-height: calc(100vh - 65px);
}

.pdfjs-viewer-container:-webkit-full-screen {
    background: #525659;
}

.pdfjs-viewer-container:-moz-full-screen {
    background: #525659;
}

/* Responsive - Tablettes */
@media screen and (max-width: 768px) {
    .pdfjs-toolbar {
        padding: 10px 15px;
        gap: 10px;
    }

    .pdfjs-controls-left,
    .pdfjs-controls-right {
        gap: 5px;
    }

    .pdfjs-btn {
        padding: 6px 12px;
        min-width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .pdfjs-page-input-wrapper {
        padding: 0 8px;
    }

    .pdfjs-page-input {
        width: 40px;
        font-size: 13px;
    }

    .pdfjs-zoom-level {
        font-size: 12px;
        min-width: 45px;
    }

    .pdfjs-canvas-container {
        min-height: 400px;
        padding: 15px;
    }
    
    .pdfjs-pages-wrapper {
        gap: 15px;
    }

    .pdfjs-canvas-container {
        min-height: 300px;
        max-height: 400px;
    }
}

/* Responsive - Mobile */
@media screen and (max-width: 480px) {
    .pdfjs-toolbar {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }

    .pdfjs-controls-left,
    .pdfjs-controls-right {
        width: 100%;
        justify-content: space-between;
    }

    .pdfjs-controls-left {
        order: 2;
    }

    .pdfjs-controls-right {
        order: 1;
    }

    .pdfjs-btn {
        flex: 1;
        max-width: calc(25% - 7.5px);
    }

    .pdfjs-page-input-wrapper {
        flex: 1;
        justify-content: center;
        padding: 0 10px;
    }

    .pdfjs-canvas-container {
        min-height: 300px;
        padding: 10px;
    }
    
    .pdfjs-pages-wrapper {
        gap: 10px;
        padding: 10px 0;
    }
}

/* Intégration WordPress - Blocs */
.wp-block-file .pdf-embed-wrapper {
    margin-top: 20px;
}

/* Amélioration de l'accessibilité */
.pdfjs-btn:focus {
    outline: 2px solid #0071BF;
    outline-offset: 2px;
}

.pdfjs-page-input:focus {
    outline: 2px solid #0071BF;
    outline-offset: 2px;
}

/* Animation du bouton plein écran */
.pdfjs-fullscreen span {
    transition: transform 0.2s ease;
}

.pdfjs-fullscreen:hover span {
    transform: scale(1.1);
}

/* Cacher le lien WordPress original quand le viewer est actif */
.wp-block-file a[href$=".pdf"] {
    display: none;
}

.wp-block-file:has(.pdf-embed-wrapper) a[href$=".pdf"] {
    display: none !important;
}

/* Amélioration du scroll dans le canvas container */
.pdfjs-canvas-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.pdfjs-canvas-container::-webkit-scrollbar-track {
    background: #3a3f43;
}

.pdfjs-canvas-container::-webkit-scrollbar-thumb {
    background: #5a5f63;
    border-radius: 6px;
}

.pdfjs-canvas-container::-webkit-scrollbar-thumb:hover {
    background: #6d7278;
}