/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #f59e0b;
    --accent-color: #10b981;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-image {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(245, 158, 11, 0.3));
}

.logo h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.header-stats {
    display: flex;
    gap: 2rem;
}

.stat {
    text-align: center;
}

    .stat-number {
        display: block;
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--primary-color);
        line-height: 1;
    }
    
    .stat-label {
        font-size: 0.875rem;
        color: var(--text-secondary);
        font-weight: 500;
    }

@media (max-width: 768px) {
    .stat-number {
        font-size: 1.125rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
}

/* Main Content */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 80px);
}

/* Navigation Controls */
.nav-controls {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.nav-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-sm);
}

.page-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 150px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0.33%;
}

.page-counter {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .page-counter {
        font-size: 0.75rem;
    }
}

/* Flipbook Viewer */
.flipbook-container {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: visible;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-x; /* Allow horizontal panning only, prevent vertical scrolling */
}

.flipbook {
    display: none;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
    touch-action: pan-x; /* Allow horizontal panning for page turning */
}

.flipbook .page {
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.flipbook .page canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* PDF Links Overlay */
.pdf-links-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1000 !important;
}

.pdf-link-hotspot {
    pointer-events: auto !important;
    background: rgba(0, 123, 255, 0.15);
    border: 2px solid rgba(0, 123, 255, 0.3);
    transition: all 0.2s ease;
    display: block;
    text-decoration: none;
}

.pdf-link-hotspot:hover {
    background: rgba(0, 123, 255, 0.3);
    border: 2px solid rgba(0, 123, 255, 0.5);
}

.pdf-link-hotspot:active {
    background: rgba(0, 255, 0, 0.4);
    border: 2px solid rgba(0, 255, 0, 0.6);
}

.flipbook-page {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
    -ms-interpolation-mode: bicubic;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.flipbook .even {
    background: linear-gradient(to left, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0) 10%);
}

.flipbook .odd {
    background: linear-gradient(to right, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0) 10%);
}

.pdf-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.pdf-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.pdf-error i {
    font-size: 3rem;
    color: var(--secondary-color);
}

.retry-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.retry-btn:hover {
    background: var(--primary-dark);
}


/* Quick Navigation */
.quick-nav {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.quick-nav h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

@media (max-width: 768px) {
    .quick-nav h3 {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }
}

.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
}

.nav-item {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--accent-color);
}

/* Floating Action Button - REMOVED */

/* Gesture Hint */
.gesture-hint {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
}

.gesture-hint.show {
    opacity: 1;
    visibility: visible;
}

.gesture-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gesture-content i {
    font-size: 1rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-animation {
    margin-bottom: 2rem;
}

.logo-icon {
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

.loading-logo {
    width: 5rem;
    height: 5rem;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(245, 158, 11, 0.3));
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulse {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.loading-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.loading-content p {
    font-size: 1.125rem;
    opacity: 0.9;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
        padding: 0.25rem 0;
    }
    
    .header-stats {
        gap: 0.75rem;
    }
    
    .logo h1 {
        font-size: 0.875rem;
    }
    
    .logo-image {
        width: 1.5rem;
        height: 1.5rem;
    }
    
    .loading-logo {
        width: 4rem;
        height: 4rem;
    }
    
    .nav-controls {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .nav-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .page-indicator {
        min-width: 120px;
    }
    
    .page-indicator {
        order: -1;
    }
    
    .flipbook-container {
        padding: 0.5rem;
        margin-bottom: 1rem;
        min-height: 70vh;
    }
    
    .nav-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 0.5rem;
    }
    
    .nav-item {
        font-size: 0.7rem;
    }
    
    .fab-container {
        bottom: 1rem;
        right: 1rem;
    }
    
    .fab {
        width: 48px;
        height: 48px;
        font-size: 1rem;
    }
    
    .fab-item {
        width: 40px;
        height: 40px;
        font-size: 0.875rem;
    }
    
    .loading-content h2 {
        font-size: 2rem;
    }
    
    .loading-content p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 1rem 0;
    }
    
    .nav-controls {
        padding: 1rem;
    }
    
    .pdf-viewer {
        height: 70vh;
        min-height: 450px;
    }
    
    .quick-nav {
        padding: 1.5rem;
    }
    
    .nav-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    }
}

/* Focus styles */
button:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
