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

:root {
    --bg-color: #1a1a2e;
    --header-bg: #16213e;
    --text-color: #eee;
    --accent-color: #e94560;
    --secondary-color: #0f3460;
    --page-shadow: rgba(0, 0, 0, 0.4);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* RTL support for Hebrew */
body.rtl {
    direction: rtl;
}

header {
    background: var(--header-bg);
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    height: 50px;
}

h1 {
    font-size: 1.2rem;
    font-weight: 300;
    letter-spacing: 2px;
}

.language-toggle {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    background: var(--secondary-color);
    color: var(--text-color);
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.lang-btn:hover {
    background: var(--accent-color);
}

.lang-btn.active {
    background: var(--accent-color);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    overflow: hidden;
    min-height: 0;
}

.book-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#book {
    box-shadow: 0 10px 50px var(--page-shadow);
}

.page {
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.page canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.controls {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-shrink: 0;
    height: 50px;
}

.nav-btn {
    background: var(--secondary-color);
    color: var(--text-color);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.nav-btn:hover:not(:disabled) {
    background: var(--accent-color);
    transform: translateY(-2px);
}

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

.arrow {
    font-size: 1.1rem;
}

#page-info {
    font-size: 0.95rem;
    color: #aaa;
    min-width: 100px;
    text-align: center;
}

footer {
    background: var(--header-bg);
    padding: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: #666;
    flex-shrink: 0;
    height: 30px;
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--secondary-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loading-text {
    margin-top: 1rem;
    color: #aaa;
}

/* Responsive - mobile shows single page */
@media (max-width: 600px) {
    header {
        padding: 0.4rem 0.8rem;
        height: 45px;
    }

    h1 {
        font-size: 1rem;
    }

    .lang-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .controls {
        gap: 0.8rem;
        height: 45px;
    }

    .nav-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    #page-info {
        font-size: 0.8rem;
        min-width: 70px;
    }

    footer {
        height: 25px;
        font-size: 0.7rem;
    }
}

/* Page flip styling - make it larger */
.stf__parent {
    margin: 0 auto;
    width: 100% !important;
    max-width: none !important;
}

.stf__wrapper {
    width: 100% !important;
}

.stf__block {
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
}

/* Ensure book fills available space */
.stf__parent, .stf__wrapper, .stf__block {
    max-height: 100% !important;
}
