/* 基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #5f7a73;
    --primary-light: #5eead4;
    --primary-dark: #4a635d;
    --accent-color: #f472b6;
    --accent-light: #f9a8d4;
    --bg-gradient: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: #333;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 15px;
    padding-bottom: 30px;
}

/* 頂部標題 */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5px;
    margin-bottom: 10px;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.app-title-icon {
    font-size: 24px;
}

/* 進度條 */
.progress-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    position: relative;
    padding: 0 10px;
}

.progress-bar::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 15%;
    right: 15%;
    height: 3px;
    background: #e0e0e0;
    border-radius: 2px;
    z-index: 0;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e8e8e8;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.progress-step.active .step-number,
.progress-step.completed .step-number {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(45, 212, 191, 0.4);
}

.step-label {
    font-size: 11px;
    color: #999;
    font-weight: 500;
}

.progress-step.active .step-label {
    color: var(--primary-color);
    font-weight: 600;
}

/* 步驟內容 */
.step-content {
    display: none;
    background: white;
    border-radius: 24px;
    padding: 30px 25px;
    box-shadow: var(--card-shadow);
    animation: fadeIn 0.3s ease;
}

.step-content.active {
    display: block;
}

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

h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #333;
    font-size: 20px;
    font-weight: 600;
}

/* 問題組 */
.question-group {
    margin-bottom: 25px;
}

.question-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 15px;
    color: #333;
}

.hint {
    text-align: center;
    color: #888;
    margin-bottom: 15px;
    font-size: 13px;
}

/* 選項按鈕 */
.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (max-width: 400px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
}

.option-btn {
    padding: 14px 16px;
    border: 2px solid #f0f0f0;
    border-radius: 14px;
    background: #fafafa;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    color: #555;
}

.option-btn:hover {
    border-color: var(--primary-light);
    background: #f0fdfa;
}

.option-btn.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    color: var(--primary-dark);
    font-weight: 600;
}

/* 按鈕 */
.next-btn, .back-btn, .restart-btn {
    padding: 14px 36px;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.next-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
}

.next-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(45, 212, 191, 0.4);
}

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

.back-btn {
    background: #f5f5f5;
    color: #666;
}

.back-btn:hover {
    background: #ebebeb;
}

.btn-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 25px;
}

/* 上傳區域 */
.upload-section {
    text-align: center;
}

/* 上傳選項按鈕 */
.upload-options {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
}

.upload-option-btn {
    flex: 1;
    max-width: 140px;
    padding: 20px 15px;
    border: 2px solid #f0f0f0;
    border-radius: 16px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-option-btn:hover {
    border-color: var(--primary-color);
    background: #f0fdfa;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(45, 212, 191, 0.2);
}

.upload-option-btn:active {
    transform: scale(0.98);
}

.upload-option-btn .option-icon {
    font-size: 32px;
}

.upload-option-btn .option-text {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.upload-tips {
    background: linear-gradient(135deg, #f0fdfa 0%, #e6fffa 100%);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 20px;
    text-align: left;
    border: 1px solid #ccfbf1;
}

.upload-tips h3 {
    font-size: 13px;
    color: var(--primary-dark);
    margin-bottom: 10px;
    font-weight: 600;
}

.upload-tips ul {
    list-style: none;
    font-size: 12px;
    color: #666;
}

.upload-tips li {
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
}

.upload-tips li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.upload-area {
    border: 2px dashed #d0d0d0;
    border-radius: 20px;
    padding: 35px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    background: #fafafa;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #f0fdfa;
}

.upload-area.has-image {
    border-style: solid;
    border-color: var(--primary-color);
    padding: 10px;
    background: white;
}

.upload-placeholder {
    color: #999;
}

.upload-icon {
    font-size: 42px;
    margin-bottom: 12px;
}

.upload-placeholder p {
    margin: 5px 0;
    font-size: 14px;
}

.upload-placeholder .small {
    font-size: 12px;
    color: #bbb;
}

.preview-image {
    max-width: 100%;
    max-height: 280px;
    border-radius: 16px;
}

.change-photo-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
}

/* Loading */
.loading-section {
    text-align: center;
    padding: 50px 20px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-section p {
    color: #555;
    margin: 8px 0;
    font-size: 15px;
    font-weight: 500;
}

.loading-section .small {
    font-size: 13px;
    color: #888;
}

/* 結果頁面 */
.result-section h2 {
    margin-bottom: 25px;
}

.overall-score {
    text-align: center;
    margin-bottom: 30px;
}

.score-circle {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    color: white;
    box-shadow: 0 8px 30px rgba(45, 212, 191, 0.35);
}

.score-number {
    font-size: 42px;
    font-weight: bold;
}

.score-label {
    font-size: 12px;
    opacity: 0.9;
}

/* 分析詳情 */
.analysis-details {
    margin-bottom: 25px;
}

.analysis-details h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #333;
    font-weight: 600;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 400px) {
    .analysis-grid {
        grid-template-columns: 1fr;
    }
}

.analysis-item {
    background: #f8fafb;
    border-radius: 14px;
    padding: 14px;
    border: 1px solid #f0f0f0;
}

.analysis-item .label {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
    font-weight: 500;
}

.analysis-item .score-bar {
    height: 6px;
    background: #e8e8e8;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.analysis-item .score-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.analysis-item .score-fill.good {
    background: linear-gradient(90deg, #34d399 0%, #10b981 100%);
}

.analysis-item .score-fill.medium {
    background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
}

.analysis-item .score-fill.poor {
    background: linear-gradient(90deg, #f87171 0%, #ef4444 100%);
}

.analysis-item .score-text {
    font-size: 11px;
    color: #666;
    text-align: right;
}

/* AI 建議 */
.ai-suggestion {
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #99f6e4;
}

.ai-suggestion h3 {
    font-size: 15px;
    margin-bottom: 12px;
    color: var(--primary-dark);
    font-weight: 600;
}

.ai-suggestion p {
    font-size: 13px;
    line-height: 1.7;
    color: #555;
}

/* 產品推薦 */
.product-recommendations h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #333;
    font-weight: 600;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

@media (max-width: 360px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
}

.product-card {
    background: white;
    border: 1px solid #f0f0f0;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.product-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.product-info {
    padding: 12px;
}

.product-tag {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
    font-weight: 500;
}

.product-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 15px;
    color: var(--accent-color);
    font-weight: bold;
    margin-bottom: 10px;
}

.product-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s;
}

.product-btn:hover {
    background: var(--primary-dark);
}

.restart-btn {
    display: block;
    margin: 20px auto 0;
    background: #f0f0f0;
    color: #666;
}

.restart-btn:hover {
    background: #e5e5e5;
}

/* 黑眼圈類型顯示 */
.darkcircle-type-display {
    margin-bottom: 20px;
}

.darkcircle-badge {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    padding: 14px 18px;
    border-radius: 14px;
    color: white;
}

.darkcircle-icon {
    font-size: 26px;
    margin-right: 14px;
}

.darkcircle-info {
    display: flex;
    flex-direction: column;
}

.darkcircle-label {
    font-size: 11px;
    opacity: 0.9;
    margin-bottom: 3px;
}

.darkcircle-type {
    font-size: 16px;
    font-weight: bold;
}

/* 底部安全區域 */
.container {
    padding-bottom: 30px;
}

/* 手機適配 */
@media (max-width: 500px) {
    .container {
        padding: 12px;
        padding-bottom: 25px;
    }

    .step-content {
        padding: 25px 20px;
        border-radius: 20px;
    }

    h2 {
        font-size: 18px;
    }

    .option-btn {
        padding: 12px 14px;
        font-size: 13px;
    }

    .btn-group {
        flex-direction: column;
    }

    .next-btn, .back-btn {
        width: 100%;
    }
}

/* iPhone X 等有底部安全區域的裝置 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .container {
        padding-bottom: calc(25px + env(safe-area-inset-bottom));
    }
}

/* 返回按鈕 */
.back-to-home {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    padding: 10px 0;
    margin-bottom: 10px;
    transition: color 0.2s;
}

.back-to-home:hover {
    color: var(--primary-color);
}

.back-to-home svg {
    width: 20px;
    height: 20px;
}
