/* 
 * סגנונות לדפדפן PDF באתר "דרכו של זה"
 */

.book-viewer-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 10rem);
    min-height: 37.5rem;
    max-height: 90vh;
    margin-bottom: var(--spacing-xl);
    position: relative;
}

.book-toolbar {
    background-color: white;
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.book-controls {
    display: flex;
    align-items: center;
}

.book-controls button {
    background: none;
    border: 1px solid var(--border-color);
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
}

.book-controls button:hover {
    background-color: var(--background-color);
}

.page-info {
    margin: 0 var(--spacing-md);
    font-size: 1.1rem;
}

.book-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.page-jumper {
    display: flex;
    align-items: center;
    margin-right: var(--spacing-md);
}

.page-jumper label {
    margin-right: var(--spacing-xs);
    margin-bottom: 0;
}

.page-jumper input {
    width: 3.75rem;
    margin-right: var(--spacing-xs);
    text-align: center;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.page-jumper button {
    padding: 0.3125rem 0.625rem;
}

.book-content {
    flex: 1;
    position: relative;
    border: 1px solid var(--border-color);
    background-color: #e0e0e0;
    overflow: hidden;
}

#pdf-viewer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease-in-out;
}

#pdf-viewer canvas {
    display: block;
    margin: 0;
    box-shadow: 0 0 0.625rem rgba(0, 0, 0, 0.2);
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

/* מצב שני עמודים */
.double-page canvas {
    margin: 0 -0.3125rem;
}

/* מצב עמוד אחד (כריכה) */
.single-page canvas {
    margin: 0 auto;
}

.book-not-available {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: var(--spacing-xl);
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: 0 0 0.625rem rgba(0, 0, 0, 0.1);
    max-width: 90%;
}

.book-not-available h2 {
    margin-bottom: var(--spacing-md);
    color: var(--primary-color);
}

/* התאמה למסכים קטנים */
@media screen and (max-width: 48rem) { /* 768px */
    .book-viewer-container {
        height: calc(100vh - 9.375rem);
    }
    
    .book-toolbar {
        flex-direction: column;
        align-items: flex-start;
        padding: var(--spacing-sm);
    }
    
    .book-controls {
        margin-bottom: var(--spacing-md);
        width: 100%;
        justify-content: center;
    }
    
    .book-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    
    .page-jumper {
        margin-bottom: var(--spacing-md);
        width: 100%;
        justify-content: center;
    }
    
    .book-actions button {
        margin-bottom: var(--spacing-xs);
        width: 100%;
    }
    
    #pdf-viewer {
        flex-direction: column;
    }
    
    #pdf-viewer canvas {
        max-width: 95%;
        margin: var(--spacing-xs) auto;
    }
}

/* RTL התאמות */
.rtl .page-jumper {
    margin-right: 0;
    margin-left: var(--spacing-md);
}

.rtl .page-jumper label {
    margin-right: 0;
    margin-left: var(--spacing-xs);
}

.rtl .page-jumper input {
    margin-right: 0;
    margin-left: var(--spacing-xs);
    text-align: right;
}

@media screen and (max-width: 30rem) { /* 480px */
    .book-viewer-container {
        height: calc(100vh - 7.5rem);
    }
    
    .page-info {
        font-size: 0.9rem;
    }
    
    .book-controls button {
        width: 2rem;
        height: 2rem;
    }
}


.page-navigation {
    z-index: 10;
    background: var(--background-color);
    padding: 10px;
    border-radius: 5px;
}



/* סגנון עמודים */
.page {
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* מספר עמוד */
.page-number {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #666;
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 8px;
    border-radius: 3px;
}

/* הודעת טעינה */
.loading-message,
.loading-progress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 18px;
    color: #666;
}

/* אינדיקטור טעינה */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: 50px; /* מתחת להודעת "טוען את הספר" */
    background: white;
    padding: 20px 40px;
    border-radius: 10px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 300px;
    text-align: center;
}

.loading-bar {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.loading-progress-bar {
    height: 100%;
    background: rgb(30, 89, 84);
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* הודעת עמוד לא נטען */
.page-loading-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1001;
    font-size: 14px;
}

/* התאמה ל-RTL */
.rtl .loading-indicator {
    right: auto;
    left: 10px;
}

.rtl .page-number {
    direction: ltr;
}

/* התאמה למובייל */
@media (max-width: 768px) {
    .loading-indicator {
        top: auto;
        bottom: 60px;
        right: 50%;
        transform: translateX(50%);
    }
    
    .page-number {
        font-size: 10px;
        bottom: 10px;
    }
}


/* אנימציית Fade */
#pdf-viewer.fade-out {
    opacity: 0;
}

#pdf-viewer.fade-in {
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

