/* 基礎樣式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #DBE2EF 0%, #3F72AF 100%);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #F9F7F7;
    min-height: 100vh;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 頂部區域 */
.header {
    background: linear-gradient(135deg, #3F72AF 0%, #112D4E 100%);
    padding: 30px;
    text-align: center;
    color: #F9F7F7;
    position: relative;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(17, 45, 78, 0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.95;
    margin-bottom: 20px;
}

.header-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.content {
    padding: 30px;
    background: #F9F7F7;
}

/* 按鈕樣式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(45deg, #3F72AF, #112D4E);
    color: #F9F7F7;
    box-shadow: 0 4px 15px rgba(63, 114, 175, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(63, 114, 175, 0.4);
    background: linear-gradient(45deg, #4a7fb8, #1a3658);
}

.btn-secondary {
    background: #DBE2EF;
    color: #112D4E;
    border: 1px solid #3F72AF;
}

.btn-secondary:hover {
    background: #c8d4e6;
    border-color: #2d5a94;
}

.btn-success {
    background: #4CAF50;
    color: #F9F7F7;
}

.btn-success:hover {
    background: #45a049;
}

.btn-warning {
    background: #FF9800;
    color: #F9F7F7;
}

.btn-warning:hover {
    background: #e68900;
}

.btn-danger {
    background: #F44336;
    color: #F9F7F7;
}

.btn-danger:hover {
    background: #da190b;
}

.btn-info {
    background: #3F72AF;
    color: #F9F7F7;
}

.btn-info:hover {
    background: #2d5a94;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-large {
    padding: 15px 30px;
    font-size: 1.2rem;
    border-radius: 12px;
}

/* 題庫管理 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #DBE2EF;
}

.section-header h2 {
    color: #112D4E;
    font-size: 1.8rem;
}

.bank-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.bank-card {
    background: white;
    border: 2px solid #DBE2EF;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(63, 114, 175, 0.1);
    transition: all 0.3s ease;
}

.bank-card:hover {
    border-color: #3F72AF;
    box-shadow: 0 8px 25px rgba(63, 114, 175, 0.2);
}

.bank-card.selected {
    border-color: #3F72AF;
    background: linear-gradient(135deg, rgba(63, 114, 175, 0.05), rgba(17, 45, 78, 0.05));
}

.bank-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.bank-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #112D4E;
}

.bank-date {
    font-size: 0.9rem;
    color: #3F72AF;
}

.bank-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.bank-stat {
    text-align: center;
    padding: 10px;
    background: #F9F7F7;
    border-radius: 8px;
    border: 1px solid #DBE2EF;
}

.bank-stat h4 {
    font-size: 1.5rem;
    color: #3F72AF;
    margin-bottom: 5px;
}

.bank-stat p {
    font-size: 0.9rem;
    color: #112D4E;
}

.bank-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #3F72AF;
    font-size: 1.1rem;
    background: #F9F7F7;
    border-radius: 12px;
    border: 2px dashed #DBE2EF;
}

/* 全域統計 */
.global-stats {
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #3F72AF, #112D4E);
    color: #F9F7F7;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(63, 114, 175, 0.3);
}

.stat-card h3 {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.stat-card p {
    font-size: 1rem;
    opacity: 0.95;
}

/* 練習設置 */
.setup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.setup-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #DBE2EF;
    box-shadow: 0 2px 8px rgba(63, 114, 175, 0.1);
}

.setup-section h3 {
    color: #112D4E;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.bank-info {
    margin-bottom: 15px;
}

.bank-info p {
    margin-bottom: 8px;
    color: #3F72AF;
}

.bank-info strong {
    color: #112D4E;
}

.setup-section select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #DBE2EF;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    margin-bottom: 10px;
    color: #112D4E;
}

.setup-section select:focus {
    border-color: #3F72AF;
    outline: none;
    box-shadow: 0 0 0 2px rgba(63, 114, 175, 0.2);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 1rem;
    color: #112D4E;
}

.checkbox-label input {
    transform: scale(1.2);
    accent-color: #3F72AF;
}

.mode-info {
    margin-top: 10px;
    padding: 10px;
    background: #DBE2EF;
    border-radius: 6px;
    color: #112D4E;
    font-size: 0.9rem;
    min-height: 20px;
}

.start-practice {
    text-align: center;
    margin-top: 20px;
}

/* 練習區域 */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid #DBE2EF;
    box-shadow: 0 2px 8px rgba(63, 114, 175, 0.1);
}

.timer-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: #112D4E;
    font-family: 'Courier New', monospace;
}

.progress-info {
    font-weight: 500;
    color: #112D4E;
    font-size: 1.1rem;
}

.quiz-actions {
    display: flex;
    gap: 5px;
}

.progress-bar {
    background: #DBE2EF;
    height: 8px;
    border-radius: 4px;
    margin-bottom: 25px;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, #3F72AF, #112D4E);
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.question-card {
    background: white;
    border: 2px solid #DBE2EF;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(63, 114, 175, 0.1);
}

.question-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #DBE2EF;
}

.question-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.chapter-tag, .type-tag, .difficulty-tag {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.chapter-tag {
    background: #DBE2EF;
    color: #112D4E;
}

.type-tag {
    background: rgba(63, 114, 175, 0.15);
    color: #112D4E;
}

.difficulty-tag.easy {
    background: #e8f5e8;
    color: #2e7d32;
}

.difficulty-tag.medium {
    background: #fff3e0;
    color: #f57c00;
}

.difficulty-tag.hard {
    background: #ffebee;
    color: #d32f2f;
}

.question-stats {
    font-size: 0.9rem;
    color: #3F72AF;
    text-align: right;
}

.question-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #112D4E;
    margin-bottom: 25px;
    line-height: 1.6;
}

.options {
    list-style: none;
    margin-bottom: 20px;
}

.options li {
    background: #F9F7F7;
    margin: 12px 0;
    padding: 15px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #DBE2EF;
    font-size: 1rem;
    line-height: 1.5;
    color: #112D4E;
}

.options li:hover {
    background: #DBE2EF;
    transform: translateX(5px);
    border-color: #3F72AF;
}

.options li.selected {
    background: linear-gradient(135deg, #3F72AF, #112D4E);
    color: #F9F7F7;
    border-color: #3F72AF;
}

.options li.correct {
    background: linear-gradient(135deg, #4caf50, #388e3c);
    color: #F9F7F7;
    border-color: #4caf50;
}

.options li.wrong {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: #F9F7F7;
    border-color: #f44336;
}

.explanation {
    background: #F9F7F7;
    border-left: 4px solid #3F72AF;
    padding: 20px;
    border-radius: 0 8px 8px 0;
    margin-top: 20px;
    display: none;
}

.explanation.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

.explanation h4 {
    color: #112D4E;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.hint-section {
    background: #fff8e1;
    border-left: 4px solid #ff9800;
    padding: 20px;
    border-radius: 0 8px 8px 0;
    margin-top: 15px;
}

.hint-section h4 {
    color: #e65100;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 200px; }
}

.quiz-controls {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 20px;
}

/* 結果區域 */
.result-section {
    text-align: center;
    padding: 40px 20px;
}

.result-summary h2 {
    color: #112D4E;
    margin-bottom: 30px;
    font-size: 2.5rem;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.result-item {
    background: linear-gradient(135deg, #3F72AF, #112D4E);
    color: #F9F7F7;
    padding: 25px 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(63, 114, 175, 0.3);
}

.result-item h3 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.result-item p {
    font-size: 0.9rem;
    opacity: 0.95;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 模態框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 45, 78, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #F9F7F7;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
    box-shadow: 0 10px 30px rgba(17, 45, 78, 0.3);
}

.modal-large {
    max-width: 900px;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #DBE2EF;
    background: white;
}

.modal-header h3 {
    color: #112D4E;
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #3F72AF;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #DBE2EF;
    color: #112D4E;
}

.modal-body {
    padding: 25px;
    background: #F9F7F7;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #DBE2EF;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: white;
}

/* 上傳區域 */
.upload-area {
    text-align: center;
    padding: 40px;
    border: 2px dashed #DBE2EF;
    border-radius: 12px;
    background: white;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: #3F72AF;
    background: #F9F7F7;
}

.upload-icon {
    font-size: 3rem;
    color: #3F72AF;
    margin-bottom: 15px;
}

.upload-area h4 {
    color: #112D4E;
    margin-bottom: 10px;
}

.upload-area p {
    color: #3F72AF;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.upload-result {
    background: #e8f5e8;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.upload-result h4 {
    color: #155724;
    margin-bottom: 15px;
}

.bank-name-input {
    margin-top: 15px;
}

.bank-name-input label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #112D4E;
}

.bank-name-input input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #DBE2EF;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    color: #112D4E;
}

.bank-name-input input:focus {
    border-color: #3F72AF;
    outline: none;
    box-shadow: 0 0 0 2px rgba(63, 114, 175, 0.2);
}

/* 詳細統計 */
.stats-tabs {
    display: flex;
    border-bottom: 1px solid #DBE2EF;
    margin-bottom: 20px;
    background: white;
    border-radius: 8px 8px 0 0;
}

.stats-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #3F72AF;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.stats-tab.active {
    color: #112D4E;
    border-bottom-color: #3F72AF;
    font-weight: 500;
    background: #F9F7F7;
}

.stats-tab:hover {
    color: #112D4E;
    background: #DBE2EF;
}

.stats-content {
    margin-bottom: 25px;
}

.chapter-stats {
    display: grid;
    gap: 15px;
}

.chapter-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3F72AF;
    box-shadow: 0 2px 8px rgba(63, 114, 175, 0.1);
}

.chapter-name {
    font-weight: 500;
    color: #112D4E;
    margin-bottom: 8px;
}

.chapter-progress {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #3F72AF;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        margin: 0;
        border-radius: 0;
    }
    
    .content {
        padding: 20px 15px;
    }
    
    .header {
        padding: 20px 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .header-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .bank-list {
        grid-template-columns: 1fr;
    }
    
    .setup-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .result-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quiz-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .quiz-controls {
        flex-direction: column;
    }
    
    .result-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .result-stats {
        grid-template-columns: 1fr;
    }
    
    .question-title {
        font-size: 1.2rem;
    }
    
    .options li {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
}

/* 動畫效果 */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.slide-up {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.bounce-in {
    animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* 滾動條樣式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #DBE2EF;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #3F72AF;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #112D4E;
}

/* 選中狀態 */
::selection {
    background: rgba(63, 114, 175, 0.2);
}

/* 焦點狀態 */
.btn:focus,
select:focus,
input:focus {
    outline: 2px solid rgba(63, 114, 175, 0.5);
    outline-offset: 2px;
}

/* 載入動畫 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(249,247,247,.3);
    border-radius: 50%;
    border-top-color: #3F72AF;
    animation: spin 1s ease-in-out infinite;
}

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