body {
    font-family: Arial, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    line-height: 1.6;
    background-color: #f5f5f5;
}

.container {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
}

h2 {
    color: #444;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

select, input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 16px;
}

select:focus, input:focus {
    border-color: #4CAF50;
    outline: none;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 10px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #45a049;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

#imageContainer, #fullscreenImageContainer {
    margin-top: 20px;
}

#imageContainer img {
    width: 100%;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.vertical-mode img {
    margin-bottom: 10px;
}

.horizontal-mode {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 0;
    scroll-behavior: smooth;
}

.horizontal-mode img {
    width: auto;
    height: 100vh;
    max-height: 90vh;
    margin-right: 10px;
    flex-shrink: 0;
    border-radius: 4px;
}

.loading {
    text-align: center;
    margin: 20px 0;
    font-weight: bold;
    color: #666;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 4px solid rgba(76, 175, 80, 0.2);
    border-radius: 50%;
    border-top-color: #4CAF50;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

.status {
    margin-top: 15px;
    padding: 12px;
    border-radius: 4px;
    font-weight: bold;
}

.success {
    background-color: #dff0d8;
    color: #3c763d;
    border-left: 4px solid #3c763d;
}

.error {
    background-color: #f2dede;
    color: #a94442;
    border-left: 4px solid #a94442;
}

.info {
    background-color: #d9edf7;
    color: #31708f;
    border-left: 4px solid #31708f;
}

.progress-container {
    margin-top: 15px;
}

.progress-bar {
    height: 20px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: #4CAF50;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    margin-top: 5px;
    font-size: 14px;
    color: #666;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
}

/* 調整章節導航樣式 */
.chapter-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.nav-button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.nav-button:hover {
    background-color: #45a049;
}

.nav-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.chapter-info {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 4px;
    margin-bottom: 20px;
}

.options-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.option-group {
    flex: 1;
    min-width: 200px;
}

.image-count-info {
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

.top-nav {
    position: sticky;
    top: 0;
    background-color: #fff;
    z-index: 100;
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* 全螢幕模式相關樣式 */
.fullscreen-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 1000;
    overflow: auto;
    padding: 0;
    margin: 0;
}

.fullscreen-content {
    padding: 60px 0 0 0; /* 只保留頂部的padding，用於頂部控制欄 */
    margin: 0;
    width: 100%;
}

.fullscreen-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: space-between; /* 改為 space-between 來分散元素 */
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1001;
    transition: opacity 0.3s ease;
    opacity: 1;
}

.fullscreen-controls.hidden {
    opacity: 0;
    pointer-events: none;
}

.chapter-title {
    color: white;
    font-size: 18px;
    margin: 0; /* 移除左右邊距 */
    font-weight: bold;
    text-align: center; /* 確保文字居中 */
    flex: 1; /* 讓標題佔據中間空間 */
    overflow: hidden; /* 防止文字溢出 */
    text-overflow: ellipsis; /* 文字過長時顯示省略號 */
    white-space: nowrap; /* 防止文字換行 */
}

.close-button {
    position: static; /* 改為靜態定位而非絕對定位 */
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 0 10px; /* 增加水平內邊距 */
    margin: 0;
    line-height: 1;
    min-width: 44px; /* 確保有足夠的點擊區域 */
    text-align: center;
}

.close-button:hover {
    color: #ff5555;
    background: none;
}

.arrow-left, .arrow-right {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.arrow-left {
    border-right: 10px solid white;
    margin-right: 5px;
}

.arrow-right {
    border-left: 10px solid white;
    margin-left: 5px;
}

/* 章節內容標題區域樣式 */
.chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chapter-header h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* 全螢幕按鈕樣式 */
.fullscreen-button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    margin: 0 10px;
    min-width: 44px;
}

.fullscreen-button:hover {
    background-color: #45a049;
}

.fullscreen-icon {
    font-size: 18px;
}

.checkbox-container {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 16px;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #eee;
    border-radius: 4px;
}

.checkbox-container:hover input ~ .checkmark {
    background-color: #ccc;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: #4CAF50;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* 全螢幕模式下的特殊樣式 */
#fullscreenImageContainer {
    margin: 0;
    padding: 0;
    width: 100%;
    /* 添加以下屬性以消除可能的空白 */
    font-size: 0; /* 消除行內元素間的空白 */
    line-height: 0; /* 消除行高導致的空白 */
}

#fullscreenImageContainer.vertical-mode {
    max-width: 100%; /* 移除最大寬度限制 */
    margin: 0;
    padding: 0;
    display: flex; /* 使用 flex 布局 */
    flex-direction: column; /* 垂直排列 */
}

#fullscreenImageContainer.vertical-mode img {
    margin: 0; /* 移除圖片間距 */
    box-shadow: none; /* 移除陰影 */
    border-radius: 0; /* 移除圓角 */
    width: 100%;
    display: block; /* 確保圖片作為塊級元素 */
}

#fullscreenImageContainer.horizontal-mode {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-behavior: smooth;
    align-items: center;
    height: calc(100vh - 60px); /* 只減去頂部控制欄的高度 */
    padding: 0;
    margin: 0;
    gap: 0; /* 確保 flex 項目之間沒有間隙 */
}

#fullscreenImageContainer.horizontal-mode img {
    width: auto;
    height: calc(100vh - 60px); /* 只減去頂部控制欄的高度 */
    max-height: 100vh;
    margin: 0; /* 移除圖片間距 */
    flex-shrink: 0;
    box-shadow: none; /* 移除陰影 */
    border-radius: 0; /* 移除圓角 */
    display: block; /* 確保圖片作為塊級元素 */
}

/* 添加全螢幕模式下的切換按鈕 */
.toggle-controls-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1002;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.toggle-controls-button:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.7);
}


/* 為導航按鈕添加容器 */
.nav-buttons-container {
    display: flex;
    align-items: center;
}

/* 媒體查詢優化手機顯示 */
@media (max-width: 768px) {
    .fullscreen-controls {
        padding: 10px;
    }

    .chapter-title {
        font-size: 14px;
        max-width: 60%; /* 限制標題寬度 */
    }

    .nav-button {
        padding: 8px 12px;
        font-size: 14px;
    }

    .close-button {
        font-size: 24px;
        padding: 0 8px;
    }
}

/* 更小的螢幕尺寸進一步優化 */
@media (max-width: 480px) {
    .chapter-title {
        max-width: 50%; /* 更小的螢幕進一步限制標題寬度 */
        font-size: 12px;
    }

    .nav-button {
        padding: 6px 10px;
        font-size: 12px;
    }
}
