/* 變數定義 */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #ec489a;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
}

.dark-theme {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --gray-50: #111827;
    --gray-100: #1f2937;
    --gray-200: #374151;
    --gray-300: #4b5563;
    --gray-400: #6b7280;
    --gray-500: #9ca3af;
    --gray-600: #d1d5db;
    --gray-700: #e5e7eb;
    --gray-800: #f3f4f6;
    --gray-900: #f9fafb;
}

/* 主容器 */
.mbti-test-container,
.mbti-result-container {
    max-width: 900px;
    margin: 2rem auto;
    background: var(--gray-50);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: fadeInUp 0.5s ease;
}

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

/* 頭部區域 */
.mbti-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 2.5rem;
    text-align: center;
    color: white;
}

.mbti-header h2 {
    font-size: 2rem;
    margin: 0 0 0.5rem 0;
    font-weight: 700;
}

.mbti-header p {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

/* 進度條 */
.mbti-progress {
    padding: 1.5rem 2rem 0 2rem;
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* 題目卡片 */
.question-item {
    padding: 2rem;
    animation: slideIn 0.4s ease;
}

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

.question-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 2rem;
    line-height: 1.4;
}

/* 選項按鈕 */
.options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.option {
    flex: 1;
    min-width: 200px;
    padding: 1rem 1.5rem;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-weight: 500;
    color: var(--gray-700);
}

.option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option input {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.option.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    color: white;
}

/* 導航按鈕 */
.navigation-buttons {
    padding: 0 2rem 2rem 2rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.navigation-buttons button {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.prev-btn, .next-btn {
    background: var(--gray-200);
    color: var(--gray-700);
}

.prev-btn:hover:not(:disabled),
.next-btn:hover:not(:disabled) {
    background: var(--gray-300);
    transform: translateY(-2px);
}

.prev-btn:disabled,
.next-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.submit-btn {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    flex: 1;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 結果頁面 */
.result-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 2.5rem;
    text-align: center;
    color: white;
}

.personality-type {
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    margin: 1rem 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.personality-name {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.personality-title {
    font-size: 1.125rem;
    opacity: 0.9;
}

/* 結果區塊 */
.result-section {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--gray-200);
}

.result-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-section p {
    color: var(--gray-600);
    line-height: 1.6;
}

.result-section ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.result-section ul li {
    background: var(--gray-100);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    color: var(--gray-700);
}

/* 分數圖表 */
.scores-container {
    padding: 2rem;
    background: var(--gray-100);
}

.score-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.score-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-weight: 500;
    color: var(--gray-700);
}

.score-bar-bg {
    height: 12px;
    background: var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: var(--radius);
    transition: width 1s ease;
    position: relative;
    overflow: hidden;
}

.score-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}

/* 操作按鈕 */
.result-actions {
    padding: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.retake-btn, .share-btn {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.retake-btn {
    background: var(--gray-200);
    color: var(--gray-700);
}

.retake-btn:hover {
    background: var(--gray-300);
    transform: translateY(-2px);
}

.share-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 模態框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--gray-50);
    margin: 5% auto;
    padding: 0;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.4s ease;
}

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

.close {
    position: sticky;
    top: 0;
    right: 0;
    float: right;
    font-size: 28px;
    font-weight: bold;
    color: var(--gray-500);
    cursor: pointer;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    transition: all 0.3s ease;
}

.close:hover {
    color: var(--danger);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .mbti-test-container,
    .mbti-result-container {
        margin: 1rem;
        border-radius: var(--radius-lg);
    }
    
    .mbti-header,
    .result-header {
        padding: 1.5rem;
    }
    
    .mbti-header h2 {
        font-size: 1.5rem;
    }
    
    .question-text {
        font-size: 1.25rem;
    }
    
    .question-item,
    .result-section {
        padding: 1.5rem;
    }
    
    .options {
        flex-direction: column;
    }
    
    .option {
        min-width: auto;
    }
    
    .personality-type {
        font-size: 2.5rem;
    }
    
    .personality-name {
        font-size: 1.25rem;
    }
    
    .navigation-buttons {
        flex-direction: column;
    }
    
    .result-actions {
        flex-direction: column;
    }
}

/* 加載動畫 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

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

/* 工具提示 */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::before {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.tooltip:hover::before {
    opacity: 1;
}

/* 頁腳 */
.mbti-footer {
    padding: 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-400);
    border-top: 1px solid var(--gray-200);
}