/**
 * Flipbook ARWeb - Styles CSS Minimaliste
 * Design épuré sans ombres, inspiré d'Elementor
 */

/* Variables CSS - Compatible avec les couleurs Elementor */
:root {
    --arweb-primary: #92003B;
    --arweb-secondary: #54595F;
    --arweb-text: #333333;
    --arweb-text-light: #7A7A7A;
    --arweb-accent: #61CE70;
    --arweb-border: #E0E0E0;
    --arweb-bg: #FFFFFF;
    --arweb-bg-light: #F9F9F9;
}

/* Conteneur principal - Minimaliste */
.flipbook-arweb-wrapper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0;
    background: transparent;
}

/* Conteneur du flipbook */
.flipbook-arweb-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    position: relative;
    background: var(--arweb-bg-light);
    border: 1px solid var(--arweb-border);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    box-sizing: border-box;
}

.flipbook-arweb-container.zoomed {
    cursor: grab;
    /* Désactiver le centrage flex quand zoomé pour permettre le scroll complet */
    align-items: flex-start;
    justify-content: flex-start;
}

.flipbook-arweb-container.zoomed .flipbook-zoom-wrapper {
    /* Centrage via margin auto : scrollable dans toutes les directions */
    margin: auto;
}

.flipbook-arweb-container.zoomed:active {
    cursor: grabbing;
}

/* Wrapper pour le zoom */
.flipbook-zoom-wrapper {
    display: inline-block;
    position: relative;
    margin: 0 auto;
}

/* Flipbook - Sans ombres */
.flipbook {
    margin: 0 auto;
}

.flipbook .page {
    background-color: var(--arweb-bg);
    background-size: 100% 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--arweb-border);
}

.flipbook .page canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Couverture rigide - Minimaliste */
.flipbook .page.hard-cover {
    background: var(--arweb-primary);
    border: none;
}

/* Animation de chargement */
.flipbook-arweb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--arweb-text-light);
}

.flipbook-arweb-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--arweb-border);
    border-top: 3px solid var(--arweb-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.flipbook-arweb-loading p {
    font-size: 14px;
    font-weight: 400;
    color: var(--arweb-text-light);
}

/* Message d'erreur */
.flipbook-arweb-error {
    text-align: center;
    padding: 30px;
    color: #d32f2f;
    font-size: 14px;
    background-color: #ffebee;
    border: 1px solid #ef5350;
}

/* Contrôles - Design Elementor */
.flipbook-arweb-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--arweb-bg);
    border: 1px solid var(--arweb-border);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.flipbook-arweb-controls.bottom {
    margin-bottom: 0;
    margin-top: 20px;
}

.flipbook-arweb-controls.top {
    margin-top: 0;
    margin-bottom: 20px;
}

/* Boutons - Style Elementor minimaliste */
.flipbook-arweb-btn {
    padding: 8px 14px;
    background: var(--arweb-bg);
    border: 1px solid var(--arweb-border);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 14px;
    color: var(--arweb-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    font-family: inherit;
}

.flipbook-arweb-btn:hover {
    background: var(--arweb-primary);
    color: white;
    border-color: var(--arweb-primary);
}

.flipbook-arweb-btn:active {
    transform: scale(0.98);
}

.flipbook-arweb-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.flipbook-arweb-btn span {
    font-size: 16px;
}

/* Information de page - Clean */
.flipbook-arweb-page-info {
    padding: 8px 16px;
    background-color: transparent;
    font-weight: 500;
    color: var(--arweb-text);
    font-size: 14px;
    min-width: 70px;
    text-align: center;
}

.flipbook-arweb-page-info .current-page {
    color: var(--arweb-primary);
    font-weight: 600;
}

/* Pas d'effet d'ombre sur les pages en transition */
.flipbook .turn-page {
    box-shadow: none;
}

/* Style minimal pour les pages */
.flipbook .page:nth-child(even) {
    background-color: var(--arweb-bg);
}

.flipbook .page:nth-child(odd) {
    background-color: var(--arweb-bg);
}

/* Mode plein écran */
.flipbook-arweb-wrapper:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    padding: 10px !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--arweb-bg-light);
}

.flipbook-arweb-wrapper:-moz-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    padding: 10px !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--arweb-bg-light);
}

.flipbook-arweb-wrapper:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    padding: 10px !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--arweb-bg-light);
}

/* Contrôles en plein écran */
.flipbook-arweb-wrapper:-webkit-full-screen .flipbook-arweb-controls,
.flipbook-arweb-wrapper:-moz-full-screen .flipbook-arweb-controls,
.flipbook-arweb-wrapper:fullscreen .flipbook-arweb-controls {
    flex-shrink: 0;
}

/* Container en plein écran doit prendre toute la hauteur disponible */
.flipbook-arweb-wrapper:-webkit-full-screen .flipbook-arweb-container,
.flipbook-arweb-wrapper:-moz-full-screen .flipbook-arweb-container,
.flipbook-arweb-wrapper:fullscreen .flipbook-arweb-container {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Le flipbook lui-même en plein écran */
.flipbook-arweb-wrapper:-webkit-full-screen .flipbook,
.flipbook-arweb-wrapper:-moz-full-screen .flipbook,
.flipbook-arweb-wrapper:fullscreen .flipbook {
    margin: 0 auto !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .flipbook-arweb-wrapper {
        padding: 0;
        margin: 20px auto;
    }

    .flipbook-arweb-controls {
        padding: 10px;
        gap: 6px;
    }

    .flipbook-arweb-btn {
        padding: 6px 10px;
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }

    .flipbook-arweb-btn span {
        font-size: 14px;
    }

    .flipbook-arweb-page-info {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 60px;
    }

    .flipbook {
        margin: 0 auto;
    }
}

@media (max-width: 480px) {
    .flipbook-arweb-controls {
        gap: 4px;
        padding: 8px;
    }

    .flipbook-arweb-btn {
        padding: 5px 8px;
        min-width: 34px;
        height: 34px;
    }

    .flipbook-arweb-page-info {
        padding: 5px 10px;
        font-size: 12px;
    }
}

/* Animation de transition de page - Minimaliste */
.flipbook .turn-page-wrapper {
    perspective: 2000px;
}

.flipbook .turn-page {
    transform-style: preserve-3d;
}

/* Pas d'effet de brillance */
.flipbook .page::before {
    display: none;
}

/* Style pour le zoom - Scrollbar minimaliste */
.flipbook-arweb-container {
    overflow: visible;
    transition: cursor 0.2s ease;
}

.flipbook-arweb-container.zoomed {
    overflow: auto;
}

.flipbook-arweb-container.grabbing {
    cursor: grabbing !important;
}

.flipbook-arweb-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.flipbook-arweb-container::-webkit-scrollbar-track {
    background: var(--arweb-bg-light);
}

.flipbook-arweb-container::-webkit-scrollbar-thumb {
    background: var(--arweb-border);
    border-radius: 4px;
}

.flipbook-arweb-container::-webkit-scrollbar-thumb:hover {
    background: var(--arweb-text-light);
}

/* Accessibilité */
.flipbook-arweb-btn:focus {
    outline: 2px solid var(--arweb-primary);
    outline-offset: 2px;
}

/* Impression */
@media print {
    .flipbook-arweb-controls {
        display: none;
    }

    .flipbook-arweb-wrapper {
        padding: 0;
        margin: 0;
        border: none;
    }

    .flipbook-arweb-container {
        border: none;
    }
}



/* ===== Edge hover zones & peel indicators ===== */
.flipbook-edge-zone {
    position: absolute;
    top: 0;
    width: 60px;
    height: 100%;
    z-index: 10;
    cursor: pointer;
}
.flipbook-edge-left { left: 0; }
.flipbook-edge-right { right: 0; }

.flipbook-peel {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 11;
}
.flipbook-peel span {
    font-size: 24px;
    color: var(--arweb-primary);
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.flipbook-peel-left { left: 5px; }
.flipbook-peel-right { right: 5px; }
.flipbook-peel.visible { opacity: 1; }
.flipbook-peel-left.visible { animation: peelBounceLeft 0.4s ease; }
.flipbook-peel-right.visible { animation: peelBounceRight 0.4s ease; }

@keyframes peelBounceLeft {
    0% { transform: translateY(-50%) translateX(-10px); opacity: 0; }
    60% { transform: translateY(-50%) translateX(3px); opacity: 1; }
    100% { transform: translateY(-50%) translateX(0); opacity: 1; }
}
@keyframes peelBounceRight {
    0% { transform: translateY(-50%) translateX(10px); opacity: 0; }
    60% { transform: translateY(-50%) translateX(-3px); opacity: 1; }
    100% { transform: translateY(-50%) translateX(0); opacity: 1; }
}

/* Drag-to-turn cursor */
.flipbook-arweb-container:not(.zoomed) .flipbook { cursor: grab; }
.flipbook-arweb-container:not(.zoomed) .flipbook:active { cursor: grabbing; }

/* Hide edge zones when zoomed */
.flipbook-arweb-container.zoomed .flipbook-edge-zone,
.flipbook-arweb-container.zoomed .flipbook-peel { display: none; }


/* ===================== */
/* Barre de progression  */
/* ===================== */

.flipbook-download-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

.flipbook-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--arweb-border, #E0E0E0);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.flipbook-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--arweb-primary, #92003B);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.flipbook-progress-text {
    font-size: 13px;
    color: var(--arweb-text-light, #7A7A7A);
    margin: 0;
    text-align: center;
}

.flipbook-arweb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}