/* Flipbook Frontend CSS */
.afb-container {
    position: relative;
    margin: 20px auto;
    width: 90%;
    max-width: 1000px;
    aspect-ratio: 4 / 3;
    max-height: 90vh;
}

.afb-container.single-page-view {
    aspect-ratio: 2 / 3;
    max-width: 500px;
}

.afb-cover {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.afb-cover img {
    width: 50%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.afb-container.single-page-view .afb-cover img {
    width: 100%;
}

.afb-begin-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 25px;
    font-size: 16px;
    cursor: pointer;
    background-color: #0073aa;
    color: white;
    border: none;
    border-radius: 5px;
    z-index: 10;
}

.afb-flipbook-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.afb-flipbook {
    width: 100%;
    height: 100%;
}

.afb-flipbook .turn-page {
    background-color: #fff;
    overflow: hidden;
    position: relative;
}

/* This universal rule now applies to ALL images, ensuring none are cut off. */
.afb-flipbook .turn-page img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.afb-flipbook .hard {
    background: #f7f7ff !important;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
}

/* === CONFLICTING RULE REMOVED === */
/* The old ".afb-flipbook .hard img" rule was here and has been deleted to fix the bug. */

.afb-flipbook .page-wrapper {
    -webkit-perspective: 2000px;
    -moz-perspective: 2000px;
    -ms-perspective: 2000px;
    -o-perspective: 2000px;
    perspective: 2000px;
}

.afb-arrows {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 20;
}

.afb-prev-btn,
.afb-next-btn {
    pointer-events: all;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 10px;
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.afb-prev-btn:hover,
.afb-next-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.afb-prev-btn {
    margin-left: -25px;
}

.afb-next-btn {
    margin-right: -25px;
}

@media (max-width: 768px) {
    .afb-prev-btn {
        margin-left: 5px;
    }
    .afb-next-btn {
        margin-right: 5px;
    }
}

/* Styles for the "Back to Cover" feature */
.afb-back-cover-inside {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f0f0f0 !important;
}

.afb-back-to-cover-content {
    text-align: center;
    padding: 30px;
    border: 2px solid #cccccc;
    background-color: transparent;
    border-radius: 8px;
    max-width: 80%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.afb-back-to-cover-btn {
    background-color: #0073aa;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1em;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.afb-back-to-cover-btn:hover {
    background-color: #005a87;
}