/* ========================================
   中西医AI诊断系统 - 主样式表
   PWA移动端优先设计
   ======================================== */

/* CSS变量 */
:root {
    --color-primary: #2c7a5c;
    --color-primary-dark: #1a5c42;
    --color-primary-light: #3cab7d;
    --color-success: #27ae60;
    --color-warning: #f39c12;
    --color-danger: #e74c3c;
    --color-info: #3498db;
    --color-bg: #f5f7fa;
    --color-card: #ffffff;
    --color-text: #2c3e50;
    --color-text-light: #7f8c8d;
    --color-border: #e8ecf1;
    --color-shadow: rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 3px var(--color-shadow);
    --shadow-md: 0 4px 12px var(--color-shadow);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 全局基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    padding-bottom: calc(70px + var(--safe-bottom));
}

/* 应用头部 */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 主内容区 */
.main-content {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

/* 页面切换 */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

/* 欢迎卡片 */
.welcome-card {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
}

.welcome-card h2 {
    color: var(--color-primary);
    font-size: 22px;
    margin-bottom: 8px;
}

.welcome-card p {
    color: var(--color-text-light);
    font-size: 14px;
}

/* 功能卡片网格 */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.feature-card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.feature-card:active {
    transform: scale(0.97);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.feature-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--color-text);
}

.feature-card p {
    font-size: 12px;
    color: var(--color-text-light);
    line-height: 1.5;
}

.feature-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 10px;
    background: var(--color-primary);
    color: white;
    font-size: 10px;
    border-radius: 10px;
    font-weight: 500;
}

/* 摄像头容器 */
.camera-container {
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 12px;
    position: relative;
    aspect-ratio: 4/3;
    max-height: 400px;
}

.camera-container video,
.camera-container .preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 摄像头控制按钮 */
.camera-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
}

.btn-block {
    width: 100%;
    display: flex;
}

/* 结果容器 */
.result-container {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.result-container h3 {
    font-size: 16px;
    color: var(--color-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-border);
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item .label {
    color: var(--color-text-light);
}

.result-item .value {
    font-weight: 500;
    text-align: right;
}

/* 信息提示条 */
.info-banner {
    background: #e3f2fd;
    border-left: 4px solid var(--color-info);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 13px;
    color: #1565c0;
}

.warning-banner {
    background: #fff3e0;
    border-left: 4px solid var(--color-warning);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 13px;
    color: #e65100;
}

/* 聊天容器 */
.consult-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 280px);
    min-height: 400px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    margin-bottom: 12px;
}

.chat-bubble {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    max-width: 90%;
}

.chat-bubble.system {
    background: #e8f5e9;
    border-left: 3px solid var(--color-primary);
}

.chat-bubble.user {
    background: var(--color-primary);
    color: white;
    margin-left: auto;
    border-right: 3px solid var(--color-primary-dark);
}

.chat-bubble .hint {
    font-size: 12px;
    color: var(--color-text-light);
    margin-top: 6px;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input-area textarea {
    flex: 1;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area textarea:focus {
    border-color: var(--color-primary);
}

/* 快捷症状标签 */
.quick-symptoms {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tag {
    display: inline-block;
    padding: 4px 14px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.tag:active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* 认证页面 */
.auth-card {
    text-align: center;
    padding: 40px 20px;
}

.auth-card h2 {
    color: var(--color-primary);
    font-size: 24px;
    margin-bottom: 8px;
}

.auth-card > p {
    color: var(--color-text-light);
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-tabs {
    display: flex;
    background: var(--color-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.auth-tabs .tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    font-size: 15px;
    cursor: pointer;
    color: var(--color-text-light);
    transition: all 0.2s;
}

.auth-tabs .tab.active {
    background: var(--color-primary);
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input,
.auth-form select {
    padding: 12px 16px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    outline: none;
    background: var(--color-card);
    font-family: inherit;
}

.auth-form input:focus,
.auth-form select:focus {
    border-color: var(--color-primary);
}

/* 问卷 */
.questionnaire {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.question-section {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.question-section h3 {
    font-size: 16px;
    color: var(--color-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.question-item {
    margin-bottom: 12px;
}

.question-item label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.question-item input,
.question-item select,
.question-item textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.question-item textarea {
    resize: vertical;
    min-height: 60px;
}

/* 列表容器 */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-item {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.list-item:active {
    transform: scale(0.98);
}

.list-item h4 {
    font-size: 15px;
    margin-bottom: 4px;
}

.list-item .meta {
    font-size: 12px;
    color: var(--color-text-light);
}

/* 报告内容 */
.report-content {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
}

/* 个人资料卡片 */
.profile-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
    text-align: center;
}

.profile-card .avatar {
    width: 64px;
    height: 64px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 12px;
}

/* 统计卡片 */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-card .num {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-card .label {
    font-size: 12px;
    color: var(--color-text-light);
    margin-top: 4px;
}

/* 趋势图表 */
.trend-chart {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    min-height: 200px;
}

.trend-chart canvas {
    width: 100%;
    height: 200px;
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 calc(6px + var(--safe-bottom));
    box-shadow: 0 -2px 8px var(--color-shadow);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--color-text-light);
    transition: color 0.2s;
    font-size: 12px;
}

.nav-item.active {
    color: var(--color-primary);
}

.nav-icon {
    font-size: 22px;
}

.nav-label {
    font-size: 11px;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

#loading-text {
    color: white;
    margin-top: 12px;
    font-size: 14px;
}

/* Toast提示 */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: white;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 1000;
    animation: slideDown 0.3s ease;
    box-shadow: var(--shadow-lg);
}

@keyframes slideDown {
    from { transform: translate(-50%, -100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* 表单动作按钮 */
.form-actions {
    margin-top: 20px;
}

/* 结果卡片颜色 */
.result-warning { color: var(--color-warning); }
.result-good { color: var(--color-success); }
.result-danger { color: var(--color-danger); }

/* 响应式调整 */
@media (min-width: 600px) {
    .main-content {
        padding: 24px;
    }
    .feature-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
