/* סגנונות לתצוגת הספר */
.book-display-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    width: 100%;
    flex-grow: 1;
    margin: 0; /* שינוי מ-40px ל-0 */
    padding: 0;
}

/* סגנון הספר - התאמה אוטומטית לחלל הזמין */
.book-cover {
    position: relative;
    width: min(90vw, 1200px); /* רוחב responsive */
    height: calc(100vh - 300px); /* גובה מסך פחות header+footer+ניווט */
    min-height: 400px; /* מינימום למובייל */
    margin: 0 auto 10px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    overflow: hidden;
}

/* מניעת סקרול במיכל הראשי */
main {
    overflow: hidden;
    height: 100vh;
    min-height: 600px;
}

/* עמודי הספר - מיכל ראשי */
#pdf-viewer {
    width: 100%;
    height: 100%;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    direction: ltr !important; /* הוספת כיווניות LTR כדי לתקן את הצגת הטקסט */
}

/* הקנבס של הספר */
#pdf-viewer canvas {
    max-height: 100%;
    max-width: 100%;
}

/* סגנון כריכה קדמית ואחורית */
#pdf-viewer.first-page,
#pdf-viewer.last-page {
    background-color: transparent;
}

/* מצב תצוגת עמוד יחיד (כריכות) */
#pdf-viewer.single-page {
    justify-content: center;
}

#pdf-viewer.single-page canvas {
    height: auto;
    width: auto;
    max-height: 100%;
    max-width: 60%;
}

/* מצב תצוגת שני עמודים */
#pdf-viewer.double-page {
    justify-content: center;
    gap: 0;
}

#pdf-viewer.double-page canvas {
    height: auto;
    width: auto;
    max-height: 100%;
    max-width: 49.5%;
    margin: 0;
    box-shadow: 0 0 0.625rem rgba(0, 0, 0, 0.2);
}

/* ניווט בין עמודים */
.page-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0.2rem auto;
    position: relative;
    margin-top: auto; /* דחוף לתחתית המיכל */
    white-space: nowrap;
    overflow: visible;
}

.nav-button {
    background: none;
    border: 1px solid var(--border-color);
    width: 1.875rem;
    height: 1.875rem;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s, color 0.3s, transform 0.2s;
    border-radius: var(--border-radius);
    margin: 0 0.625rem;
}

.nav-button:hover {
    background-color: #f0ece4;
    transform: translateY(-0.125rem);
}

.nav-button:active {
    transform: translateY(0);
}

.page-indicator {
    margin: 0 0.5rem;
    height: 1.875rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border-color);
    font-size: 1rem;
    border-radius: var(--border-radius);
    background-color: white;
    position: relative;
    width: auto; 
    padding: 0 10px;
}

.page-indicator input {
    width: 2.5rem; 
    font-size: 0.9rem;
    border: none;
    text-align: right;
    padding: 0;
    margin-right: 0.125rem;
    background: transparent;
}

.page-indicator input:focus {
    outline: none;
}

.total-pages {
    margin-left: 0.3125rem;
    color: var(--secondary-color);
}

.page-indicator input {
    width: 2.5rem; 
    font-size: 0.9rem;
    border: none;
    text-align: right;
    padding: 0;
    margin-right: 0.125rem;
    background: transparent;
}

.page-indicator input:focus {
    outline: none;
}

.total-pages {
    margin-left: 0.3125rem;
    color: var(--secondary-color);
}
/* כפתור הורדה */
.book-actions {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 0.5rem auto 1rem auto;
}

.action-button {
    background-color: rgb(10, 70,70); /* צבע טורקיז כרקע */
    color: white; /* טקסט לבן */
    border: none;
    padding: 8px 16px;
    font-size: 1rem;
    font-family: var(--font-family);
    cursor: pointer;
    min-width: 180px;
    height: auto;
    transition: background-color 0.3s, transform 0.2s;
    border-radius: var(--border-radius);
    display: inline-block; /* חשוב - להבטיח שזה נראה ככפתור */
    text-align: center; /* מרכוז הטקסט */
    font-weight: bold; /* מודגש */
}

.action-button:hover {
    background-color: rgba(10, 70,70, 0.8); /* גרסה בהירה יותר בהובר */
    transform: translateY(-2px); /* אפקט הרמה קטן */
}

.action-button:active {
    transform: translateY(0);
}

/* הודעת שגיאה בקפיצה לעמוד */
.page-error {
    position: absolute;
    top: -1.5625rem;
    left: 0;
    right: 0;
    font-size: 0.9rem;
    color: var(--error-color);
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.page-error.visible {
    opacity: 1;
}

/* הודעת ספר לא זמין */
.book-not-available {
    text-align: center;
    padding: 2rem;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: 0 0 0.625rem rgba(0, 0, 0, 0.1);
}

.book-not-available h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* פופ-אפ ההרשמה */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-content {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 37.5rem;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close-popup {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
    transition: color 0.3s;
}

.close-popup:hover {
    color: var(--text-color);
}

.popup-content h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.privacy-link {
    text-align: right;
    margin-bottom: 1rem;
}

.privacy-link a {
    font-size: 0.9rem;
    color: var(--secondary-color);
    text-decoration: underline;
}

.privacy-link a:hover {
    color: var(--text-color);
}



.rtl .close-popup {
    right: auto;
    left: 1rem;
}

.rtl .privacy-link {
    text-align: left;
}

/* מדיה קוורי להתאמה לגדלים שונים של מסך */
@media screen and (max-height: 50rem) { /* 800px */
    .book-cover {
        height: 85%;
    }
    
    .page-navigation, 
    .book-actions {
        position: relative;
        z-index: 5;
        background-color: var(--background-color);
        padding: 5px 0;
        width: 100%;
        margin: 0 auto;
    }
}

@media screen and (max-height: 37.5rem) { /* 600px */
    .book-cover {
        height: 80%;
    }
    
    .nav-button, 
    .page-indicator, 
    .action-button {
        height: 2.5rem;
    }
}

@media screen and (max-width: 48rem) { /* 768px */
    .book-cover {
        width: 95%;
    }
    
    .book-actions {
        justify-content: center;
    }
    
    .action-button {
        width: 100%;
        max-width: 18.75rem;
    }
    
    .page-indicator {
        width: 6.25rem;
    }
    
    #pdf-viewer.double-page canvas {
        max-width: 100%;
        margin: 0.3125rem 0;
    }
    
    #pdf-viewer.double-page {
        flex-direction: column;
        align-items: center;
    }
}

.rtl .page-indicator {
    direction: ltr;
}

.rtl .page-indicator * {
    direction: ltr;
}

