/* Custom CSS for the flipbook plugin */
:root {
    --flipbook-bg: #333;
    --flipbook-btn-bg: #444;
    --flipbook-btn-hover: #666;
    --flipbook-text: #fff;
    --flipbook-accent: #0073aa;
}

.custom-flipbook-container {
    position: relative;
    margin: 20px auto;
    background-color: var(--flipbook-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Loading Spinner */
.flipbook-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--flipbook-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* Viewport and Canvas */
.flipbook-viewport {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: auto;
    background: radial-gradient(circle, #444 0%, #222 100%);
}

.flipbook-canvas-container {
    display: flex;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    transition: transform 0.3s ease;
}

.flipbook-canvas-container canvas {
    max-height: 80vh;
    max-width: 45%;
    background-color: white;
    height: auto;
}

/* Controls */
.pdf-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #1a1a1a;
    color: var(--flipbook-text);
    z-index: 5;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.pdf-controls button,
.pdf-controls .download-pdf {
    background: var(--flipbook-btn-bg);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.pdf-controls button:hover,
.pdf-controls .download-pdf:hover {
    background: var(--flipbook-btn-hover);
    transform: translateY(-2px);
}

.pdf-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

/* Table of Contents (TOC) */
.flipbook-toc-container {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 56px;
    width: 280px;
    background: #222;
    z-index: 100;
    box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #444;
}

.flipbook-toc-header {
    padding: 15px;
    background: #111;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

.flipbook-toc-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--flipbook-accent);
}

.flipbook-toc-header .close-toc {
    background: none !important;
    border: none !important;
    color: #888 !important;
    cursor: pointer;
    padding: 0 !important;
}

.flipbook-toc-header .close-toc:hover {
    color: white !important;
}

.flipbook-toc-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.toc-item {
    display: block;
    padding: 10px 20px;
    color: #ccc;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #2a2a2a;
    transition: all 0.2s ease;
    cursor: pointer;
}

.toc-item:hover {
    background: #333;
    color: var(--flipbook-accent);
    padding-left: 25px;
}

.toc-loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Thumbnails Container */
.flipbook-thumbnails-container {
    position: absolute;
    bottom: 56px; /* Just above controls */
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    padding: 15px;
    z-index: 4;
    border-top: 1px solid #444;
    transition: all 0.3s ease;
}

.flipbook-thumbnails-content {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--flipbook-accent) #222;
}

.flipbook-thumbnails-content::-webkit-scrollbar {
    height: 6px;
}

.flipbook-thumbnails-content::-webkit-scrollbar-thumb {
    background: var(--flipbook-accent);
    border-radius: 3px;
}

.thumb-page {
    flex: 0 0 auto;
    cursor: pointer;
    transition: transform 0.2s ease;
    text-align: center;
}

.thumb-page canvas {
    display: block;
    height: 120px;
    width: auto;
    background: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    border: 2px solid transparent;
}

.thumb-page:hover {
    transform: translateY(-5px);
}

.thumb-page:hover canvas {
    border-color: var(--flipbook-accent);
}

.thumb-page span {
    display: block;
    font-size: 11px;
    color: #ccc;
    margin-top: 5px;
}

.thumb-page.active canvas {
    border-color: var(--flipbook-accent);
    box-shadow: 0 0 15px var(--flipbook-accent);
}

/* Icons adjustment */
.pdf-controls .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Fullscreen */
.custom-flipbook-container:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0;
}

.custom-flipbook-container:fullscreen .flipbook-viewport canvas {
    max-height: 90vh;
}

/* Error Message */
.custom-flipbook-error {
    color: #ff5252;
    padding: 20px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .flipbook-canvas-container {
        flex-direction: column;
    }
    .flipbook-canvas-container canvas {
        max-width: 90%;
    }
    .pdf-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
}