/* 基礎重置 */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #e6e7e8;
}

/* 頂部 Logo Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-image: linear-gradient(120deg, #66a6ff 0%, #89f7fe 50%, #66a6ff 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    padding: 0 10px;
    z-index: 1000;
}

.top-bar .logo {
    height: 30px;
    width: auto;
}
.book-context {
    padding: 50px 0 75px 0;
    height:100%;
}
/* 書本容器 */
.book-viewer {
    position: relative;
    width: 100%;
    height: calc(100vh - 125px);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 2px 0 2px 0;
}

/* 頁面容器 */
.book-pages {
    position: relative;
    display: flex;
    gap: 30px; /* 增加頁面間距 */
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* 單頁樣式 */
.book-page {
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.3s ease;
    min-height: 2em;
    min-width: 2em;
}

/* 頁面圖片 */
.book-page img {
    max-height: calc(100vh - 150px); /* 減去頂部和底部 bar 的高度 */
    width: auto;
    display: block;
    border-radius: 4px;
}

/* 控制欄 */
.book-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background-image: linear-gradient(120deg, #66a6ff 0%, #89f7fe 50%, #66a6ff 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* 頁碼資訊 */
.page-info {
    margin-inline: 10px;
    min-width: 30px;
    font-size: 14px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: #fff;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 書名 */
.book-title {
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap; /* 不換行 */
    overflow: hidden; /* 隱藏溢出的內容 */
    text-overflow: ellipsis; /* 使用省略號表示溢出 */
}

/* 響應式設計 - 直向模式 */
@media (orientation: portrait) {
    .book-pages {
        flex-direction: column;
        gap: 0;
        padding: 10px;
    }
    
    .book-page img {
        max-width: 95vw;
        height: auto;
        max-height: calc(100vh - 150px);
    }
}

/* 響應式設計 - 橫向模式 */
@media (orientation: landscape) {
    .book-pages {
        flex-direction: row;
        position: relative;
    }
    
    /* 當有兩頁時才顯示分隔線 */
    .book-pages:has(.book-page + .book-page)::after {
        content: '';
        position: absolute;
        left: 50%;
        top: 0;
        bottom: 0;
        width: 2px;
        background: linear-gradient(
            to bottom,
            transparent,
            rgba(0, 0, 0, 0.1) 20%,
            rgba(0, 0, 0, 0.1) 80%,
            transparent
        );
        transform: translateX(-50%);
        box-shadow: -1px 0 3px rgba(0, 0, 0, 0.1);
    }
    
    .book-page img {
        max-height: calc(100vh - 150px);
        width: auto;
    }
}

/* 載入動畫 */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}