:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --accent-color: #06b6d4;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --gradient-accent: linear-gradient(135deg, var(--accent-color), var(--primary-color));
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--surface-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-logo {
    height: 6rem;
    margin-right: 0.75rem;
    vertical-align: middle;
}

.controls {
    display: flex;
    gap: 0.5rem;
}

.btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    color: var(--text-primary);
    font-size: 1rem;
}

.btn:hover {
    background: var(--bg-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--gradient-accent);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-secondary);
}

.main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    padding: 3rem;
    text-align: center;
    background: var(--surface-color);
    transition: all 0.3s;
    max-width: 600px;
    width: 100%;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
}

.drop-zone.dragover {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(99, 102, 241, 0.1));
}

.drop-zone-content i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.drop-zone-content h2 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.drop-zone-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.flipbook-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.flipbook {
    width: 100%;
    height: 80vh;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    perspective: 1500px;
    display: flex;
}

.book-spine {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom,
        transparent 0%,
        rgba(0,0,0,0.1) 5%,
        rgba(0,0,0,0.2) 50%,
        rgba(0,0,0,0.1) 95%,
        transparent 100%
    );
    transform: translateX(-50%);
    z-index: 10;
    box-shadow: 
        -1px 0 2px rgba(0,0,0,0.1),
        1px 0 2px rgba(0,0,0,0.1);
}

.page {
    position: relative;
    width: 50%;
    height: 100%;
    background: var(--surface-color);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: none; /* Remove flip transition */
}

.page:nth-child(odd) {
    border-right: 1px solid var(--border-color);
    border-radius: 0.5rem 0 0 0.5rem;
}

.page:nth-child(even) {
    border-left: 1px solid var(--border-color);
    border-radius: 0 0.5rem 0.5rem 0;
}

.page-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    font-size: 1.2rem;
    line-height: 1.8;
    backface-visibility: hidden;
    transform: none !important; /* Ensure no transformation */
}

.page-content canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform: none !important;
}

.page-number {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.page::before {
    content: '';
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, 
        rgba(0,0,0,0.05) 0%,
        rgba(0,0,0,0.1) 50%,
        rgba(0,0,0,0.05) 100%
    );
}

.page:nth-child(odd)::before {
    right: 0;
}

.page:nth-child(even)::before {
    left: 0;
}

.navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin: 2rem 0;
}

.nav-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-weight: 500;
    color: var(--text-secondary);
}

.toolbar {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    gap: 0.5rem;
    background: var(--surface-color);
    padding: 0.5rem;
    border-radius: 2rem;
    box-shadow: var(--shadow-lg);
}

.tool-btn {
    background: none;
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.tool-btn:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface-color);
    margin: 10% auto;
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 1.5rem;
    cursor: pointer;
}

.close:hover {
    color: var(--text-primary);
}

.help-content {
    max-height: 80vh;
    overflow-y: auto;
}

.help-content h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.help-section {
    margin-bottom: 1.5rem;
}

.help-section h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.help-section ul {
    list-style: none;
    padding-left: 1rem;
}

.help-section li {
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

#urlInput {
    width: 100%;
    padding: 0.75rem;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

.loading-spinner i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    font-size: 0.875rem;
    z-index: 1000;
}

@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }
    
    .app-title {
        font-size: 1.25rem;
    }
    
    .drop-zone {
        padding: 2rem;
    }
    
    .navigation {
        gap: 1rem;
    }
    
    .toolbar {
        bottom: 1rem;
        right: 1rem;
    }
}

/* Fullscreen Overlay Styles */
#fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(17, 24, 39, 0.95); /* Darker background */
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: grab;
    backdrop-filter: blur(5px);
}

#fullscreen-page-container {
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease-out;
}

#fullscreen-page-container > * {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    transform-origin: center center;
    border-radius: 4px;
}

.fullscreen-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.fullscreen-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.fullscreen-nav:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    transform: translateY(-50%);
}

#fullscreen-prev {
    left: 20px;
}

#fullscreen-next {
    right: 20px;
}

#fullscreen-exit-hint {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    background: rgba(0,0,0,0.5);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0.7;
}

#fullscreen-page-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1rem;
    pointer-events: none;
    opacity: 0.8;
}