/* GwizIT FlipBook Public Styles */

.gwizit-flipbook-wrapper {
    font-family: Arial, sans-serif;
    margin: 20px 0;
}

.gwizit-flipbook-container {
    text-align: center;
}

.gwizit-open-book-btn {
    padding: 12px 24px;
    font-size: 16px;
    cursor: pointer;
    background-color: #0073aa;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s;
    font-weight: 500;
}

.gwizit-open-book-btn:hover {
    background-color: #005177;
}

.gwizit-open-book-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Error message */
.gwizit-flipbook-error {
    color: #d63638;
    padding: 10px;
    background: #fcf0f1;
    border-left: 4px solid #d63638;
    margin: 15px 0;
}

/* Lightbox styles */
.gwizit-lightbox {
    display: none;
    position: fixed !important;
    z-index: 2147483647;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    inset: 0;
    isolation: isolate;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
}

.gwizit-lightbox.active {
    display: flex !important;
}

.gwizit-lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gwizit-close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    user-select: none;
    z-index: 2000;
    transition: color 0.3s;
}

.gwizit-close-btn:hover {
    color: #ccc;
}

/* Flipbook Container */
.gwizit-flipbook-view {
    perspective: 3000px;
    width: 0;
    height: 0;
    position: relative;
    transform-style: preserve-3d;
    z-index: 1;
}

.gwizit-book {
    position: relative;
    transform-style: preserve-3d;
    width: 0;
    height: 0;
    transition: transform 0.3s ease;
}

/* Page Styles */
.gwizit-page {
    position: absolute;
    top: 0;
    left: 0;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1);
    backface-visibility: hidden;
    background-color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Right side pages (default) */
.gwizit-page.right {
    transform: rotateY(0deg);
}

/* Left side pages (flipped) */
.gwizit-page.left {
    transform: rotateY(-180deg);
}

.gwizit-page-front,
.gwizit-page-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    overflow: hidden;
    background-color: white;
}

.gwizit-page-front {
    transform: rotateY(0deg);
    z-index: 2;
}

.gwizit-page-back {
    transform: rotateY(180deg);
    z-index: 1;
    background-color: white;
}

.gwizit-page-front canvas,
.gwizit-page-back canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Spine Shadows */
.gwizit-spine-shadow-front {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.15), transparent);
    pointer-events: none;
    z-index: 10;
}

.gwizit-spine-shadow-back {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(to left, rgba(0,0,0,0.15), transparent);
    pointer-events: none;
    z-index: 10;
}

/* Bottom bar wrapper — holds controls + optional download button */
.gwizit-bottom-bar {
    position: absolute;
    bottom: 20px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 2000;
}

.gwizit-bottom-bar.active {
    display: flex;
}

/* Controls */
.gwizit-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(0,0,0,0.6);
    padding: 12px 24px;
    border-radius: 30px;
}

.gwizit-controls button {
    padding: 10px 20px !important;
    font-size: 14px !important;
    cursor: pointer !important;
    background-color: #0073aa !important;
    color: white !important;
    border: none !important;
    border-radius: 5px !important;
    transition: background-color 0.3s, filter 0.3s !important;
    font-weight: 500 !important;
}

.gwizit-controls button:hover:not(:disabled) {
    background-color: #005177 !important;
}

.gwizit-controls button:disabled {
    background-color: #555 !important;
    cursor: not-allowed !important;
    opacity: 0.5 !important;
}

.gwizit-zoom-controls {
    display: flex;
    gap: 10px;
    margin-left: 20px;
    border-left: 1px solid rgba(255,255,255,0.3);
    padding-left: 20px;
}

.gwizit-zoom-controls button {
    width: 40px;
    height: 40px;
    padding: 0 !important;
    font-weight: bold;
    font-size: 24px;
    line-height: 1;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

/* Cursor styles for zooming */
.gwizit-flipbook-view.grab-cursor {
    cursor: grab;
}

.gwizit-flipbook-view.grabbing-cursor {
    cursor: grabbing;
}

.gwizit-page-indicator {
    color: white;
    font-size: 16px;
    min-width: 120px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    font-weight: 500;
}

/* Loader — Spinner (default) */
.gwizit-book-loader.gwizit-loader-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #0073aa;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: gwizit-spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -30px;
    margin-left: -30px;
    z-index: 3000;
    display: none;
}

.gwizit-book-loader.gwizit-loader-spinner.active {
    display: block;
}

/* Loader — Both (spinner + progress bar) */
.gwizit-book-loader.gwizit-loader-both {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
    display: none;
    text-align: center;
}

.gwizit-book-loader.gwizit-loader-both.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gwizit-both-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #0073aa;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: gwizit-spin 1s linear infinite;
    margin-bottom: 16px;
}

/* Loader — fallback for cached HTML missing the subclass */
.gwizit-book-loader:not(.gwizit-loader-spinner):not(.gwizit-loader-progress):not(.gwizit-loader-both) {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #0073aa;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: gwizit-spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -30px;
    margin-left: -30px;
    z-index: 3000;
    display: none;
}

.gwizit-book-loader:not(.gwizit-loader-spinner):not(.gwizit-loader-progress):not(.gwizit-loader-both).active {
    display: block;
}

/* Loader — Progress bar */
.gwizit-book-loader.gwizit-loader-progress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
    display: none;
    text-align: center;
}

.gwizit-book-loader.gwizit-loader-progress.active {
    display: block;
}

.gwizit-progress-wrapper {
    width: 260px;
}

.gwizit-progress-bar {
    width: 100%;
    height: 14px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 7px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.gwizit-progress-fill {
    height: 100%;
    width: 0%;
    background: #0073aa;
    border-radius: 7px;
    transition: width 0.25s ease;
}

.gwizit-progress-text {
    display: block;
    margin-top: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
}

@keyframes gwizit-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Download Button Bar */
.gwizit-download-bar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gwizit-download-btn {
    padding: 10px 24px !important;
    font-size: 14px !important;
    cursor: pointer !important;
    background-color: #0073aa !important;
    color: white !important;
    border: none !important;
    border-radius: 5px !important;
    transition: background-color 0.3s, filter 0.3s !important;
    font-weight: 500 !important;
    text-decoration: none !important;
}

.gwizit-download-btn:hover {
    filter: brightness(0.85) !important;
}

/* ================================================================ */
/*  StPageFlip Mode                                                  */
/* ================================================================ */

/* Container styles when using StPageFlip */
.gwizit-stpageflip-book {
    position: relative !important;
    transform-style: flat !important;
    /* Let StPageFlip handle all transforms */
}

.gwizit-stpageflip-page {
    background-color: #fff;
}

.gwizit-stpageflip-page canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Override the flipbook-view perspective when using StPageFlip —
   StPageFlip uses its own canvas and does not need CSS perspective. */
.gwizit-stpageflip-book .stf__parent {
    margin: 0 auto;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .gwizit-close-btn {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
    
    .gwizit-controls {
        bottom: 15px;
        padding: 8px 16px;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .gwizit-controls button {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .gwizit-zoom-controls {
        margin-left: 10px;
        padding-left: 10px;
    }
    
    .gwizit-page-indicator {
        font-size: 14px;
        min-width: 100px;
    }
}
