* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: #0f172a;
    color: #f8fafc;
    overflow: hidden; /* Prevent scrolling, app-like feel */
    user-select: none; /* Prevent text selection for better drag-to-flip feel */
}

.app-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* Background Blobs for Glassmorphism depth */
.blob {
    position: absolute;
    filter: blur(100px);
    z-index: -1;
    border-radius: 50%;
    opacity: 0.5;
    animation: float 20s ease-in-out infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: #4f46e5; /* Indigo */
}

.blob-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: #ec4899; /* Pink */
    animation-delay: -5s;
}

.blob-3 {
    top: 30%;
    left: 40%;
    width: 40vw;
    height: 40vw;
    background: #06b6d4; /* Cyan */
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 10%) scale(1.1); }
}

/* Glassmorphism utility */
.glass {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.book-container {
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    perspective: 1500px;
    z-index: 2;
    overflow: auto; /* Allow scrolling when zoomed in */
}

#zoom-wrapper {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
    max-width: 1200px;
    max-height: calc(100vh - 120px);
    transition: width 0.3s ease, height 0.3s ease;
}

.flipbook {
    width: 100%;
    height: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    border-radius: 4px;
}

.page {
    background-color: #fff;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

.page canvas {
    width: 100%;
    height: 100%;
    object-fit: contain; /* OR fill, depending on preference */
    background-color: #ffffff; /* Make sure transparent PDFs have white background */
}

/* Realism for pages */
.page.--left {
    border-right: 1px solid rgba(0,0,0,0.15);
    background: linear-gradient(to left, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0) 5%);
}

.page.--right {
    border-left: 1px solid rgba(0,0,0,0.15);
    background: linear-gradient(to right, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0) 5%);
}

.page:before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    z-index: 10;
    pointer-events: none;
}
.page.--right:before {
    left: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 100%);
}
.page.--left:before {
    right: 0;
    background: linear-gradient(to left, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 100%);
}

.bottom-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 12px 30px;
    margin: 0 auto 30px auto;
    border-radius: 50px;
    width: fit-content;
    z-index: 10;
    transition: transform 0.3s ease;
    flex-wrap: wrap; /* Support for smaller screens with many buttons */
}

.divider {
    width: 2px;
    height: 30px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.bottom-controls:hover {
    transform: translateY(-5px);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: #4f46e5;
    border-color: #6366f1;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(79, 70, 229, 0.5);
}

.icon-btn:active {
    transform: scale(0.95);
}

.page-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 400;
}

#page-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 10px;
    padding: 6px 10px;
    width: 65px;
    text-align: center;
    font-size: 1.1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
}

#page-input:focus {
    border-color: #818cf8;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(129, 140, 248, 0.3);
}

/* Remove arrows from number input */
#page-input::-webkit-outer-spin-button,
#page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#page-input[type=number] {
    -moz-appearance: textfield;
}

.separator {
    opacity: 0.6;
}

#total-pages {
    font-weight: 600;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    color: #e2e8f0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top: 4px solid #818cf8;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}

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

@media (max-width: 768px) {
    .book-container { padding: 5px; }
    .flipbook { max-height: calc(100vh - 90px); }
    .bottom-controls { margin: 0 auto 15px auto; padding: 10px 15px; gap: 10px; }
    .icon-btn { width: 38px; height: 38px; font-size: 1.5rem; }
    .page-indicator { font-size: 1rem; }
    #page-input { width: 50px; padding: 4px 8px; font-size: 1rem; }
}
