html{
  margin: 0;
  padding: 0;
  height: 100%;
}

footer {
  width: 100%;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  background-color: #FAFAFA;
}

.footer-inner {
  max-width: 960px;
  width: 100%;
  text-align: center;
  margin: 0 auto;
}

.wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

section {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* 全局樣式 */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    height: 100%;
    background-image: url('/static/images/bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* Header 樣式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 30px;
    background-color: white;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
    height: 72px;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    box-sizing: border-box;
}

/* Logo */
.logo img {
    height: 35px;
    width: auto;
}

/* 按鈕區塊 */
.login {
    display: flex;
    align-items: center;
}

/* Quiz & Login 按鈕 */
.quiz-btn img,
.login-btn img {
    height: 35px;
    width: auto;
    max-width: 100px;
    cursor: pointer;
    margin-right: 30px;
}

/* 登入按鈕容器 */
.login-container {
    position: relative;
    display: inline-block;
}

/* 下拉選單 */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
    padding: 10px;
    min-width: 120px;
    z-index: 1000;
}

.dropdown-menu p {
    margin: 0;
    padding: 10px;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #ddd;
    user-select: none;
}

.logout-btn {
    width: 100%;
    padding: 8px;
    border: none;
    background: red;
    color: white;
    cursor: pointer;
    border-radius: 3px;
    text-align: center;
}

.logout-btn:hover {
    background: darkred;
}

/* 主視覺區塊 */
.hero {
    margin-top: 90px;
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.hero img {
    width: 65%;
    height: auto;
    object-fit: cover;
}

/* 圖片預覽區塊 */
.image-preview {
    text-align: center;
    padding: 40px 20px;
}

/* 預覽標題 */
.preview-header {
    display: flex;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    justify-content: center;
    align-items: center;
    width: 100%;
    text-align: center;
}

.preview-header img {
    height: 35px;
    width: auto;
}

/* 重新選擇圖片按鈕 */
.btn-reselect {
    border: none;
    background: none;
    cursor: pointer;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.btn-reselect img {
    height: 40px;
    width: auto;
}

/* 預覽框 */
.preview-box {
    width: 90%;
    max-width: 800px;
    height: auto;
    margin: 20px auto;
    border: 2px solid #D5F2F7;
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 10px;
}

.preview-box-modal {
    max-height: 50vh;
    overflow: hidden;
}

.preview-box-modal img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-height: 50vh;
}

.uploaded-image {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* 上傳圖片預覽 */
.uploaded-image img {
    max-width: 100%; /* 修正: 確保圖片不會超出容器 */
    height: auto;
    object-fit: contain;
}

/* 原始題目區塊 */
.original-question {
    text-align: center;
    padding: 40px 20px;
}

/* 標題 */
.question-header img {
    height: 35px;
}

/* 題目顯示框 */
.question-box {
    position: relative; /* 確保內部按鈕可以絕對定位 */
    display: flex;
    align-items: flex-start; /* 修正: 讓checkbox從頂部對齊 */
    width: 90%;
    max-width: 800px;
    margin: auto;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px; /* 增加間距 */
}


/* 選擇題型區塊 */
.question-type {
    text-align: center;
    padding: 40px 20px;
    background-color: #FAFAFA;
}

/* 標題 */
.question-type-header img {
    height: 35px;
}

/* 選擇題型 + 箭頭 + 生成題目按鈕的整體排列 */
.question-type-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap; /* 增加: 讓內容在空間不足時可以換行 */
}

/* 題型按鈕 */
.question-btn {
    border: none;
    background: none;
    cursor: pointer;
}

/* 題型按鈕圖片 */
.question-btn img {
    width: auto; 
    height: 85px;
}

/* 箭頭 */
.arrow img {
    width: 30px;
    height: auto;
}

/* 生成題目按鈕 */
.generate-button .btn-generate {
    border: none;
    background: none;
    cursor: pointer;
}

.btn-generate img {
    width: auto;
    height: 85px;
}

/* 生成題目及保留題目區塊 */
.generated-section {
    display: none;
    text-align: center;
    padding: 40px 20px;
    background-color: #FAFAFA;
}

/* 讓三個主要區塊（生成、按鈕、保留）水平對齊 */
.question-container {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.generated-container{
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 350px;
    max-height: 600px;
}

/* 生成的題目顯示框（左側） */
.generated-questions {
    width: 100%;
    flex-grow: 1;
    padding: 20px;
    border-radius: 10px;
    background-color: #FFFFFF;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    box-sizing: border-box;
}

/* 保留與移除按鈕（中間） */
.question-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

/* 按鈕 */
.btn-retain, .btn-remove {
    border: none;
    background: none;
    cursor: pointer;
}

.btn-retain img, .btn-remove img {
    height: 70px;
    width: auto;
}

/* 保留的題目區塊 + 匯出按鈕（右側） */
.saved-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 350px;
    max-height: 600px;
}

/* 保留的題目顯示框 */
.saved-questions {
    width: 100%;
    flex-grow: 1;
    padding: 20px;
    border-radius: 10px;
    background-color: #EAF1FB;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    box-sizing: border-box;
}

/* 保留的題目標題 */
.saved-questions h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

/* 匯出題目按鈕容器 */
.export-wrapper {
    width: 390px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

/* 匯出題目按鈕 */
.btn-export {
    width: 390px;
    height: auto;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

/* 讓圖片填滿整個按鈕 */
.btn-export img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 隱藏狀態 */
.hidden {
    display: none;
}

.checkbox {
    padding-top: 2px;
}

/* 讓 checkbox 看起來像 radio button */
.checkbox input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #ccc;
    outline: none;
    cursor: pointer;
    position: relative;
    background-color: white;
    flex-shrink: 0; /* 防止 checkbox 被壓縮 */
}

/* 當 checkbox 被選取時，顯示內部圓點 */
.checkbox input[type="checkbox"]:checked {
    border-color: #4285f4;
}

/* 內部圓點樣式 */
.checkbox input[type="checkbox"]::after {
    content: "";
    width: 10px;
    height: 10px;
    background-color: #4285f4;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

/* 當 checkbox 被選取時，顯示內部圓點 */
.checkbox input[type="checkbox"]:checked::after {
    display: block;
}

.generated-questions .question-box {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    box-shadow: none;
    border-bottom: 1px solid #eee;
    border-radius: 0;
}
.saved-questions .question-box {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    box-shadow: none;
    border-bottom: 1px solid #ddd;
    border-radius: 0;
    background: transparent;
}


/* 內部的數學公式或內容樣式 */
.generated-content {
    text-align: left;
    line-height: 1.6;
    font-size: 16px;
    color: #727a7c;
    flex: 1; 
    word-break: break-word; /* 增加，確保長單詞或網址能正常換行 */
}

.modal {
    position: fixed;
    z-index: 1000;  
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5); 
    display: flex;
    justify-content: center;
    align-items: center;
}


.modal-content {
    background-color: #fff;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal-content h2 {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 10px;
}

.paste-box {
    width: 100%;
    height: 200px;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background-color: #f8f8f8;
    transition: background-color 0.3s ease-in-out;
    margin-bottom: 10px;
    box-sizing: border-box;
}

/* 拖曳時變色 */
.paste-box.dragover {
    background-color: #e0e0e0;
}

.paste-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap; /* 增加，讓按鈕可以換行 */
}

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 10px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.btn-primary { background-color: #007BFF; color: white; }
.btn-secondary { background-color: #ccc; }
.btn-danger { background-color: #dc3545; color: white; }


.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

/* Loading 遮罩 */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* 旋轉 Loading 圖案 */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 0, 0, 0.2);
    border-top-color: #007BFF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 旋轉動畫 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 顯示 Loading 動畫 */
.show-loading {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.flash {
    animation: flash 0.5s ease-in-out 3;
}
@keyframes flash {
    0%, 100% { background-color: #f9f9f9; }
    50% { background-color: #ffffcc; }
}

/* 確認生成範圍區塊 */
.confirm-range {
    text-align: center;
    padding: 40px 20px;
}

/* 標題 */
.range-header img {
    height: 35px;
}

/* 調整下拉選單容器樣式 */
.range-selection {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap; /* 增加: 讓選單在空間不足時可以換行 */
}

/* 基本樣式，讓所有選單保持一致 */
.range-selection select {
    font-size: 16px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
    min-width: 150px; /* 設定最小寬度，避免選單過窄 */
}

/* 禁用時的樣式 */
.range-selection select:disabled {
    background-color: #f0f0f0;
    color: #888;
    cursor: not-allowed;
}


/* 當滑鼠懸停時變色 */
.range-selection select:hover {
    border-color: #666;
}

/* 選擇測驗設計區塊 */
.quiz-selection {
    text-align: center;
    padding: 30px 20px;
    background-color: #FFFFFF;
    border-radius: 10px;
    max-width: 600px;
    margin: 0 auto;
    margin-bottom: 50px !important;
}

/* 標題圖片 */
.quiz-header img {
    height: 35px;
}

/* Radio 按鈕群組 - 改為水平排列 */
.radio-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px; /* 按鈕之間的間距 */
    margin-top: 15px;
    font-size: 18px;
    color: #333;
    flex-wrap: wrap; /* 增加: 讓選項可以換行 */
}

/* 隱藏原生 Radio 按鈕 */
.radio-group input[type="radio"] {
    display: none;
}

/* Radio 按鈕與標籤的樣式 */
.radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    border: 2px solid #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background-color: white;
}

/* 被選取時的樣式 */
.radio-group input[type="radio"]:checked + .radio-label {
    border-color: #007BFF;
    background-color: #EAF1FB;
    font-weight: bold;
    color: #007BFF;
}

/* 滑鼠懸停時的效果 */
.radio-label:hover {
    border-color: #666;
}
/* 我的試卷按鈕 */
.quiz-btn {
    display: inline-block;
    margin-right: 20px; /* 與登入按鈕保持適當間距 */
}

/* 我的試卷按鈕圖片 */
.quiz-btn img {
    height: 35px;
    width: auto;
    cursor: pointer;
    transition: opacity 0.2s ease-in-out;
}

/* 滑鼠懸停時增加透明度變化 */
.quiz-btn:hover img {
    opacity: 0.8;
}

/* ==========================================================================
   ⭐ RWD 響應式設計修正 (手機版樣式)
   ========================================================================== */
@media (max-width: 768px) {

    /* --- 整體 Section 邊距調整 --- */
    section {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* --- 頂部 Header 調整 --- */
    .header {
        padding: 10px 15px;
        height: auto;
    }

    .logo img {
        height: 30px;
    }

    .quiz-btn img,
    .login-btn img {
        height: 30px;
        margin-right: 10px;
    }
    .quiz-btn {
        margin-right: 10px;
    }

    /* --- 主視覺區塊調整 --- */
    .hero {
        margin-top: 72px;
        height: auto;
        padding: 20px 0;
    }

    .hero img {
        width: 95%;
    }

    /* --- 圖片預覽區塊調整 --- */
    .preview-header {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .preview-header img {
        height: 30px;
    }
    
    .btn-reselect {
        position: static;
        transform: none;
    }

    .btn-reselect img {
        position: static;
        height: 38px;
    }

    /* ---【關鍵修正 1】: 範圍選擇 (下拉選單) --- */
    .range-selection {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .range-selection select {
        width: 90%;
        max-width: 400px;
    }

    /* ---【關鍵修正 2】: 測驗設計 Radio 按鈕調整 --- */
    .quiz-selection {
        max-width: 100%;
    }

    .radio-group {
        flex-direction: column;
        gap: 15px;
    }

    .radio-label {
        width: 80%;
        justify-content: center;
    }

    /* ---【關鍵修正 3】: 題型選擇按鈕 --- */
    .question-type-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .question-type-options {
        display: flex;
        justify-content: center;
        gap: 10px;
        width: 100%;
        flex-wrap: wrap;
    }

    .question-btn img {
        height: 60px;
    }

    .arrow img {
        transform: rotate(90deg);
        width: 25px;
    }

    .btn-generate img {
        height: 70px;
    }

    /* ---【關鍵修正 4】: 生成題目區塊 --- */
    .question-container {
        flex-direction: column;
        align-items: center;
        gap: 25px;
    }

    .generated-container,
    .saved-container {
        width: 100%;
        max-width: 450px;
        max-height: 400px;
    }

    .question-actions {
        flex-direction: row;
        gap: 20px;
    }
    
    .btn-retain img,
    .btn-remove img {
        transform: rotate(90deg); 
        height: 60px; 
    }

    .export-wrapper,
    .btn-export {
        width: 100%;
        max-width: 490px;
    }
}

