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

:root {
    --primary: #2563eb;
    --secondary: #1e40af;
    --accent: #dc2626;
    --bg-dark: #030712;
    --bg-card: #1a1f37;
    --text-light: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: linear-gradient(180deg, #0a0f1f 0%, #1a1f37 50%, #0a0f1f 100%);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: rgba(3, 7, 18, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.logo {
    font-size: 28px;
    font-weight: 400;
    opacity: 0.9;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    margin: 0 32px;
}

.pdf-selector {
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 31, 55, 0.6);
    color: var(--text-light);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.pdf-selector:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.15);
}

.pdf-selector:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.15);
}

.header-right {
    display: flex;
    gap: 16px;
}

.header-link {
    padding: 8px 16px;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.header-link:hover {
    color: var(--text-light);
    transform: translateY(-1px);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    overflow: hidden;
    position: relative;
}

/* Viewer Wrapper */
.viewer-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    overflow: hidden;
    position: relative;
    perspective: 2000px;
}

/* Book Wrapper */
.book-wrapper {
    flex: 1;
    display: flex;
    gap: 0;
    align-items: center;
    justify-content: center;
    height: 100%;
    max-height: 100%;
    perspective: 2000px;
    padding: 24px;
}

/* Page Container */
.page-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    perspective: 2000px;
    transform-style: preserve-3d;
}

.left-page-container {
    perspective-origin: right center;
}

.right-page-container {
    perspective-origin: left center;
}

/* Control Buttons */
.control-btn {
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: none;
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(15px);
    z-index: 50;
    box-shadow: var(--shadow-md);
}

.prev-btn {
    left: 24px;
}

.next-btn {
    right: 24px;
}

.control-btn:hover {
    background: rgba(37, 99, 235, 0.25);
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.2);
    transform: scale(1.08);
}

.control-btn:active {
    transform: scale(0.96);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

/* Pages */
.page {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: white;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    aspect-ratio: 9 / 13;
    transform-style: preserve-3d;
    border-radius: 2px;
}

.page canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: high-quality;
}

/* Page Flip Animation - SMOOTH 3D */
.left-page-container .page {
    animation: flipInLeft 0.7s cubic-bezier(0.6, 0.04, 0.98, 0.34) forwards;
}

.right-page-container .page {
    animation: flipInRight 0.7s cubic-bezier(0.6, 0.04, 0.98, 0.34) forwards;
}

@keyframes flipInLeft {
    from {
        opacity: 0;
        transform: rotateY(-95deg) translateZ(-60px);
    }
    to {
        opacity: 1;
        transform: rotateY(0deg) translateZ(0);
    }
}

@keyframes flipInRight {
    from {
        opacity: 0;
        transform: rotateY(95deg) translateZ(-60px);
    }
    to {
        opacity: 1;
        transform: rotateY(0deg) translateZ(0);
    }
}

/* Page Numbers */
.page-number {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-size: 11px;
    color: #999;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.left-page-container .page-number {
    right: auto;
    left: 12px;
}

/* Bottom Controls Bar */
.bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: rgba(3, 7, 18, 0.8);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(51, 65, 85, 0.3);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    gap: 32px;
}

.bar-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-section.center {
    flex: 1;
    justify-content: center;
}

.bar-section.right {
    justify-content: flex-end;
}

/* Zoom Slider */
.zoom-slider {
    width: 140px;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
    transition: all 0.2s ease;
}

.zoom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.6);
}

.zoom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
    transition: all 0.2s ease;
}

.zoom-slider::-moz-range-thumb:hover {
    transform: scale(1.25);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.6);
}

.zoom-display {
    width: 50px;
    text-align: center;
    font-weight: 600;
    color: var(--primary);
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

/* Page Info */
#pageInput {
    width: 45px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-weight: 600;
    text-align: center;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

#pageInput:focus {
    outline: none;
}

.separator {
    color: var(--text-muted);
    font-weight: 300;
}

#totalPages {
    color: var(--text-muted);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Icon Buttons */
.control-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-icon-btn:hover {
    background: rgba(37, 99, 235, 0.2);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* Loading Spinner */
.loading-spinner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(4px);
}

.loading-spinner.show {
    display: flex;
}

.spinner {
    border: 3px solid rgba(37, 99, 235, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

.loading-spinner p {
    color: var(--text-light);
    font-size: 16px;
}

/* Error Message */
.error-message {
    display: none;
    position: fixed;
    top: 24px;
    right: 24px;
    background: #dc2626;
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    animation: slideInRight 0.3s ease;
    max-width: 350px;
    font-size: 14px;
}

.error-message.show {
    display: block;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 1200px) {
    .book-wrapper {
        padding: 16px;
    }

    .control-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .prev-btn {
        left: 16px;
    }

    .next-btn {
        right: 16px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .header-center {
        order: 3;
        width: 100%;
        flex-basis: 100%;
        margin: 0;
    }

    .pdf-selector {
        width: 100%;
    }

    .book-wrapper {
        flex-direction: column;
        padding: 12px;
    }

    .page {
        min-height: 250px;
        aspect-ratio: auto;
    }

    .control-btn {
        position: fixed;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .prev-btn {
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
    }

    .next-btn {
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
    }

    .bottom-bar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px;
    }

    .bar-section {
        flex: 1;
        justify-content: center;
    }

    .zoom-slider {
        width: 100px;
    }
}
