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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    padding: 2rem 0;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.description {
    font-size: 1rem;
    opacity: 0.8;
}

/* 主要内容区域 */
main {
    padding: 2rem 0;
}

section {
    margin-bottom: 3rem;
}

h2 {
    font-size: 2rem;
    color: white;
    margin-bottom: 2rem;
    text-align: center;
}

h3 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}

/* 控制面板 */
.demo-controls {
    margin-bottom: 3rem;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.control-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.simulator-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

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

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #e74c3c;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #c0392b;
    transform: translateY(-2px);
}

.btn-accent {
    background: #27ae60;
    color: white;
}

.btn-accent:hover {
    background: #229954;
    transform: translateY(-2px);
}

.event-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-item {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
}

/* 智能体状态 */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.agent-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.agent-item:hover {
    transform: translateY(-2px);
}

.agent-icon {
    font-size: 2rem;
}

.agent-info h4 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: #2c3e50;
}

.agent-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.agent-status.active {
    background: #d4edda;
    color: #155724;
}

.agent-status.standby {
    background: #fff3cd;
    color: #856404;
}

/* 实时可视化 */
.real-time-visualization {
    margin-bottom: 3rem;
}

.visualization-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.chart-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.chart {
    height: 200px;
    position: relative;
}

.chart-placeholder {
    height: 150px;
    position: relative;
    background: linear-gradient(45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(-45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f8f9fa 75%), 
                linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 8px;
    overflow: hidden;
}

.chart-line {
    position: absolute;
    height: 2px;
    background: #667eea;
    animation: pulse 2s infinite;
}

.chart-line:nth-child(1) {
    top: 20%;
    left: 0;
    width: 60%;
    animation-delay: 0s;
}

.chart-line:nth-child(2) {
    top: 40%;
    left: 10%;
    width: 80%;
    animation-delay: 0.5s;
}

.chart-line:nth-child(3) {
    top: 60%;
    left: 5%;
    width: 70%;
    animation-delay: 1s;
}

.chart-line:nth-child(4) {
    top: 80%;
    left: 15%;
    width: 85%;
    animation-delay: 1.5s;
}

.chart-line:nth-child(5) {
    top: 30%;
    left: 20%;
    width: 75%;
    animation-delay: 2s;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.chart-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #666;
}

/* 缓存图表 */
.cache-meter {
    position: relative;
    height: 100px;
    background: #e9ecef;
    border-radius: 50px;
    overflow: hidden;
    margin: 2rem 0;
}

.cache-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 85%;
    transition: width 0.5s ease;
    border-radius: 50px;
}

.cache-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* 吞吐量图表 */
.throughput-bars {
    display: flex;
    align-items: end;
    height: 150px;
    gap: 0.5rem;
    margin: 2rem 0;
}

.bar {
    flex: 1;
    background: linear-gradient(to top, #667eea, #764ba2);
    border-radius: 4px 4px 0 0;
    animation: grow 2s infinite ease-in-out;
}

.bar:nth-child(1) { animation-delay: 0s; }
.bar:nth-child(2) { animation-delay: 0.2s; }
.bar:nth-child(3) { animation-delay: 0.4s; }
.bar:nth-child(4) { animation-delay: 0.6s; }
.bar:nth-child(5) { animation-delay: 0.8s; }
.bar:nth-child(6) { animation-delay: 1s; }

@keyframes grow {
    0%, 100% { transform: scaleY(0.8); }
    50% { transform: scaleY(1.2); }
}

/* 事件日志 */
.event-log {
    margin-bottom: 3rem;
}

.log-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.log-header-section h2 {
    color: white;
    font-size: 1.8rem;
    margin: 0;
}

.log-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.log-filter select,
.log-search input {
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-size: 0.9rem;
}

.log-search input {
    width: 200px;
}

.log-search input::placeholder {
    color: #666;
}

.log-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.log-header {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 1rem 2rem;
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 1px solid #dee2e6;
}

.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.3s ease;
}

.sortable:hover {
    color: #667eea;
}

.log-content {
    max-height: 400px;
    overflow-y: auto;
}

.log-entry {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 1rem 2rem;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.3s ease;
    align-items: center;
}

.log-entry:hover {
    background-color: #f8f9fa;
}

.log-entry:last-child {
    border-bottom: none;
}

.time {
    font-family: 'Courier New', monospace;
    color: #666;
    font-size: 0.9rem;
}

.event-type,
.agent {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.event-icon,
.agent-icon {
    font-size: 1.1rem;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.status.completed {
    background: #d4edda;
    color: #155724;
}

.status.processing {
    background: #fff3cd;
    color: #856404;
}

.status.pending {
    background: #cce5ff;
    color: #004085;
}

.status.cancelled {
    background: #f8d7da;
    color: #721c24;
}

.status.prioritized {
    background: #e2e3e5;
    color: #383d41;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.latency {
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.latency.good {
    color: #28a745;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: scale(1.1);
}

.log-summary {
    background: #f8f9fa;
    padding: 1rem 2rem;
    border-top: 1px solid #dee2e6;
}

.summary-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.summary-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.summary-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
}

.event-type {
    font-weight: 600;
    color: #2c3e50;
}

.agent {
    color: #667eea;
    font-weight: 600;
}

.status {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.status.completed {
    background: #d4edda;
    color: #155724;
}

.status.processing {
    background: #fff3cd;
    color: #856404;
}

.status.pending {
    background: #d1ecf1;
    color: #0c5460;
}

.latency {
    font-family: 'Courier New', monospace;
    color: #666;
}

/* 性能指标 */
.performance-metrics {
    margin-bottom: 3rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.metric-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-5px);
}

.metric-icon {
    font-size: 3rem;
    opacity: 0.8;
}

.metric-info h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #666;
}

.metric-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.metric-trend {
    font-size: 0.9rem;
    font-weight: 600;
}

.metric-trend.positive {
    color: #27ae60;
}

.metric-trend.negative {
    color: #e74c3c;
}

/* 页脚 */
footer {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    text-align: center;
    padding: 2rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

footer a {
    color: white;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

footer a:hover {
    opacity: 1;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .control-grid {
        grid-template-columns: 1fr;
    }
    
    .visualization-grid {
        grid-template-columns: 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .simulator-controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .log-header,
    .log-entry {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .log-header span,
    .log-entry span {
        padding: 0.25rem 0;
    }
    
    .metric-card {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 1rem 0;
    }
    
    section {
        margin-bottom: 2rem;
    }
    
    .control-card,
    .chart-container,
    .metric-card {
        padding: 1.5rem;
    }
}
