/* ============================================
   PDF Flipbook - Responsive Styles
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* ============================================
   Loading Screen
   ============================================ */

#loading {
    text-align: center;
    color: #fff;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

#load-progress {
    font-size: 14px;
    opacity: 0.7;
    margin-top: 10px;
}

/* ============================================
   Main App Container
   ============================================ */

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    gap: 20px;
}

/* ============================================
   Book Container - Responsive Sizing
   ============================================ */

.book-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    min-height: 0; /* Important for flex shrinking */
    transition: transform 0.5s ease-out;
}

/* Bigger cover when only front cover is visible; zooms out when opening to spread */
.book-container.cover-zoomed {
    transform: scale(1.4);
}

/* Hide flipbook during init so user never sees wrong page */
.c-flipbook.initializing {
    visibility: hidden !important;
}

/* Kill ALL transitions during init */
.c-flipbook.no-transition,
.c-flipbook.no-transition * {
    transition: none !important;
    animation: none !important;
}

/* Flipbook overrides */
.c-flipbook {
    perspective: 2000px;
    position: relative;
}

.c-flipbook__page {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.c-flipbook__page canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Page styling for left/right sides */
.c-flipbook__page:nth-child(odd) {
    border-right: 1px solid #e0e0e0;
}

.c-flipbook__page:nth-child(even) {
    border-left: 1px solid #e0e0e0;
}

/* Cover pages */
.c-flipbook__page.cover {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
}

.c-flipbook__page.cover canvas {
    border-radius: 2px;
}

/* ============================================
   Controls
   ============================================ */

.controls {
    display: flex;
    gap: 20px;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 15px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.controls button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.controls button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.controls button:active:not(:disabled) {
    transform: translateY(0);
}

.controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.controls button svg {
    flex-shrink: 0;
}

#page-info {
    color: #fff;
    min-width: 100px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    #app {
        padding: 15px;
        gap: 15px;
    }
}

/* Mobile landscape / small tablet */
@media (max-width: 768px) {
    #app {
        padding: 10px;
        gap: 10px;
    }
    
    .controls {
        padding: 10px 16px;
        gap: 12px;
    }
    
    .controls button {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    #page-info {
        min-width: 80px;
        font-size: 13px;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .controls button span {
        display: none;
    }
    
    .controls button {
        padding: 10px 14px;
    }
    
    #page-info {
        min-width: 60px;
        font-size: 12px;
    }
}

/* Very small screens - single page mode hint */
@media (max-height: 500px) {
    #app {
        padding: 5px;
        gap: 5px;
    }
    
    .controls {
        padding: 6px 12px;
        border-radius: 25px;
    }
    
    .controls button {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ============================================
   Error State
   ============================================ */

.error {
    color: #ff6b6b;
    text-align: center;
    padding: 40px;
}

.error p {
    margin: 10px 0;
}

.error .hint {
    font-size: 12px;
    opacity: 0.7;
}
