:root {
    /* Blue color theme */
    --primary-blue: #2563eb;
    --primary-blue-dark: #1d4ed8;
    --primary-blue-light: #3b82f6;
    --secondary-blue: #60a5fa;
    --accent-blue: #93c5fd;

    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Category Filter */
.category-filter {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    animation: fadeIn 0.6s ease-out 0.2s both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.category-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

.category-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.category-btn.active {
    background: white;
    color: var(--primary-blue);
}

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

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Gallery Grid */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    animation: fadeIn 0.6s ease-out;
}

.pdf-card {
    background: var(--surface);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    animation: scaleIn 0.4s ease-out both;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.pdf-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.pdf-thumbnail {
    width: 100%;
    height: 350px;
    object-fit: cover;
    object-position: center top;
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--secondary-blue) 100%);
    transition: var(--transition);
}

.pdf-card:hover .pdf-thumbnail {
    transform: scale(1.05);
}

.pdf-info {
    padding: 1.25rem;
}

.pdf-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.pdf-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pdf-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--accent-blue);
    color: var(--primary-blue-dark);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.pdf-date {
    color: var(--text-secondary);
}

.pdf-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-download {
    flex: 1;
    padding: 0.75rem;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-download:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
}

/* Flipbook Overlay */
.flipbook-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.flipbook-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.flipbook-header {
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
}

.flipbook-header.visible {
    transform: translateY(0);
}

.flipbook-title {
    color: black;
    font-size: 1.5rem;
    font-weight: 600;
}

.btn-icon {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: black;
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.flipbook-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
    background: #2a2a2a;
    padding: 2rem;
}

.magazine {
    width: 1600px;
    height: 1000px;
    margin: 0 auto;
    transition: transform 0.3s ease-in-out;
}

.magazine .page {
    width: 800px;
    height: 1000px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

/* Mobile scrolling view */
.mobile-pages-container {
    width: 100%;
    max-width: 100vw;
    height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: y mandatory;
    padding: 1rem 0;
}

.mobile-page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
    padding: 1rem;
    box-sizing: border-box;
}

.mobile-page .page-canvas {
    max-width: 100%;
    max-height: calc(100vh - 160px);
    width: auto;
    height: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.flipbook-loading {
    position: absolute;
    color: white;
    font-size: 1.2rem;
}

.flipbook-controls {
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.flipbook-controls.visible {
    transform: translateY(0);
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-control {
    background: var(--primary-blue);
    border: none;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-control:hover:not(:disabled) {
    background: var(--primary-blue-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.4);
}

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

.page-info {
    color: black;
    font-weight: 500;
    padding: 0 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.5rem;
    }

    .pdf-thumbnail {
        height: 280px;
    }

    .flipbook-header {
        padding: 1rem;
    }

    .flipbook-title {
        font-size: 1.1rem;
    }

    .flipbook-controls {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
    }

    .controls-left,
    .controls-right {
        width: 100%;
        justify-content: center;
    }

    .btn-control {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: 1fr;
    }

    .category-filter {
        justify-content: center;
    }
}

/* Mobile flipbook adjustments */
@media (max-width: 767px) {

    /* Hide zoom controls on mobile */
    .controls-right button[onclick="zoomIn()"],
    .controls-right button[onclick="zoomOut()"] {
        display: none;
    }

    /* Adjust header and footer for mobile */
    .flipbook-header,
    .flipbook-controls {
        padding: 1rem;
    }

    .flipbook-title {
        font-size: 1.1rem;
    }

    /* Larger touch targets for mobile */
    .btn-icon,
    .btn-control {
        min-width: 44px;
        min-height: 44px;
    }
}