/* Базові налаштування модуля бібліотеки */
@import url('main.css');

#library-section {
    padding: 40px 20px;
    width: 100%;
    background: transparent;
    margin: 0;
}

#library-section .section-title {
    text-align: center;
    margin-bottom: 30px;
}

/* Вікно пошуку */
#library-section .search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    width: 100%;
}

#library-section .search-input-adapted {
    flex-grow: 1;
    padding: 12px 20px;
    font-size: 1.8rem;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

/* Стилі для кнопок навігації */
#library-section .nav-button {
    padding: 12px 25px !important;
    font-size: 1.5rem !important;
    white-space: nowrap;
    background: var(--text-muted) !important;
    color: white !important;
    border: none !important;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#library-section .nav-button:hover {
    background: #4b5563 !important;
}

#library-section .top-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

#library-section #bottom-navigation {
    display: none;
    justify-content: center;
    margin: 30px 0 20px;
    padding: 20px 0;
    border-top: 1px solid rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

/* Алфавіт та Кнопка повернення */
#library-section #alphabet-btns {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 10px;
    margin-bottom: 40px;
    justify-content: center;
}

#library-section #alphabet-btns button {
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: 1px solid #ccc;
    background: rgba(255, 255, 255, 0.8);
    font-size: 1.6rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#library-section #alphabet-btns button:hover {
    background: #2563eb;
    color: white;
}

/* Уніфікований контейнер для обкладинок */
#library-section .book-cover-wrapper {
    width: 100%;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.03);
}

#library-section .book-cover-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

/* Сітка: Виправлено для однакової ширини та довжини в ряду */
#library-section #lib-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
    align-items: stretch;
    justify-items: center;
}

/* Картка: Виправлено розміри */
#library-section .step-card {
    cursor: pointer;
    background: rgba(240, 248, 255, 0.95);
    border: 2px solid #d1e9ff;
    border-radius: 12px;
    padding: 30px; 
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    
    width: 100%;
    max-width: 480px; 
    height: auto;
    min-height: 450px;
    box-sizing: border-box;
}

#library-section .step-card.book-item {
    width: 100%;
    max-width: 320px;
    margin: 10px auto;
    min-height: 350px;
}

/* ========== ЗМІНИ ДЛЯ КНИЖКОВОЇ ПОЛИЦІ ========== */

/* Обкладинка - заокруглення */
#library-section .step-card.book-item .book-cover-wrapper {
    border-radius: 12px;
}

/* Назва книги - чорний колір, більший шрифт */
#library-section .step-card.book-item h3 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #000000;
    text-align: center;
    margin: 12px 0 6px;
    line-height: 1.3;
}

/* Автор - чорний колір, більший шрифт */
#library-section .step-card.book-item .book-author {
    font-size: 1.5rem;
    font-weight: 600;
    color: #000000;
    text-align: center;
    margin-bottom: 8px;
}

/* Кількість слів - чорний колір, більший шрифт */
#library-section .step-card.book-item .book-words {
    font-size: 1.4rem;
    color: #000000;
    text-align: center;
    margin-bottom: 12px;
}

/* Прогрес текст - чорний колір, більший шрифт */
#library-section .step-card.book-item .progress-text {
    color: #000000;
    font-size: 1.3rem;
}

/* Кнопка "Читати" - Material Symbols, більший шрифт */
#library-section .step-card.book-item .cta-button {
    font-size: 1.5rem;
    font-weight: 600;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #3b82f6;
    color: #3b82f6;
    border-radius: 50px;
    margin-top: 15px;
    transition: all 0.2s;
    pointer-events: auto;
}

#library-section .step-card.book-item .cta-button:hover {
    background: #3b82f6;
    color: white;
}

/* ========== КІНЕЦЬ ЗМІН ========== */

#library-section .step-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

#library-section .step-card:hover .book-cover-img {
    transform: scale(1.05);
}

/* Контейнер імен/назв */
#library-section .author-names {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 10px 0;
    width: 100%;
}

#library-section .original-name-small {
    font-size: 1.5rem;
    color: #000000;
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

#library-section .translated-name-large {
    font-size: 1.8rem;
    margin: 0;
    color: #222;
    font-weight: 700;
    line-height: 1.3;
    word-wrap: break-word;
}

/* ПАГІНАЦІЯ - ПОСИЛЕНІ СТИЛІ */
#library-section #pagination-container {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 40px 0 30px !important;
    width: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 80px !important;
}

#library-section .pagination-btn {
    background: #fff !important;
    color: #3b82f6 !important;
    border: 2px solid #3b82f6 !important;
    padding: 12px 30px !important;
    border-radius: 50px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    font-size: 1.5rem !important;
    transition: all 0.2s ease !important;
    margin: 0 5px !important;
    display: inline-block !important;
    min-width: 100px !important;
    text-align: center !important;
}

#library-section .pagination-btn:hover:not(:disabled) {
    background: #3b82f6 !important;
    color: #fff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3) !important;
}

#library-section .pagination-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    border-color: #9ca3af !important;
    color: #9ca3af !important;
    background: #f3f4f6 !important;
}

#library-section .page-total-text {
    font-size: 1.6rem !important;
    font-weight: 700 !important;
    color: #000 !important;
    margin: 0 5px !important;
    display: inline-block !important;
}

#library-section #page-input {
    width: 70px !important;
    padding: 10px !important;
    font-size: 1.5rem !important;
    font-weight: bold !important;
    text-align: center !important;
    border: 2px solid #3b82f6 !important;
    border-radius: 10px !important;
    outline: none !important;
    background: white !important;
    color: #000 !important;
    margin: 0 5px !important;
}

#library-section #page-input:focus {
    border-color: #1d4ed8 !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2) !important;
}

#library-section #page-go-btn {
    background: #fff !important;
    color: #3b82f6 !important;
    border: 2px solid #3b82f6 !important;
    padding: 10px 25px !important;
    border-radius: 50px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    font-size: 1.4rem !important;
    transition: all 0.2s ease !important;
    margin: 0 5px !important;
}

#library-section #page-go-btn:hover {
    background: #3b82f6 !important;
    color: #fff !important;
    transform: translateY(-2px) !important;
}

/* СУЧАСНИЙ КОНТЕЙНЕР ЗАВАНТАЖЕННЯ */
#library-section .loading-container {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    gap: 20px;
}

#library-section .loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(59, 130, 246, 0.1);
    border-top: 6px solid #3b82f6; 
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#library-section .loading-text {
    font-size: 2.2rem;
    font-weight: 700;
    color: #000;
    text-align: center;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Адаптація для мобільних */
@media (max-width: 768px) {
    #library-section .top-navigation {
        flex-direction: column;
        align-items: stretch;
    }
    
    #library-section .nav-button {
        width: 100%;
        margin: 5px 0;
        text-align: center;
    }
    
    #library-section #bottom-navigation {
        margin: 20px 0;
        padding: 15px 0;
    }
    
    #library-section #alphabet-btns { 
        grid-template-columns: repeat(5, 1fr) !important; 
    }
    
    #library-section #lib-grid { 
        grid-template-columns: 1fr !important; 
    }
    
    #library-section .pagination-btn { 
        padding: 10px 15px !important; 
        font-size: 1.2rem !important; 
        min-width: 70px !important;
    }
    
    #library-section .book-cover-wrapper { 
        height: 250px; 
    }
    
    #library-section .step-card.book-item { 
        width: 100%; 
        max-width: 100%; 
    }
    
    #library-section #pagination-container {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    
    #library-section .page-total-text {
        font-size: 1.4rem !important;
    }
    
    #library-section #page-input {
        width: 60px !important;
        padding: 8px !important;
        font-size: 1.3rem !important;
    }
}

/* ==============================================
   ВІКНО ВИБОРУ СТИЛЮ ПЕРЕКЛАДУ
   ============================================== */

.style-selector-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.style-selector-modal .modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 1200px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    max-height: none;
    overflow: visible;
}

.style-selector-modal h2 {
    font-size: 2.4rem;
    color: #1a1a1a;
    margin-bottom: 10px;
    font-weight: 700;
    text-align: center;
}

.style-selector-modal h3 {
    font-size: 1.6rem;
    color: #3b82f6;
    margin-bottom: 30px;
    font-weight: 600;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #eef2f6;
}

/* Сітка стилів в один рядок */
.style-selector-modal .style-grid {
    display: flex;
    flex-direction: row;
    gap: 20px;
    margin: 20px 0;
    justify-content: center;
    flex-wrap: wrap;
}

/* Картка стилю як книга */
.style-selector-modal .style-card {
    background: rgba(240, 248, 255, 0.95);
    border: 2px solid #d1e9ff;
    border-radius: 12px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 280px;
    min-height: 350px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.style-selector-modal .style-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.style-selector-modal .style-card.selected {
    border-color: #3b82f6;
    background: #e6f0ff;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
}

.style-selector-modal .style-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.style-selector-modal .style-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 10px;
}

.style-selector-modal .style-description {
    font-size: 1.4rem;
    color: #4a5568;
    margin-bottom: 15px;
    line-height: 1.4;
}

.style-selector-modal .style-example {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    font-size: 1.3rem;
    color: #2d3748;
    border-left: 4px solid #3b82f6;
    line-height: 1.5;
    font-family: monospace;
    white-space: pre-line;
    width: 100%;
    text-align: left;
}

/* ==============================================
   ВІКНО ОЧІКУВАННЯ
   ============================================== */

.waiting-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.waiting-modal .modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 80%;
    max-width: 90%;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.waiting-modal h2 {
    font-size: 2.2rem;
    color: #1a1a1a;
    margin-bottom: 20px;
    font-weight: 700;
}

/* Рекламний блок */
.waiting-modal .ad-placeholder {
    flex: 1;
    min-height: 250px;
    background: rgba(240, 248, 255, 0.95);
    border: 2px solid #d1e9ff;
    border-radius: 12px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #3b82f6;
}

/* Прогрес-бар */
.waiting-modal .progress-container {
    margin: 20px 0;
}

.waiting-modal .progress-bar {
    width: 100%;
    height: 20px;
    background: #eef2f6;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.waiting-modal .progress-fill {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.waiting-modal .progress-text {
    font-size: 1.8rem;
    font-weight: 600;
    color: #3b82f6;
}

/* Час очікування */
.waiting-modal .waiting-time {
    font-size: 1.6rem;
    color: #4b5563;
    margin: 10px 0;
}

/* Спінер */
.waiting-modal .loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(59, 130, 246, 0.1);
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto 0;
}

/* Адаптація для мобільних */
@media (max-width: 768px) {
    .style-selector-modal .modal-content {
        padding: 20px;
    }
    
    .style-selector-modal .style-grid {
        flex-direction: column;
        align-items: center;
    }
    
    .style-selector-modal .style-card {
        width: 100%;
        max-width: 320px;
    }
    
    .style-selector-modal h2 {
        font-size: 2rem;
    }
    
    .style-selector-modal h3 {
        font-size: 1.4rem;
    }
    
    .waiting-modal .modal-content {
        width: 350px;
        min-height: 450px;
        padding: 25px;
    }
    
    .waiting-modal h2 {
        font-size: 2rem;
    }
    
    .waiting-modal .ad-placeholder {
        min-height: 200px;
        font-size: 1.6rem;
    }
    
    .waiting-modal .waiting-time {
        font-size: 1.4rem;
    }
}