.epfa-flipbook-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.epfa-flipbook-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.epfa-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    min-width: 200px;
    text-align: center;
    color: #333;
}

.epfa-loading::before {
    content: "";
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: epfa-spin 1s linear infinite;
}

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

.epfa-flipbook-container {
    width: 100%;
    height: 100%;
    min-height: 400px;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.epfa-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50px;
    color: #fff;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.epfa-flipbook-wrapper:hover .epfa-controls,
.epfa-flipbook-wrapper.epfa-touch .epfa-controls,
.epfa-flipbook-wrapper.epfa-controls-visible .epfa-controls {
    opacity: 1;
    visibility: visible;
}

.epfa-controls button,
.epfa-controls .epfa-download {
    background: transparent;
    border: none;
    color: #fff;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.1s ease;
    text-decoration: none;
    line-height: 1;
}

.epfa-controls button:hover,
.epfa-controls .epfa-download:hover {
    background: rgba(255, 255, 255, 0.2);
}

.epfa-controls button:active,
.epfa-controls .epfa-download:active {
    transform: scale(0.9);
}

.epfa-controls .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.epfa-page-info {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
    font-weight: 500;
    margin: 0 10px;
    white-space: nowrap;
    user-select: none;
}

/* StPageFlip specific styles */
.stPageFlip {
    background-color: transparent !important;
}

.epfa-page {
    background-color: #fff;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.epfa-page-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.epfa-page-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.epfa-page-img.epfa-loaded {
    opacity: 1;
}

.epfa-page-spinner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #888;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.2s ease-out;
}

.epfa-page-spinner::before {
    content: "";
    width: 28px;
    height: 28px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: epfa-spin 0.8s linear infinite;
}

canvas {
    display: block;
    max-width: 100%;
    height: auto !important;
}

/* Fullscreen handling */
.epfa-flipbook-container:fullscreen {
    background: #222;
    width: 100vw;
    height: 100vh;
}

.epfa-flipbook-container:-webkit-full-screen {
    background: #222;
    width: 100vw;
    height: 100vh;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .epfa-controls {
        bottom: 10px;
        gap: 4px;
        padding: 4px 8px;
    }
    
    .epfa-controls button,
    .epfa-controls .epfa-download {
        padding: 6px;
    }
    
    .epfa-page-info {
        margin: 0 5px;
        font-size: 12px;
    }
}

/* PDF link overlay styles */
.epfa-page-content {
    position: relative;
}

.epfa-links-overlay {
    z-index: 5;
}

.epfa-pdf-link {
    background-color: rgba(34, 113, 177, 0); /* Invisible initially */
    border-radius: 2px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.epfa-pdf-link:hover {
    background-color: rgba(34, 113, 177, 0.15); /* Light blue highlight on hover */
    box-shadow: 0 0 4px rgba(34, 113, 177, 0.4);
}

/* Frontend Demo Mode & Upsell */
.epfa-flipbook-wrapper.epfa-demo-mode {
    padding-bottom: 40px; /* Leave space for the subtle footer banner */
}

.epfa-frontend-upsell {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35px;
    background: rgba(245, 245, 245, 0.9);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99;
}

.epfa-frontend-upsell p {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 11px;
    color: #666;
    letter-spacing: 0.3px;
}

.epfa-frontend-upsell p a {
    color: #2271b1;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.epfa-frontend-upsell p a:hover {
    color: #135e96;
    text-decoration: underline;
}
