/* ============================================
   ECG心电图分析系统 - 全局样式
   严格匹配原型图配色方案
   ============================================ */

/* --- CSS变量 --- */
:root {
    --color-primary: #2B7DE9;
    --color-primary-dark: #1A5CBF;
    --color-primary-light: #E3F2FD;
    --color-success: #2E7D32;
    --color-success-light: #E8F5E9;
    --color-danger: #C62828;
    --color-warning: #F57C00;
    --color-dark-blue: #0D2B4E;
    --color-text-primary: #212121;
    --color-text-secondary: #616161;
    --color-text-muted: #9E9E9E;
    --color-border: #E0E0E0;
    --color-bg: #F5F7FA;
    --color-white: #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

/* --- 全局重置 --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* --- 头部导航 --- */
.app-header {
    background: var(--color-primary);
    color: var(--color-white);
    padding: 0 32px;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

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

.nav-links {
    display: flex;
    gap: 24px;
}

.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-white);
    border-bottom-color: var(--color-white);
}

/* --- 页面切换 --- */
.page {
    display: none;
    padding: 32px 24px;
    max-width: 900px;
    margin: 0 auto;
}

.page.active {
    display: block;
}

/* --- 上传卡片 --- */
.upload-container {
    display: flex;
    justify-content: center;
}

.upload-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 640px;
    position: relative;
    overflow: hidden;
}

.upload-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 6px;
}

.upload-subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 28px;
}

/* --- 拖拽区域 --- */
.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    background: #FAFBFC;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-icon {
    width: 52px;
    height: 52px;
}

.drop-text {
    font-size: 15px;
    color: var(--color-text-primary);
}

.browse-link {
    color: var(--color-primary);
    font-weight: 500;
    cursor: pointer;
}

.drop-hint {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* --- 预览区域 --- */
.preview-area {
    margin-top: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #F5F5F5;
}

.preview-filename {
    font-size: 13px;
    color: var(--color-text-secondary);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-remove:hover {
    background: #FFEBEE;
}

.preview-image {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
}

/* --- 患者信息表单 --- */
.patient-form {
    margin-top: 24px;
}

.form-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 12px;
}

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

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-family);
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(43,125,233,0.15);
}

/* --- 按钮 --- */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.btn-primary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-md);
}

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

.btn-icon {
    width: 18px;
    height: 18px;
}

.btn-secondary {
    padding: 12px 20px;
    background: var(--color-white);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: var(--color-primary-light);
}

/* --- 加载遮罩 --- */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-primary-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* --- 报告展示页面 --- */
.report-container {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
}

/* 报告头部 */
.report-header {
    background: var(--color-primary);
    color: var(--color-white);
    padding: 24px 28px;
    border-radius: var(--radius-md);
    margin-bottom: 28px;
}

.report-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

.report-header-info {
    display: flex;
    gap: 24px;
    font-size: 13px;
    opacity: 0.9;
    flex-wrap: wrap;
}

.report-header-info span {
    white-space: nowrap;
}

/* 核心结论 */
.core-conclusion {
    background: var(--color-success-light);
    border: 1px solid #A5D6A7;
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 28px;
}

.core-label {
    display: inline-block;
    background: var(--color-success);
    color: var(--color-white);
    font-size: 12px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.core-text {
    font-size: 15px;
    color: var(--color-text-primary);
    line-height: 1.7;
}

/* 章节标题 */
.section-heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary-dark);
    border-left: 4px solid var(--color-primary);
    padding-left: 12px;
    margin: 28px 0 16px;
}

.section-heading:first-child {
    margin-top: 0;
}

/* 指标表格 */
.indicator-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 14px;
}

.indicator-table thead th {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-weight: 600;
    padding: 10px 12px;
    text-align: center;
    border: 1px solid var(--color-border);
}

.indicator-table tbody td {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    text-align: center;
}

.indicator-table tbody tr:nth-child(even) {
    background: #FAFAFA;
}

.judgment-normal {
    color: var(--color-success);
    font-weight: 600;
}

.judgment-warning {
    color: var(--color-warning);
    font-weight: 600;
}

.judgment-danger {
    color: var(--color-danger);
    font-weight: 600;
}

/* 电压明细 */
.voltage-detail {
    background: #F5F5F5;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

/* 逐项解读 */
.interpretation-item {
    margin-bottom: 14px;
}

.interpretation-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 2px;
}

.interpretation-desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* 诊断区域 */
.diagnosis-box {
    background: var(--color-dark-blue);
    color: var(--color-white);
    text-align: center;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
}

.diagnosis-points {
    list-style: none;
    padding: 0;
}

.diagnosis-points li {
    font-size: 14px;
    color: var(--color-text-primary);
    padding: 4px 0 4px 16px;
    position: relative;
    line-height: 1.6;
}

.diagnosis-points li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--color-text-secondary);
}

/* 综合总结 */
.summary-box {
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
    padding: 18px 24px;
    text-align: center;
    font-size: 15px;
    color: var(--color-text-primary);
    line-height: 1.7;
    margin-bottom: 20px;
}

/* 补充提示 */
.supplementary-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 20px 0 10px;
}

.supplementary-list {
    list-style: none;
    padding: 0;
}

.supplementary-list li {
    font-size: 13px;
    color: var(--color-text-secondary);
    padding: 4px 0 4px 16px;
    position: relative;
    line-height: 1.6;
}

.supplementary-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--color-text-muted);
}

/* 页脚 */
.report-footer {
    border-top: 1px dashed var(--color-border);
    margin-top: 28px;
    padding-top: 16px;
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.8;
}

/* 操作按钮 */
.report-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

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

.btn-back {
    display: inline-flex;
    align-items: center;
    padding: 10px 24px;
    background: var(--color-white);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
}

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

/* --- 历史报告列表 --- */
.reports-container {
    max-width: 800px;
    margin: 0 auto;
}

.section-heading {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 20px;
}

.reports-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.report-card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
    cursor: pointer;
}

.report-card:hover {
    box-shadow: var(--shadow-md);
}

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

.report-card-info p {
    font-size: 12px;
    color: var(--color-text-muted);
}

.report-card-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-white);
    color: var(--color-text-secondary);
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s;
}

.btn-sm:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.empty-state {
    text-align: center;
    color: var(--color-text-muted);
    padding: 48px 0;
    font-size: 14px;
}

/* --- 错误提示 --- */
.error-toast {
    position: fixed;
    top: 72px;
    right: 24px;
    background: var(--color-danger);
    color: var(--color-white);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

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

/* --- 响应式 --- */
@media (max-width: 768px) {
    .upload-card {
        padding: 24px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .report-header-info {
        flex-direction: column;
        gap: 4px;
    }

    .report-container {
        padding: 20px;
    }

    .action-buttons {
        flex-direction: column;
    }
}
