/* ========================================
   Flavor Flipbook - Styles v1.1.0
   ======================================== */

/* Container */
.ffb-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

.ffb-container.ffb-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999;
    border-radius: 0;
    background: #1a1a2e !important;
}

/* Loading */
.ffb-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
    color: #666;
    font-size: 14px;
    background: inherit;
}

.ffb-loading.ffb-hidden {
    display: none;
}

.ffb-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #ddd;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: ffb-spin 0.8s linear infinite;
}

@keyframes ffb-spin {
    to { transform: rotate(360deg); }
}

/* Book Wrapper */
.ffb-book-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    perspective: 2000px;
    min-height: 0;
}

.ffb-container.ffb-fullscreen .ffb-book-wrapper {
    padding: 30px;
}

/* Book */
.ffb-book {
    display: flex;
    position: relative;
    transform-style: preserve-3d;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 6px 30px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
    border-radius: 2px;
}

/* Pages */
.ffb-page {
    position: relative;
    background: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ffb-page-left {
    border-right: 1px solid #e0e0e0;
    box-shadow: inset -8px 0 12px -8px rgba(0,0,0,0.08);
    border-radius: 2px 0 0 2px;
}

.ffb-page-right {
    box-shadow: inset 8px 0 12px -8px rgba(0,0,0,0.08);
    border-radius: 0 2px 2px 0;
}

.ffb-page.ffb-empty {
    background: #fafafa;
}

.ffb-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* Single page mode (mobile) */
.ffb-container.ffb-single-page .ffb-book {
    justify-content: center;
}

.ffb-container.ffb-single-page .ffb-page-left {
    display: none;
}

.ffb-container.ffb-single-page .ffb-page-right {
    border-radius: 2px;
    box-shadow: none;
}

/* Click zones for navigation */
.ffb-page::after {
    content: '';
    position: absolute;
    top: 0;
    width: 40%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.ffb-page-left::after {
    left: 0;
}

.ffb-page-right::after {
    right: 0;
}

/* Flip animation overlay */
.ffb-flip-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    pointer-events: none;
    perspective: 2000px;
}

.ffb-flip-page {
    position: absolute;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1.000);
}

.ffb-flip-front,
.ffb-flip-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ffb-flip-back {
    transform: rotateY(180deg);
}

.ffb-flip-front canvas,
.ffb-flip-back canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Toolbar */
.ffb-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    flex-shrink: 0;
    border-radius: 0 0 8px 8px;
}

.ffb-container.ffb-fullscreen .ffb-toolbar {
    border-radius: 0;
}

.ffb-btn {
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s, transform 0.1s;
    padding: 0;
    line-height: 1;
}

.ffb-btn:hover {
    background: rgba(255,255,255,0.25);
}

.ffb-btn:active {
    transform: scale(0.93);
}

.ffb-btn:disabled {
    opacity: 0.3;
    cursor: default;
    transform: none;
}

.ffb-btn:disabled:hover {
    background: rgba(255,255,255,0.12);
}

.ffb-page-info {
    font-size: 13px;
    min-width: 70px;
    text-align: center;
    color: rgba(255,255,255,0.85);
    font-variant-numeric: tabular-nums;
}

.ffb-toolbar-sep {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    margin: 0 6px;
}

/* Swipe hint on touch devices */
.ffb-swipe-hint {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.65);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 6;
    animation: ffb-fadeout 3s forwards;
    pointer-events: none;
}

@keyframes ffb-fadeout {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Responsive */
@media (max-width: 768px) {
    .ffb-book-wrapper {
        padding: 10px;
    }

    .ffb-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .ffb-toolbar {
        gap: 4px;
        padding: 8px 10px;
    }

    .ffb-page-info {
        font-size: 12px;
        min-width: 55px;
    }

    .ffb-toolbar-sep {
        margin: 0 3px;
    }
}

@media print {
    .ffb-toolbar { display: none !important; }
}
