:root {
    --primary-gold: rgb(201, 149, 40);
    --primary-dark: rgb(161, 119, 32);
    --primary-light: rgb(241, 199, 90);
    --dark-bg: #0a0a0a;
    --card-bg: #1a1a1a;
    --text-light: #f8f9fa;
    --shadow-gold: 0 25px 50px -12px rgba(201, 149, 40, 0.3);
    --glow-gold: 0 0 30px rgba(201, 149, 40, 0.4);
}

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

.main-container {
    min-height: 100vh;
    position: relative;
    display: flex;
}

/* Left Panel Styles */
.left-panel {
    width: 280px;
    background: #ffffff; /* White background to match pages */
    border-right: 2px solid rgba(201, 149, 40, 0.3);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 80px; /* Start below header */
    height: calc(100vh - 80px); /* Adjust height to account for header */
    z-index: 100;
    overflow: hidden;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.panel-header {
    padding: 1.5rem 1rem;
    border-bottom: 2px solid rgba(201, 149, 40, 0.3);
    background: #ffffff;
}

.panel-header h3 {
    color: #000000;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.zoom-btn {
    background: linear-gradient(135deg, 
                var(--primary-gold) 0%, 
                var(--primary-dark) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    width: 24px;
    height: 24px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(201, 149, 40, 0.3);
}

.zoom-btn:hover {
    background: linear-gradient(135deg, 
        var(--primary-light) 0%, 
        var(--primary-gold) 100%);
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(201, 149, 40, 0.4);
}

.zoom-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(201, 149, 40, 0.3);
}

#zoom-level {
    color: var(--primary-dark);
    font-size: 10px;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
    background: rgba(201, 149, 40, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 10px;
}

.thumbnails-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.thumbnail {
    width: 100%;
    height: 120px;
    background: #ffffff;
    border: 2px solid rgba(201, 149, 40, 0.3);
    border-radius: 8px;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.thumbnail:hover {
    border-color: var(--primary-gold);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 149, 40, 0.4);
}

.thumbnail.active {
    border-color: var(--primary-gold);
    background: linear-gradient(135deg, 
        rgba(201, 149, 40, 0.1) 0%, 
        rgba(201, 149, 40, 0.05) 100%);
    box-shadow: 0 0 25px rgba(201, 149, 40, 0.5);
    transform: translateY(-1px);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-number {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: #ffffff;
    color: #000000;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.thumbnail-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(201, 149, 40, 0.95);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    z-index: 10;
    animation: pulse 1.5s infinite;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.thumbnail.hd-loaded .thumbnail-img {
    transition: all 0.3s ease;
}

.thumbnail.hd-loaded {
    border-color: rgba(201, 149, 40, 0.5);
}

.page-highlight {
    animation: pageHighlight 2s ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes pageHighlight {
    0% { 
        box-shadow: 0 0 0 0 rgba(201, 149, 40, 0.7);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 0 10px rgba(201, 149, 40, 0.3);
        transform: scale(1.02);
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(201, 149, 40, 0);
        transform: scale(1);
    }
}

/* Main PDF Container */
.pdf-container {
    flex: 1;
    padding: 2rem;
    margin-left: 280px;
    max-width: calc(100% - 280px);
    position: relative;
    height: calc(100vh - 80px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Zoom Controls - Small and positioned in top-right corner */
.zoom-controls-top {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(201, 149, 40, 0.2);
    border-radius: 20px;
    padding: 0.3rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    width: fit-content;
    flex-shrink: 0;
}

#pdf-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    max-width: 100%;
    transition: transform 0.3s ease;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
    margin-top: 1rem;
}

/* 2-Page Spread Container */
.page-spread {
    display: flex;
    gap: 0; /* No gap between pages - they should be connected */
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: none; /* Use full available width */
    margin: 0 auto;
    padding: 0; /* No left and right margins - use full width */
}

/* Custom scrollbar for PDF viewer */
#pdf-viewer::-webkit-scrollbar {
    width: 12px;
}

#pdf-viewer::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

#pdf-viewer::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, 
        var(--primary-gold) 0%, 
        var(--primary-dark) 100%);
    border-radius: 6px;
    border: 2px solid #f1f1f1;
}

#pdf-viewer::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, 
        var(--primary-light) 0%, 
        var(--primary-gold) 100%);
}

.page {
    width: 50%; /* Use exactly half the available width */
    height: calc(50vw * 0.707); /* Maintain A4 landscape ratio based on available width */
    min-height: 60vh; /* Ensure minimum height for better visibility */
    max-height: 90vh; /* Allow pages to be taller for full screen usage */
    background: #ffffff; /* Pure white background */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(201, 149, 40, 0.2);
    box-shadow: 0 8px 25px rgba(201, 149, 40, 0.15), 
                0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    margin: 0;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

/* Remove right border from first page in spread */
.page-spread .page:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

/* Remove left border from second page in spread */
.page-spread .page:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: none;
}

/* Add connecting shadow effect between pages */
.page-spread .page:first-child {
    box-shadow: 0 8px 25px rgba(201, 149, 40, 0.15), 
                0 2px 10px rgba(0, 0, 0, 0.1),
                2px 0 0 rgba(201, 149, 40, 0.1);
}

.page-spread .page:last-child {
    box-shadow: 0 8px 25px rgba(201, 149, 40, 0.15), 
                0 2px 10px rgba(0, 0, 0, 0.1),
                -2px 0 0 rgba(201, 149, 40, 0.1);
}

/* Single page for odd pages or when needed */
.page.single-page {
    width: 50%;
    height: calc(50vw * 0.707);
    min-height: 60vh;
    max-height: 90vh;
    margin: 0 auto;
}

.page img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.hard-cover {
    background: linear-gradient(135deg, 
        var(--primary-gold) 0%, 
        var(--primary-dark) 50%, 
        var(--primary-gold) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 700;
    position: relative;
    overflow: hidden;
}

.hard-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 35px,
        rgba(255, 255, 255, 0.1) 35px,
        rgba(255, 255, 255, 0.1) 70px
    );
}

.cover-title {
    font-size: 2.8rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.5);
    z-index: 2;
    position: relative;
    background: linear-gradient(45deg, #fff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cover-subtitle {
    font-size: 1.4rem;
    opacity: 0.95;
    font-weight: 400;
    z-index: 2;
    position: relative;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.3);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(15px);
}

.spinner {
    width: 70px;
    height: 70px;
    border: 4px solid rgba(201, 149, 40, 0.2);
    border-top: 4px solid var(--primary-gold);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    margin-bottom: 2rem;
    box-shadow: var(--glow-gold);
}

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

.loading-text {
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 600;
}

/* Navigation styles removed for scrollable layout */

@media (max-width: 1200px) {
    .page {
        width: 50%;
        height: calc(50vw * 0.707);
        min-height: 55vh;
        max-height: 85vh;
    }
    
    .page-spread {
        padding: 0; /* No margins - use full width */
    }
    
    .left-panel {
        width: 250px;
        top: 80px;
        height: calc(100vh - 80px);
    }
    
    .pdf-container {
        margin-left: 250px;
        max-width: calc(100% - 250px);
        height: calc(100vh - 80px);
    }
}

@media (max-width: 1024px) {
    .page {
        width: 50%;
        height: calc(50vw * 0.707);
        min-height: 50vh;
        max-height: 80vh;
    }
    
    .page-spread {
        padding: 0; /* No margins - use full width */
    }
    
    .left-panel {
        width: 220px;
        top: 80px;
        height: calc(100vh - 80px);
    }
    
    .pdf-container {
        margin-left: 220px;
        max-width: calc(100% - 220px);
        height: calc(100vh - 80px);
    }
    
    .thumbnail {
        height: 100px;
    }
}

@media (max-width: 768px) {
    .page {
        width: 100%; /* Full width for mobile */
        height: calc(100vw * 0.707); /* Maintain A4 ratio */
        min-height: 45vh;
        max-height: 70vh;
    }
    
    .page-spread {
        flex-direction: column;
        gap: 1rem; /* Add gap back for mobile since pages stack */
        padding: 0; /* No margins - use full width */
    }
    
    /* Reset connected page styling for mobile stacked layout */
    .page-spread .page:first-child,
    .page-spread .page:last-child {
        border-radius: 12px;
        border: 2px solid rgba(201, 149, 40, 0.2);
        box-shadow: 0 8px 25px rgba(201, 149, 40, 0.15), 
                    0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .left-panel {
        width: 200px;
        top: 80px;
        height: calc(100vh - 80px);
    }
    
    .pdf-container {
        margin-left: 200px;
        max-width: calc(100% - 200px);
        height: calc(100vh - 80px);
        padding: 1rem;
    }
    
    .thumbnail {
        height: 80px;
    }
    
    .panel-header {
        padding: 1rem 0.5rem;
    }
    
    .panel-header h3 {
        font-size: 1rem;
    }
    
    .zoom-controls-top {
        padding: 0.2rem;
        gap: 0.2rem;
        top: 8px;
        right: 8px;
    }
    
    .zoom-btn {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

@media (max-width: 640px) {
    .page {
        width: 100%; /* Full width for small mobile */
        height: calc(100vw * 0.707); /* Maintain A4 ratio */
        min-height: 40vh;
        max-height: 65vh;
    }
    
    .page-spread {
        flex-direction: column;
        gap: 0.8rem; /* Add gap back for mobile since pages stack */
        padding: 0; /* No margins - use full width */
    }
    
    /* Reset connected page styling for mobile stacked layout */
    .page-spread .page:first-child,
    .page-spread .page:last-child {
        border-radius: 12px;
        border: 2px solid rgba(201, 149, 40, 0.2);
        box-shadow: 0 8px 25px rgba(201, 149, 40, 0.15), 
                    0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .left-panel {
        width: 180px;
        top: 80px;
        height: calc(100vh - 80px);
    }
    
    .pdf-container {
        margin-left: 180px;
        max-width: calc(100% - 180px);
        height: calc(100vh - 80px);
        padding: 0.5rem;
    }
    
    .thumbnail {
        height: 70px;
    }
    
    #pdf-viewer {
        gap: 1rem;
        padding: 1rem;
    }
    
    .zoom-controls-top {
        padding: 0.2rem;
        gap: 0.2rem;
        top: 6px;
        right: 6px;
    }
    
    .zoom-btn {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }
    
    #zoom-level {
        font-size: 8px;
        min-width: 25px;
        padding: 0.1rem 0.3rem;
    }
}

.fade-in {
    animation: fadeInUp 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(30px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}