/**
 * 历史邮件导入分析 - 页面专属样式
 */

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

.hi-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.hi-stat-card:hover {
    box-shadow: var(--shadow-card);
    transform: translateY(-1px);
}

.hi-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.hi-stat-icon.total { background: rgba(68, 119, 147, 0.12); color: var(--primary-color); }
.hi-stat-icon.running { background: rgba(24, 144, 255, 0.12); color: #1890ff; }
.hi-stat-icon.completed { background: rgba(82, 196, 26, 0.12); color: #52c41a; }
.hi-stat-icon.failed { background: rgba(255, 77, 79, 0.12); color: #ff4d4f; }

.hi-stat-info { flex: 1; }
.hi-stat-label { font-size: 13px; color: var(--text-tertiary); margin-bottom: 4px; }
.hi-stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }

/* ==================== 全局进度条 ==================== */
.hi-global-progress {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.hi-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.hi-progress-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.hi-progress-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.hi-progress-stats span { display: flex; align-items: center; gap: 4px; }
.hi-progress-stats .dot {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.hi-progress-stats .dot.processed { background: #52c41a; }
.hi-progress-stats .dot.failed { background: #ff4d4f; }
.hi-progress-stats .dot.pending { background: #d9d9d9; }

.hi-progress-bar {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
}

.hi-progress-bar .segment {
    height: 100%;
    transition: width 0.5s ease;
}

.hi-progress-bar .segment.processed { background: #52c41a; }
.hi-progress-bar .segment.failed { background: #ff4d4f; }

/* ==================== Tab 栏 ==================== */
.hi-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 0 16px;
}

.hi-tab-btn {
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.hi-tab-btn:hover { color: var(--primary-color); }
.hi-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.hi-tab-content { display: none; }
.hi-tab-content.active { display: block; }

/* ==================== 筛选栏 ==================== */
.hi-filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.hi-filter-bar select,
.hi-filter-bar input {
    padding: 7px 12px;
    border: 1px solid #d9d9d9;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-primary);
    background: white;
    outline: none;
    transition: var(--transition-fast);
}

.hi-filter-bar select:focus,
.hi-filter-bar input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(68, 119, 147, 0.15);
}

.hi-search-input { width: 220px; }

/* ==================== 表格通用样式 ==================== */
.hi-table-card {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.hi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.hi-table thead th {
    background: #fafafa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

.hi-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    color: var(--text-primary);
    vertical-align: middle;
}

.hi-table tbody tr:hover { background: var(--bg-hover); }
.hi-table tbody tr.expandable { cursor: pointer; }

.hi-table tbody tr.expandable td:first-child::before {
    content: '\f054';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 10px;
    margin-right: 8px;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
    display: inline-block;
}

.hi-table tbody tr.expandable.expanded td:first-child::before {
    transform: rotate(90deg);
}

/* 子表缩进 */
.hi-sub-table-row { display: none; }
.hi-sub-table-row.visible { display: table-row; }
.hi-sub-table-row td { padding: 0 !important; background: #fafbfc; }

.hi-sub-table-wrapper {
    padding: 8px 16px 8px 40px;
}

.hi-sub-table-wrapper .hi-table { font-size: 12px; }
.hi-sub-table-wrapper .hi-table thead th { padding: 8px 12px; background: #f0f2f5; }
.hi-sub-table-wrapper .hi-table tbody td { padding: 8px 12px; }

/* 二级子表缩进 */
.hi-sub-table-wrapper .hi-sub-table-wrapper { padding-left: 24px; }

/* ==================== 状态标签 ==================== */
.hi-status-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.hi-status-tag.pending { background: #f5f5f5; color: #8c8c8c; }
.hi-status-tag.running { background: #e6f7ff; color: #1890ff; }
.hi-status-tag.paused { background: #fff7e6; color: #fa8c16; }
.hi-status-tag.completed { background: #f6ffed; color: #52c41a; }
.hi-status-tag.partially_failed { background: #fffbe6; color: #faad14; }
.hi-status-tag.failed { background: #fff2f0; color: #ff4d4f; }
.hi-status-tag.cancelled { background: #f5f5f5; color: #8c8c8c; }

/* 模式标签 */
.hi-mode-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 6px;
}

.hi-mode-tag.analyze { background: #e6f7ff; color: #1890ff; }
.hi-mode-tag.download { background: #fff7e6; color: #fa8c16; }

/* 分类标签 */
.hi-category-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: white;
}

/* 情绪标签 */
.hi-sentiment-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

/* 分析类型标签 */
.hi-analysis-type-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.hi-analysis-type-tag.classification { background: #e6f7ff; color: #1890ff; }
.hi-analysis-type-tag.sentiment { background: #f9f0ff; color: #722ed1; }
.hi-analysis-type-tag.business_event { background: #fff7e6; color: #fa8c16; }

/* 审阅状态标签 */
.hi-review-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.hi-review-tag.not_reviewed { background: #f5f5f5; color: #8c8c8c; }
.hi-review-tag.pending_review { background: #fffbe6; color: #faad14; }
.hi-review-tag.reviewed { background: #f6ffed; color: #52c41a; }
.hi-review-tag.overridden { background: #f9f0ff; color: #722ed1; }

/* ==================== 行内进度条 ==================== */
.hi-inline-progress {
    width: 120px;
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}

.hi-inline-progress .bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.hi-inline-progress .bar.green { background: #52c41a; }
.hi-inline-progress .bar.blue { background: #1890ff; }

/* ==================== 操作按钮 ==================== */
.hi-action-btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid #d9d9d9;
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.hi-action-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.hi-action-btn.primary { border-color: var(--primary-color); color: var(--primary-color); }
.hi-action-btn.danger { border-color: #ff4d4f; color: #ff4d4f; }
.hi-action-btn.danger:hover { background: #fff2f0; }

.hi-action-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ==================== 抽屉 ==================== */
.hi-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-base);
}

.hi-drawer-overlay.visible { opacity: 1; visibility: visible; }

.hi-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 910;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hi-drawer.visible { transform: translateX(0); }
.hi-drawer.create-drawer { width: 480px; }
.hi-drawer.detail-drawer { width: 700px; }

.hi-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
}

.hi-drawer-header h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin: 0; }

.hi-drawer-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition-fast);
}

.hi-drawer-close:hover { background: #f5f5f5; color: var(--text-primary); }

.hi-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.hi-drawer-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* ==================== 表单样式 ==================== */
.hi-form-group {
    margin-bottom: 18px;
}

.hi-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.hi-form-label .required { color: #ff4d4f; margin-left: 2px; }

.hi-form-input,
.hi-form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-fast);
}

.hi-form-input:focus,
.hi-form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(68, 119, 147, 0.15);
}

.hi-form-input:read-only { background: #fafafa; color: var(--text-tertiary); }

.hi-form-row { display: flex; gap: 12px; }
.hi-form-row .hi-form-group { flex: 1; }

.hi-form-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

/* 快速选择按钮 */
.hi-quick-btns { display: flex; gap: 6px; margin-top: 6px; }
.hi-quick-btn {
    padding: 3px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    cursor: pointer;
    transition: var(--transition-fast);
}
.hi-quick-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* 高级筛选折叠 */
.hi-advanced-toggle {
    font-size: 13px;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
}

.hi-advanced-section { display: none; }
.hi-advanced-section.visible { display: block; }

/* ==================== 详情标签页 ==================== */
.hi-detail-tabs {
    display: flex;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 16px;
}

.hi-detail-tab-btn {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
}

.hi-detail-tab-btn:hover { color: var(--primary-color); }
.hi-detail-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.hi-detail-tab-content { display: none; }
.hi-detail-tab-content.active { display: block; }

/* 分析结果区块 */
.hi-analysis-section {
    margin-bottom: 20px;
    padding: 16px;
    background: #fafbfc;
    border-radius: var(--radius-md);
    border: 1px solid #f0f0f0;
}

.hi-analysis-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hi-analysis-field {
    display: flex;
    margin-bottom: 8px;
    font-size: 13px;
}

.hi-analysis-field-label {
    width: 80px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.hi-analysis-field-value { color: var(--text-primary); flex: 1; }

/* 邮件内容区 */
.hi-email-content-block {
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 12px;
}

.hi-email-content-block.original { background: #fafafa; border: 1px solid #f0f0f0; }
.hi-email-content-block.cleaned { background: #f0f7ff; border: 1px solid #d6e8fa; }

.hi-email-content-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 6px;
    text-transform: uppercase;
}

/* JSON 预览 */
.hi-json-block {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: var(--radius-md);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 500px;
    overflow-y: auto;
}

/* ==================== 模态框 ==================== */
.hi-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 950;
    display: none;
    align-items: center;
    justify-content: center;
}

.hi-modal-overlay.visible { display: flex; }

.hi-modal {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 560px;
    max-height: 80vh;
    overflow-y: auto;
}

.hi-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.hi-modal-header h3 { font-size: 16px; font-weight: 600; margin: 0; }

.hi-modal-body { padding: 20px 24px; }

/* 质量报告样式 */
.hi-quality-score {
    text-align: center;
    padding: 20px 0;
    margin-bottom: 20px;
}

.hi-quality-score .score-value {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}

.hi-quality-score .score-value.pass { color: #52c41a; }
.hi-quality-score .score-value.warn { color: #faad14; }
.hi-quality-score .score-value.fail { color: #ff4d4f; }

.hi-quality-score .score-label { font-size: 14px; color: var(--text-tertiary); margin-top: 4px; }

.hi-quality-metric {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}

.hi-quality-metric:last-child { border-bottom: none; }

.hi-quality-metric .metric-label { width: 100px; font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.hi-quality-metric .metric-bar { flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.hi-quality-metric .metric-bar .fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.hi-quality-metric .metric-value { width: 60px; text-align: right; font-size: 13px; font-weight: 600; }
.hi-quality-metric .metric-status { width: 50px; text-align: center; }

.hi-quality-recommendations {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fffbe6;
    border-radius: var(--radius-md);
    border: 1px solid #ffe58f;
}

.hi-quality-recommendations h4 {
    font-size: 13px;
    font-weight: 600;
    color: #d48806;
    margin-bottom: 8px;
}

.hi-quality-recommendations li {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    padding-left: 4px;
}

/* ==================== 审阅面板 ==================== */
.hi-review-card {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: hidden;
}

.hi-review-card-header {
    padding: 12px 16px;
    background: #fafbfc;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.hi-review-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

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

.hi-review-item-info { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.hi-review-confidence { font-size: 12px; color: var(--text-tertiary); }

/* ==================== 按钮样式 ==================== */
.hi-btn-primary {
    padding: 8px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.hi-btn-default {
    padding: 8px 20px;
    background: white;
    color: var(--text-secondary);
    border: 1px solid #d9d9d9;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

/* ==================== 空状态 ==================== */
.hi-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

.hi-empty i { font-size: 40px; margin-bottom: 12px; display: block; opacity: 0.3; }
.hi-empty p { font-size: 14px; }

/* ==================== 响应式 ==================== */
@media (max-width: 1200px) {
    .hi-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .hi-stats-grid { grid-template-columns: 1fr; }
    .hi-drawer.detail-drawer { width: 100%; }
    .hi-drawer.create-drawer { width: 100%; }
}
