:root {
    
    --color-gold: #ffd700;
    --color-white: #ffffff;
    --color-black: #000000;
    --color-gray-50: #f9fafb;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --transition: all .3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding-top: 80px;
}

/* Header */
header {
    
    color: var(--color-white);
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700
}

nav ul {
    display: flex;
    list-style: none
}

nav ul li {
    margin-left: 1.5rem
}

nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color .3s
}

nav ul li a:hover {
    color: #e0e0e0
}

/* Breadcrumbs */
.breadcrumbs {
    background: var(--color-gray-50);
    padding: 1rem 0;
    margin-top: 0
}

.breadcrumbs .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem
}

.breadcrumbs a {
    color: var(--color-purple);
    text-decoration: none
}

/* Hero */
.biblioteca-hero {
    background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-purple-dark) 100%);
    color: var(--color-white);
    padding: 80px var(--spacing-md) 60px;
    text-align: center
}

.biblioteca-hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem
}

.biblioteca-hero p {
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto
}

/* Grid */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md)
}

.section-header {
    text-align: center;
    margin: var(--spacing-2xl) 0
}

.section-header h2 {
    color: var(--color-purple);
    font-size: 2rem;
    margin-bottom: var(--spacing-md)
}

.section-divider {
    width: 80px;
    height: 4px;
    background: var(--color-gold);
    margin: 0 auto var(--spacing-lg)
}

.publicacoes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-xl);
    margin: var(--spacing-2xl) 0
}

.publicacao-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer
}

.publicacao-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl)
}

.publicacao-capa {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-purple), var(--color-purple-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white)
}

.publicacao-capa .pdf-icon {
    font-size: 3rem;
    opacity: .8
}

.publicacao-badge {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: var(--color-gold);
    color: var(--color-black);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: .8rem;
    font-weight: 600
}

.publicacao-info {
    padding: var(--spacing-lg)
}

.publicacao-info h3 {
    color: var(--color-purple);
    margin-bottom: var(--spacing-sm);
    font-size: 1.25rem
}

.publicacao-meta {
    color: var(--color-gray-600);
    font-size: .9rem;
    margin-bottom: var(--spacing-md)
}

.publicacao-descricao {
    color: var(--color-gray-600);
    font-size: .95rem;
    margin-bottom: var(--spacing-lg);
    line-height: 1.5
}

.publicacao-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap
}

.btn-acao {
    flex: 1;
    min-width: 80px;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
    font-size: .9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs)
}

.btn-ler {
    background: var(--color-purple);
    color: var(--color-white)
}

.btn-ler:hover {
    background: var(--color-purple-dark);
    transform: translateY(-2px)
}

.btn-baixar {
    background: var(--color-gold);
    color: var(--color-black)
}

.btn-baixar:hover {
    background: var(--color-white);
    border: 2px solid var(--color-gold);
    transform: translateY(-2px)
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px)
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn .3s ease
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

.modal-flipbook {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    width: 95%;
    height: 95%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    transform: scale(.95);
    transition: transform .3s ease;
}

.modal-overlay.active .modal-flipbook {
    transform: scale(1)
}

.modal-header {
    
    padding: var(--spacing-sm) var(--spacing-lg); 
   
    
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between; /* Empurra o botão de fechar para o canto */
    align-items: center;
    padding: 10px 20px;
    z-index: 1010;
}

.modal-header .close-btn {
    margin-left: auto; 
}

.modal-title {
    color: var(--color-purple);
    margin: 0;
    font-size: 1.5rem
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-gray-600);
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    transition: var(--transition)
}

.modal-close:hover {
    background: var(--color-gray-200);
    color: var(--color-purple)
}

/* Flipbook area */
.flipbook-container {
    flex: 1;
    position: relative;
    perspective: 2000px;
    background: #f0f0f0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px
}

.flipbook-viewport {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    display: flex;
    align-items: center;
    justify-content: center
}

/* Single page (cover) */
.single-page {
    width: 80%;
    height: 100%;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.single-page canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block
}

/* Spread (two pages) */
.spread {
    width: 90%;
    height: 100%;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: center;
}

.page-left,
.page-right {
    width: 50%;
    height: 100%;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.20);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.page-left canvas,
.page-right canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* controls */
.flipbook-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--color-gray-50);
    border-top: 1px solid var(--color-gray-200)
}

.flip-btn {
    background: var(--color-purple);
    color: var(--color-white);
    border: none;
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm)
}

.flip-btn:hover {
    background: var(--color-purple-dark);
    transform: translateY(-2px)
}

.flip-btn:disabled {
    background: var(--color-gray-300);
    cursor: not-allowed;
    transform: none
}

.page-indicator {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-purple);
    min-width: 120px;
    text-align: center
}

/* thumbnails */
.thumbnails-container {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin: var(--spacing-xl) 0;
    flex-wrap: wrap;
    max-height: 120px;
    overflow: auto;
    padding: 0 20px
}

.thumbnail {
    width: 50px;
    height: 70px;
    background: var(--color-white);
    border: 2px solid var(--color-gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--color-purple);
    font-size: .8rem;
    overflow: hidden;
    margin: 4px
}

.thumbnail:hover {
    border-color: var(--color-purple);
    transform: translateY(-3px)
}

.thumbnail.active {
    border-color: var(--color-gold);
    background: var(--color-gold);
    color: var(--color-white)
}

/* loading */
.pdf-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-purple);
    font-size: 1.2rem
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-gray-200);
    border-top: 4px solid var(--color-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--spacing-md)
}

@keyframes spin {
    0% {
        transform: rotate(0)
    }

    100% {
        transform: rotate(360deg)
    }
}

/* responsive */
@media (max-width:1024px) {
    .spread {
        width: 95%
    }

    .single-page {
        width: 90%
    }
}

@media (max-width:768px) {
    .single-page {
        width: 100%;
        padding: 8px
    }

    .spread {
        flex-direction: column;
        width: 95%;
        gap: 12px
    }

    .page-left,
    .page-right {
        width: 100%;
        height: 48vh
    }

    .thumbnails-container {
        flex-wrap: nowrap;
        overflow-x: auto
    }
}

/* ====================== MODAL CORRIGIDO E FUNCIONAL ====================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.98);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-flipbook {
    width: 95%;
    height: 95%;
    max-width: 1400px;
    max-height: 960px;
    background: #000;
    border: 6px solid #ffd700;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    background: #000;
    color: #ffd700;
    padding: 1rem 2rem;
    border-bottom: 2px solid #ffd700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 700;
}

.flipbook-viewport {
    flex: 1;
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.single-page, .spread {
    display: flex;
    justify-content: center;
    align-items: center;
}

.spread {
    gap: 16px;
}

.page-left, .page-right {
    background: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.7);
    max-height: 100%;
    overflow: hidden;
}

.page-left canvas, .page-right canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.flipbook-controls {
    background: #000;
    color: #ffd700;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    font-size: 1.1rem;
}

.flip-btn {
    background: none;
    border: 2px solid #ffd700;
    color: #ffd700;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
}

.flip-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    background: rgba(0,0,0,0.7);
    padding: 12px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
}

.modal-controls button {
    background: transparent;
    border: 2px solid #ffd700;
    color: #ffd700;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
}

.modal-controls button:hover {
    background: #ffd700;
    color: #000;
}

/* Adicione ao final do seu biblioteca.css */

/* Melhorias para o visualizador */
.flipbook-viewport {
    background: #2c2c2c;
}

.single-page, .page-left, .page-right {
    background: white !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
}

/* Loading states melhorados */
.pdf-loading {
    color: #ffd700 !important;
    font-size: 1.1rem;
}

.loading-spinner {
    border: 4px solid #444;
    border-top: 4px solid #ffd700;
}

/* Controles mais responsivos */
@media (max-width: 768px) {
    .modal-flipbook {
        width: 98%;
        height: 98%;
    }
    
    .flipbook-controls {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .flip-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Estados de erro */
.pdf-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #e74c3c;
    padding: 2rem;
    text-align: center;
}

.pdf-error button {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Adicione estas regras ao seu biblioteca.css */

/* ========== BARRA DE PESQUISA SOFISTICADA ========== */
.search-container {
    max-width: 700px;
    margin: 0 auto var(--spacing-2xl);
    width: 100%;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--color-white);
    border: 2px solid #e5e7eb;
    border-radius: 50px;
    padding: 1rem 1.5rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.search-box:focus-within {
    border-color: #8b5cf6;
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.15);
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 1);
}

.search-box.has-results {
    border-color: #ffd700;
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.2);
}

.search-icon {
    color: #6b7280;
    margin-right: 1rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.search-box:focus-within .search-icon {
    color: #8b5cf6;
    transform: scale(1.1);
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 400;
    color: #374151;
    padding: 0.5rem 0;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.01em;
}

.search-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
    transition: all 0.3s ease;
}

.search-box:focus-within .search-input::placeholder {
    color: #d1d5db;
}

.search-clear {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-left: 0.5rem;
}

.search-clear:hover {
    background: #f3f4f6;
    color: #ef4444;
    transform: scale(1.1);
}

.search-results {
    text-align: center;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #a52a2a  0%, #a32525 100%);
    color: var(--color-white);
    border-radius: 25px;
    font-weight: 500;
    font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    transition: all 0.4s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-results.highlight {
    background: linear-gradient(135deg, #ffd700 0%, #fbbf24 100%);
    color: #1f2937;
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.4);
}

/* ========== CAPAS DOS PDFs ========== */
.publicacao-capa {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    transition: all 0.3s ease;
}

.publicacao-capa .pdf-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.publicacao-capa .pdf-fallback {
    font-size: 3rem;
    opacity: 0.7;
    color: #6b7280;
}

.publicacao-card:hover .publicacao-capa .pdf-preview {
    transform: scale(1.05);
}

/* ========== CONTROLES DE NAVEGAÇÃO DO ZOOM ========== */
.zoom-navigation {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.8);
    padding: 12px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid #ffd700;
}

.nav-btn {
    background: transparent;
    border: 1px solid #ffd700;
    color: #ffd700;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: #ffd700;
    color: #000;
    transform: scale(1.1);
}

.nav-center {
    margin-top: 8px;
    background: #ffd700;
    color: #000;
    font-weight: bold;
}

.nav-center:hover {
    background: #ffffff;
    color: #000;
}

/* ========== INDICADOR DE ZOOM ========== */
.zoom-level {
    color: #ffd700;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 50px;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #ffd700;
}

/* ========== MELHORIAS NO MODAL ========== */
.modal-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.8);
    padding: 12px 16px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    border: 1px solid #ffd700;
}

.modal-controls button {
    background: transparent;
    border: 1px solid #ffd700;
    color: #ffd700;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-controls button:hover {
    background: #ffd700;
    color: #000;
    transform: scale(1.1);
}

/* ========== ANIMAÇÕES ========== */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-container {
    animation: slideInUp 0.6s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.publicacao-card {
    animation: fadeInScale 0.5s ease;
}

/* ========== RESPONSIVIDADE ========== */
@media (max-width: 768px) {
    .search-container {
        max-width: 100%;
        margin: 0 auto var(--spacing-xl);
    }
    
    .search-box {
        padding: 0.8rem 1.25rem;
        border-radius: 25px;
    }
    
    .search-input {
        font-size: 1rem;
    }
    
    .search-results {
        font-size: 0.9rem;
        padding: 0.6rem 1.25rem;
    }
    
    .zoom-navigation {
        right: 10px;
        padding: 8px;
    }
    
    .nav-btn {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .modal-controls {
        bottom: 10px;
        right: 10px;
        padding: 10px 14px;
    }
    
    .modal-controls button {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .search-box {
        padding: 0.7rem 1rem;
    }
    
    .search-input {
        font-size: 0.95rem;
    }
    
    .search-input::placeholder {
        font-size: 0.9rem;
    }
    
    .zoom-navigation {
        display: none; /* Oculta em mobile muito pequeno */
    }
}

/* Estados de loading na busca */
.search-box.loading .search-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}