/* 优化：CSS变量定义，提升维护性 */
:root {
    --timeline-bg: #fff;
    --timeline-shadow: 0 1px 3px rgba(0,0,0,0.05);
    --header-bg: #f8f9fa;
    --border-color: #e5e5e5;
    --text-primary: #333;
    --text-secondary: #555;
    --text-muted: #6c757d;
    --transition-fast: all 0.2s ease;
    --transition-smooth: all 0.25s ease-out;
}

/* 整体布局样式 */
.timeline-container {
    background-color: var(--timeline-bg);
    box-shadow: var(--timeline-shadow);
    padding: 20px;
    /* 优化：启用硬件加速 */
    transform: translateZ(0);
    will-change: scroll-position;
}

/* 标题栏样式 */
.timeline-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* 优化：筛选按钮样式 */
.filter-btn {
    border-color: #dee2e6;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.35rem 0.75rem;
    background-color: var(--timeline-bg);
    transition: var(--transition-fast);
    /* 优化：提升点击性能 */
    touch-action: manipulation;
    user-select: none;
}

.filter-btn:hover,
.filter-btn:focus {
    background-color: #f0f2f5;
    border-color: #ced4da;
    color: var(--text-primary);
    transform: translateY(-1px);
}

.filter-btn.active {
    background-color: #e9ecef;
    border-color: #ced4da;
    color: #212529;
    font-weight: 500;
}

/* 优化：时间线样式 */
.vis-timeline {
    border: none;
    background-color: transparent;
    font-family: inherit;
    /* 优化：启用硬件加速 */
    transform: translateZ(0);
    will-change: transform;
}

.vis-panel.vis-center {
    border-color: #eaeaea;
}

.vis-time-axis .vis-text {
    color: var(--text-secondary);
    padding: 3px 5px;
}

/* 优化：朝代标识线样式 */
.dynasty-timeline {
    height: 24px;
    position: relative;
    background-color: #f5f5f5;
    margin-bottom: 5px;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    /* 优化：启用硬件加速 */
    transform: translateZ(0);
    contain: layout style paint;
}

.dynasty-segment {
    position: absolute;
    height: 100%;
    top: 0;
    border-right: 1px solid rgba(0,0,0,0.1);
    text-align: center;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0,0,0,0.7);
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
    overflow: hidden;
    white-space: nowrap;
    transition: var(--transition-fast);
    /* 优化：提升渲染性能 */
    will-change: transform, z-index;
}

.dynasty-segment:hover {
    overflow: visible;
    z-index: 100;
    font-weight: bold;
    transform: scale(1.02);
}

/* 优化：事件样式 */
.vis-timeline .vis-item {
    border-width: 0;
    border-radius: 4px;
    padding: 8px 12px;
    color: white;
    transition: var(--transition-smooth);
    /* 优化：启用硬件加速 */
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

.vis-timeline .vis-item:hover {
    transform: translateY(-3px) translateZ(0);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* 优化：事件类型颜色（使用CSS自定义属性） */
.vis-timeline .vis-item.政治 { background-color: #4dabf7; }
.vis-timeline .vis-item.军事 { background-color: #f17b7b; }
.vis-timeline .vis-item.文化 { background-color: #51cf66; }
.vis-timeline .vis-item.经济 { background-color: #8bbed4; }
.vis-timeline .vis-item.教育 { background-color: #9575cd; }
.vis-timeline .vis-item.艺术 { background-color: #d88da6; }
.vis-timeline .vis-item.科技 { background-color: #26a69a; }
.vis-timeline .vis-item.医学 { background-color: #29b6f6; }
.vis-timeline .vis-item.社会 { background-color: #adb6ea; }
.vis-timeline .vis-item.其他 { background-color: #9e9e9e; }

/* 优化：时间线项目样式 */
.timeline-item {
    font-size: 12px;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    width: 100%;
    /* 优化：提升文本渲染性能 */
    text-rendering: optimizeSpeed;
}

.timeline-item-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    order: 1;
    width: 100%;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    /* 优化：限制重排 */
    contain: layout;
}

.timeline-figure,
.timeline-location {
    display: flex;
    align-items: center;
    width: 100%;
    font-weight: 400;
}

.timeline-figure {
    font-size: 12px;
    color: rgba(255,255,255,0.95);
    order: 2;
    margin-bottom: 3px;
}

.timeline-location {
    font-size: 11px;
    opacity: 0.85;
    order: 3;
}

.timeline-figure i,
.timeline-location i {
    width: 16px;
    text-align: center;
    margin-right: 5px;
    opacity: 0.9;
    /* 优化：图标渲染 */
    font-display: swap;
}

/* 朝代图例样式 */
.timeline-legend {
    margin-top: 15px;
    padding: 12px 16px;
    background-color: #f8f9fa;
    border-top: 1px solid #e5e5e5;
}

.dynasty-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.dynasty-item {
    padding: 4px 10px;
    border-radius: 16px;
    background-color: #f1f1f1;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    font-size: 0.8125rem;
    transition: all 0.2s ease;
}

.dynasty-item:hover {
    background-color: #e9ecef;
}

.dynasty-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

/* 事件详情模态框样式 */
.event-modal .modal-content {
    border-radius: 4px;
    border: none;
}

.event-modal .modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
}

.event-modal .modal-title {
    font-weight: 500;
    color: #333;
}

.event-details {
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 4px;
    margin-top: 15px;
    border: 1px solid #e5e5e5;
}

.event-description {
    line-height: 1.6;
    color: #444;
}

.event-figure {
    color: #0d6efd;
    text-decoration: none;
    transition: color 0.2s ease;
}

.event-figure:hover {
    color: #0a58ca;
    text-decoration: underline;
}

.event-info-item {
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
}

.event-info-item i {
    margin-top: 3px;
    margin-right: 8px;
    color: #6c757d;
    width: 14px;
    text-align: center;
} 