/* AI 体质评估 - 页面专属样式 */
/* 复用 style.css 中的 CSS 变量 */

/* 步骤指示器 */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    margin-bottom: 2rem;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.step-item.active .step-number {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-focus-shadow);
}

.step-item.completed .step-number {
    background: var(--success-color);
    color: #fff;
}

.step-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.step-item.active .step-label {
    color: var(--primary-color);
    font-weight: 700;
}

.step-item.completed .step-label {
    color: var(--success-color);
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    margin: 0 0.5rem;
    max-width: 80px;
    margin-bottom: 1.5rem;
}

/* 评估步骤区域 */
.diagnosis-step {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    animation: fadeIn 0.4s ease;
}

.step-header {
    text-align: center;
    margin-bottom: 2rem;
}

.step-header h2 {
    font-family: 'Noto Serif SC', serif;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.step-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* 摄像头相关 */
.camera-container {
    max-width: 640px;
    margin: 0 auto;
}

.camera-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    /* [v1.10.38] 微信 X5 / 旧版 Android 不支持 aspect-ratio 时的兜底高度
       防止摄像头区域塌陷为 0px 高度不可见 */
    min-height: 200px;
    background: #1a1a2e;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1rem;
}

/* aspect-ratio 不支持时，用 padding-top 撑开 4:3 比例（老式兼容方案） */
@supports not (aspect-ratio: 4 / 3) {
    .camera-viewport {
        height: 0;
        padding-top: 75%;       /* 75% = 3/4 of width → 4:3 ratio */
        min-height: unset;
    }
    /* 内部元素绝对定位填满 */
    .camera-viewport video,
    .camera-viewport img,
    .camera-guide,
    .drag-overlay {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
    }
}

.camera-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-viewport img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* [v1.8.7] 文件上传 + 拖拽 + 桌面/手机按钮区分 */
.hidden-file {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); border: 0;
}

/* 拖拽遮罩（仅桌面端 hover 设备启用）*/
.drag-overlay {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--primary-color, #2c5f2d) 78%, transparent);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
    backdrop-filter: blur(4px);
}
.drag-text {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 1rem 1.5rem;
    border: 3px dashed rgba(255,255,255,0.8);
    border-radius: 14px;
}
.camera-viewport.drag-active .drag-overlay { display: flex; }

/* 按钮触屏/桌面互斥显示 */
@media (hover: none) and (pointer: coarse) {
    .btn-desktop-only { display: none !important; }
    .drag-overlay { display: none !important; }
}
@media (hover: hover) and (pointer: fine) {
    .btn-mobile-only { display: none !important; }
}

/* ghost 风格按钮（次次要操作，比 secondary 更轻量）*/
.btn-ghost {
    background: transparent;
    color: var(--primary-color, #2c5f2d);
    border: 1.5px solid var(--border-color, #e0ddd8);
}
.btn-ghost:hover { background: var(--primary-bg-light, rgba(44, 95, 45, 0.06)); }
.btn-ghost:active { transform: translateY(1px); }

.camera-guide {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.camera-guide .guide-outline {
    width: 60%;
    aspect-ratio: 3 / 4;
    border: 2px dashed rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    margin-bottom: 0.5rem;
}

.camera-guide span {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.camera-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-capture {
    min-width: 140px;
}

/* 分析加载状态 */
.analysis-loading {
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.analysis-loading p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* 分析结果卡片 */
.analysis-result {
    animation: fadeIn 0.4s ease;
}

.result-card {
    background: var(--primary-bg-light, #f0f7f0);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.result-card h3 {
    color: var(--primary-color);
    font-family: 'Noto Serif SC', serif;
    margin-bottom: 1rem;
}

.result-content {
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.step-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* 问诊相关 */
.inquiry-phase {
    margin-bottom: 2rem;
}

.inquiry-phase h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.phase-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.symptom-input-area {
    margin-bottom: 1.5rem;
}

.symptom-input-area textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.8;
    resize: vertical;
    min-height: 180px;
    transition: all 0.3s ease;
    background: #fafafa;
}

.symptom-input-area textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-focus-shadow);
}

.audio-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.audio-preview audio {
    width: 100%;
    max-width: 400px;
}

.audio-controls {
    display: flex;
    gap: 1rem;
}

.transcription-result {
    animation: fadeIn 0.4s ease;
}

.transcription-result h4 {
    color: var(--primary-color);
    margin: 1rem 0 0.5rem;
}

.transcription-result textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
}

.transcription-result textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-focus-shadow);
}

/* 追问卡片 */
.followup-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.followup-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: all 0.3s ease;
}

.followup-card.completed {
    border-color: var(--success-color);
    background: #f6ffed;
}

.followup-question {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.followup-question .q-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.followup-question .q-text {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.followup-question .tts-btn {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.followup-question .tts-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

.followup-answer {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.followup-answer textarea {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    min-height: 60px;
}

.followup-answer textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}


/* 综合确认 */
.review-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.review-card {
    background: #f9f9f9;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.review-card h3 {
    color: var(--primary-color);
    font-family: 'Noto Serif SC', serif;
    margin-bottom: 0.75rem;
}

.review-card .result-content {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.review-card.collapsible .review-card-body {
    max-height: 200px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.review-card.collapsible .review-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.review-card.collapsible .review-card-header h3 {
    margin-bottom: 0;
}

.collapse-icon {
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.review-card.collapsible.collapsed .review-card-body {
    max-height: 0;
    overflow: hidden;
}

.review-card.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.review-card textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
}

.review-card textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-focus-shadow);
}

.review-form {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.review-form .form-group {
    margin-bottom: 1.25rem;
}

.review-form .form-group:last-child {
    margin-bottom: 0;
}

.review-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.review-form input[type="text"],
.review-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.review-form input[type="text"]:focus,
.review-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-focus-shadow);
}

.btn-submit {
    min-width: 200px;
    font-size: 1.05rem;
    padding: 0.85rem 2rem;
}

/* 导航链接 */
.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
    transition: all 0.2s;
    margin-right: 0.75rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* 响应式 */
@media (max-width: 768px) {
    .step-indicator {
        padding: 1rem 0.5rem;
    }

    .step-number {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    .step-label {
        font-size: 0.75rem;
    }

    .step-line {
        max-width: 40px;
    }

    .diagnosis-step {
        padding: 1.25rem;
    }

    .camera-viewport {
        aspect-ratio: 3 / 4;
        min-height: 240px;  /* 微信 X5 / 旧版兜底 */
    }

    .camera-controls {
        flex-wrap: wrap;
    }

    .mic-button {
        width: 80px;
        height: 80px;
    }

    .mic-icon {
        font-size: 2rem;
    }

    .followup-answer {
        flex-direction: column;
    }

    .followup-answer .answer-mic {
        align-self: flex-end;
    }

    .step-actions {
        flex-direction: column;
    }

    .step-actions .btn {
        width: 100%;
    }
}

/* 手机端（≤480px）强化 */
@media (max-width: 480px) {
    .step-indicator {
        padding: 0.75rem 0.25rem;
        gap: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        scroll-snap-type: x mandatory;
    }

    .step-item {
        scroll-snap-align: start;
        min-width: 60px;
        flex-shrink: 0;
    }

    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.78rem;
    }

    .step-label {
        font-size: 0.68rem;
        text-align: center;
        max-width: 56px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .step-line {
        max-width: 20px;
        min-width: 8px;
        flex-shrink: 1;
    }

    .diagnosis-step {
        padding: 1rem 0.875rem;
    }

    .step-header h2 {
        font-size: 1.15rem;
    }

    .result-card {
        padding: 1rem;
    }

    .result-card h3 {
        font-size: 1rem;
    }

    /* 摄像头在手机上改为 16:9 */
    .camera-viewport {
        aspect-ratio: 16 / 9;
        min-height: 180px;  /* 微信 X5 / 旧版兜底 */
        border-radius: var(--radius-md);
    }

    .camera-controls {
        gap: 0.6rem;
    }

    .camera-controls .btn {
        flex: 1;
        font-size: 0.9rem;
        padding: 0.65rem 0.5rem;
    }

    /* 追问卡片 */
    .followup-card {
        padding: 1rem;
    }

    .followup-question .q-number {
        width: 24px;
        height: 24px;
        font-size: 0.78rem;
    }

    .followup-question .q-text {
        font-size: 0.9rem;
    }

    .followup-answer textarea {
        font-size: 1rem; /* 防 iOS 缩放 */
        min-height: 52px;
    }

    /* 综合确认 */
    .review-card {
        padding: 1rem 0.875rem;
    }

    .review-card textarea,
    .review-form textarea,
    .review-form input[type="text"] {
        font-size: 1rem; /* 防 iOS 缩放 */
    }

    .btn-submit {
        min-width: unset;
        width: 100%;
        font-size: 1rem;
    }

    /* nav-link 在手机端换行时缩小 */
    .nav-link {
        padding: 0.3rem 0.5rem;
        font-size: 0.78rem;
        margin-right: 0.4rem;
    }
}

/* 极小屏幕（≤360px） */
@media (max-width: 360px) {
    .step-indicator {
        padding: 0.5rem 0;
    }

    .step-number {
        width: 24px;
        height: 24px;
        font-size: 0.72rem;
    }

    .step-label {
        font-size: 0.62rem;
        max-width: 46px;
    }

    .diagnosis-step {
        padding: 0.875rem 0.75rem;
    }

    .symptom-input-area textarea {
        min-height: 140px;
    }
}

/* 横屏手机：摄像头高度限制 */
@media (max-height: 500px) and (orientation: landscape) {
    .camera-viewport {
        aspect-ratio: 16 / 9;
        max-height: 220px;
    }

    .step-indicator {
        display: none; /* 横屏时节省空间 */
    }

    .diagnosis-step {
        padding: 0.875rem;
    }
}
