/* --- FlipBook Magic Global Styles & Variables (Cosmic Glow Theme) --- */
:root {
    --fbm-primary-bg: #12121c; 
    --fbm-secondary-bg: #1f1f2e;
    --fbm-accent-primary: #00f2ff;
    --fbm-accent-secondary: #ff00e0;
    --fbm-accent-gradient: linear-gradient(135deg, var(--fbm-accent-primary) 0%, var(--fbm-accent-secondary) 100%);
    --fbm-text-color: #e0e0ff;
    --fbm-text-on-accent: #12121c;
    --fbm-border-color: #3a3a52;
    --fbm-button-hover-glow: 0 0 15px var(--fbm-accent-primary), 0 0 5px var(--fbm-accent-secondary);
    --fbm-shadow-color: rgba(0, 242, 255, 0.2);
    --fbm-font-family: 'Orbitron', 'Segoe UI', sans-serif;
}

/* Import Orbitron font for a more futuristic look */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700&display=swap');

.fbm-outer-container {
    width: 100%;
    height: auto;
    min-height: 85vh;
    max-height: 95vh;
    margin: 15px auto;
    background-color: var(--fbm-primary-bg);
    color: var(--fbm-text-color);
    font-family: var(--fbm-font-family);
    border-radius: 10px;
    box-shadow: 0 0 30px var(--fbm-shadow-color), 0 0 15px var(--fbm-accent-secondary);
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    position: relative;
}

/* --- Loader --- */
.fbm-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(18,18,28,0.95) 0%, rgba(31,31,46,0.98) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    color: var(--fbm-text-color);
    font-size: 1.3em;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
    opacity: 1;
    visibility: visible;
    text-shadow: 0 0 5px var(--fbm-accent-primary);
}

.fbm-loader.fbm-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.fbm-loader-text {
    margin-bottom: 15px;
    font-weight: 700;
    letter-spacing: 1px;
}

.fbm-loader-subtext {
    font-size: 0.9em;
    color: var(--fbm-accent-primary);
    opacity: 0.8;
    padding: 0 20px;
    text-align: center;
}

/* --- Flipbook Area --- */
.fbm-flipbook-container {
    flex-grow: 1; 
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    background-color: transparent;
    padding: 20px; 
    box-sizing: border-box;
}

.fbm-flipbook {
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.fbm-flipbook .page {
    background-color: #f0f0f8;
    color: #222;
    box-shadow: 
        0 0 10px rgba(0,0,0,0.1),
        inset 0 0 5px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 3px;
}

.fbm-flipbook .fbm-page-inner-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fbm-flipbook .page canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.fbm-flipbook .shadow { 
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}


/* --- Controls Bar --- */
.fbm-controls-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: var(--fbm-secondary-bg);
    border-top: 1px solid var(--fbm-border-color);
    box-shadow: 0 -5px 15px -5px rgba(0,0,0,0.2);
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0; 
}

.fbm-controls-bar button {
    background: var(--fbm-accent-gradient);
    color: var(--fbm-text-on-accent);
    border: none;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-width: 48px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fbm-controls-bar button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3), var(--fbm-button-hover-glow);
}

.fbm-controls-bar button:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
    box-shadow: none;
}

.fbm-page-input-container {
    display: flex;
    align-items: center;
    color: var(--fbm-text-color);
    margin: 0 12px;
    font-weight: 500;
}

.fbm-page-current {
    width: 60px;
    padding: 9px 10px;
    text-align: center;
    border: 1px solid var(--fbm-border-color);
    background-color: var(--fbm-primary-bg);
    color: var(--fbm-accent-primary);
    border-radius: 4px;
    margin-right: 6px;
    font-weight: bold;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
    -moz-appearance: textfield;
}
.fbm-page-current::-webkit-outer-spin-button,
.fbm-page-current::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.fbm-page-current:focus {
    outline: none;
    border-color: var(--fbm-accent-primary);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3), 0 0 5px var(--fbm-accent-primary);
}

.fbm-page-separator {
    margin: 0 6px;
    opacity: 0.7;
}

/* --- Thumbnails Strip --- */
.fbm-thumbnails-strip-container {
    background-color: var(--fbm-secondary-bg);
    padding: 12px 0;
    border-top: 1px solid var(--fbm-border-color);
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    max-height: 145px;
    min-height: 100px;
    flex-shrink: 0; 
    box-sizing: border-box;
    box-shadow: inset 0 5px 10px -5px rgba(0,0,0,0.15);
}

.fbm-thumbnails-strip {
    display: inline-flex;
    align-items: center;
    padding: 0 15px; 
    gap: 15px;
}

.fbm-thumbnail-item {
    display: inline-block;
    width: 85px; 
    height: 120px; 
    border: 2px solid var(--fbm-border-color);
    border-radius: 6px; 
    cursor: pointer;
    overflow: hidden;
    position: relative;
    background-color: var(--fbm-primary-bg); 
    transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
    vertical-align: middle; 
    box-shadow: 0 3px 7px rgba(0,0,0,0.25);
}

.fbm-thumbnail-item:hover {
    border-color: var(--fbm-accent-primary);
    transform: translateY(-3px) scale(1.03); 
    box-shadow: 0 5px 12px var(--fbm-shadow-color);
}

.fbm-thumbnail-item.fbm-active-thumbnail {
    border-color: var(--fbm-accent-secondary);
    box-shadow: 0 0 15px var(--fbm-accent-secondary), 0 0 5px var(--fbm-accent-primary);
    transform: scale(1.08); 
}

.fbm-thumbnail-item canvas,
.fbm-thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px; 
}

.fbm-thumbnail-cover {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    text-align: center;
    padding: 8px 5px;
    font-size: 0.75em;
    color: var(--fbm-text-color); 
    height: 100%;
}

.fbm-thumbnail-cover img {
    max-height: 50%; 
    object-fit: contain;
    margin-bottom: 5px;
    border-radius: 3px;
}

.fbm-thumbnail-cover .fbm-cover-title {
    font-weight: 700; 
    font-size: 0.9em;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;  
    width: 100%;
    color: var(--fbm-accent-primary); 
    line-height: 1.2;
}

.fbm-thumbnail-cover .fbm-cover-author {
    font-size: 0.8em;
    color: var(--fbm-accent-secondary);
    opacity: 0.9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

/* --- Fullscreen Mode --- */
.fbm-outer-container.fbm-fullscreen-active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; 
    max-width: none;
    margin: 0;
    border-radius: 0;
    z-index: 99999;
    max-height: 100vh; 
    min-height: 100vh; 
}
body.fbm-body-fullscreen-active {
    overflow: hidden;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .fbm-outer-container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        max-height: 100vh;
    }
    .fbm-controls-bar {
        padding: 10px;
        gap: 8px;
    }
    .fbm-controls-bar button {
        padding: 8px 12px;
        font-size: 0.9em;
    }
    .fbm-page-current {
        width: 50px;
        padding: 8px;
    }
    .fbm-thumbnails-strip-container {
        max-height: 120px;
        min-height: 80px;
        padding: 10px 0;
    }
    .fbm-thumbnail-item {
        width: 70px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .fbm-controls-bar {
        font-size: 0.9em;
        gap: 6px; 
    }
     .fbm-controls-bar button {
        min-width: 40px;
        font-size: 0.85em;
        padding: 7px 10px;
    }
    .fbm-page-input-container {
        margin: 0 6px;
    }
    .fbm-thumbnails-strip-container {
        max-height: 110px;
        min-height: 70px;
    }
    .fbm-thumbnail-item {
        width: 60px;
        height: 85px;
    }
    .fbm-thumbnail-cover .fbm-cover-title {
        -webkit-line-clamp: 1;
    }
}

.fbm-outer-container *, .fbm-outer-container *::before, .fbm-outer-container *::after {
    box-sizing: border-box;
}