/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* 头部样式 */
.header {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* 统计卡片 */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    display: flex;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    font-size: 3em;
    margin-right: 20px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #666;
    margin-top: 5px;
}

/* 查询面板 */
.query-panel {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.query-panel h2 {
    margin-bottom: 20px;
    color: #333;
}

/* 标签页 */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid #eee;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1em;
    color: #666;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: bold;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 表单组 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* 按钮 */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* 加载动画 */
.loading {
    display: none;
    text-align: center;
    padding: 50px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.loading.show {
    display: block;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 结果面板 */
.results-panel {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.results-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.results-info span {
    color: #666;
    font-size: 1.1em;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.pagination button {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.pagination button:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: #667eea;
    color: white;
}

/* 结果列表 */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-item {
    border: 2px solid #eee;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s;
    cursor: pointer;
}

.result-item:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
    transform: translateX(5px);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.result-id {
    font-weight: bold;
    color: #667eea;
}

.result-time {
    color: #999;
    font-size: 0.9em;
}

.result-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 6px;
}

.meta-item {
    font-size: 0.9em;
}

.meta-label {
    color: #666;
    margin-right: 5px;
}

.meta-value {
    color: #333;
    font-weight: 500;
}

.result-content {
    margin-top: 15px;
}

.content-section {
    margin-bottom: 10px;
}

.content-label {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.content-text {
    color: #555;
    line-height: 1.6;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 6px;
    max-height: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-large {
    max-width: 1200px;
    max-height: 90vh;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #000;
}

#modalBody {
    margin-top: 20px;
}

/* 用户对话历史样式 */
.user-conversations-header {
    border-bottom: 2px solid #667eea;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.user-conversations-header h2 {
    color: #667eea;
    margin-bottom: 10px;
}

.user-conversations-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.user-stat-item {
    text-align: center;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 8px;
}

.user-stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

.user-stat-label {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

.conversation-group {
    margin-bottom: 30px;
    border: 2px solid #eee;
    border-radius: 10px;
    overflow: hidden;
}

.conversation-group-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-group-header:hover {
    opacity: 0.9;
}

.conversation-group-title {
    font-weight: bold;
    font-size: 1.1em;
}

.conversation-group-meta {
    font-size: 0.9em;
    opacity: 0.9;
}

.conversation-group-body {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.conversation-group-body.expanded {
    max-height: 5000px;
    padding: 20px;
}

.message-item {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    background: #f9f9f9;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.message-time {
    color: #999;
    font-size: 0.9em;
}

.message-meta {
    font-size: 0.85em;
    color: #666;
}

.message-query {
    margin-bottom: 15px;
}

.message-query-label {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.message-query-content {
    padding: 10px 15px;
    background: white;
    border-left: 4px solid #667eea;
    border-radius: 5px;
    line-height: 1.6;
}

.message-answer-label {
    font-weight: bold;
    color: #764ba2;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.message-answer-content {
    padding: 15px;
    background: white;
    border-left: 4px solid #764ba2;
    border-radius: 5px;
    line-height: 1.8;
}

/* Markdown和LaTeX渲染样式 */
.rendered-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
}

.rendered-content h1, .rendered-content h2, .rendered-content h3 {
    color: #333;
    margin-top: 20px;
    margin-bottom: 10px;
}

.rendered-content h1 {
    font-size: 1.8em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.rendered-content h2 {
    font-size: 1.5em;
}

.rendered-content h3 {
    font-size: 1.3em;
}

.rendered-content p {
    margin-bottom: 10px;
}

.rendered-content ul, .rendered-content ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

.rendered-content li {
    margin-bottom: 5px;
}

.rendered-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.rendered-content pre {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 10px;
}

.rendered-content pre code {
    background: none;
    padding: 0;
}

.rendered-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 10px;
}

.rendered-content table th,
.rendered-content table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.rendered-content table th {
    background: #667eea;
    color: white;
}

.rendered-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 15px;
    margin-left: 0;
    color: #666;
    font-style: italic;
}

/* KaTeX数学公式样式 */
.katex {
    font-size: 1.1em;
}

.katex-display {
    margin: 15px 0;
}

/* 用户ID点击样式 */
.clickable-user {
    color: #667eea;
    cursor: pointer;
    text-decoration: underline;
    font-weight: bold;
    transition: color 0.3s;
}

.clickable-user:hover {
    color: #764ba2;
}

.detail-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.detail-section:last-child {
    border-bottom: none;
}

.detail-section h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.detail-section p {
    line-height: 1.8;
    color: #555;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px;
    color: white;
    margin-top: 30px;
}

/* 用户关联分析样式 */
.correlation-results {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.correlation-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
}

.summary-item {
    text-align: center;
}

.summary-value {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 5px;
}

.summary-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.analysis-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
}

.analysis-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.analysis-section .section-header:hover {
    opacity: 0.8;
}

.analysis-section h3 {
    color: #667eea;
    margin: 0;
}

.toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 10px;
    font-size: 1.2em;
    color: #667eea;
    transition: transform 0.3s;
}

.toggle-btn:hover {
    background: #eee;
    border-radius: 5px;
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s;
}

.toggle-btn.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.section-content {
    margin-top: 15px;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

/* 会话关联样式 */
.conversation-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.conv-stat-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid #eee;
    transition: transform 0.3s;
}

.conv-stat-card:hover {
    transform: translateY(-3px);
    border-color: #667eea;
}

.conv-stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

.conv-stat-label {
    color: #666;
    margin-top: 5px;
    font-size: 0.9em;
}

.conversation-list {
    margin-top: 20px;
}

.conversation-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: transform 0.3s;
}

.conversation-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.conversation-id {
    font-weight: bold;
    color: #667eea;
    font-size: 0.9em;
}

.conversation-badge {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85em;
}

.conversation-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    font-size: 0.9em;
    color: #666;
}

.conversation-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.conversation-meta-label {
    font-weight: 500;
}

.multi-user-tag {
    background: #ff9800;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    margin-left: 10px;
}

/* 智能体分布图 */
.appid-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    transition: transform 0.3s;
}

.appid-item:hover {
    transform: translateX(5px);
}

.appid-name {
    flex: 1;
    font-weight: 500;
}

.appid-bar {
    width: 60%;
    height: 25px;
    background: #eee;
    border-radius: 5px;
    margin: 0 15px;
    position: relative;
    overflow: hidden;
}

.appid-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 5px;
    transition: width 0.5s;
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: white;
    font-size: 0.85em;
}

.appid-count {
    color: #667eea;
    font-weight: bold;
}

/* 日历热力图 */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-top: 15px;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    transition: transform 0.3s;
    cursor: pointer;
    border: 1px solid #ddd;
}

.calendar-day:hover {
    transform: scale(1.1);
}

.calendar-day.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: bold;
}

.calendar-day-date {
    font-size: 0.9em;
}

.calendar-day-count {
    font-size: 0.75em;
    margin-top: 2px;
}

/* 关键词云 */
.keyword-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: white;
    border-radius: 8px;
}

.keyword-item {
    padding: 8px 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: 500;
    transition: transform 0.3s;
    cursor: pointer;
}

.keyword-item:hover {
    transform: scale(1.1);
}

.keyword-word {
    margin-right: 5px;
}

.keyword-count {
    opacity: 0.8;
    font-size: 0.9em;
}

/* 用户详情表格 */
.user-details-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.user-details-table th,
.user-details-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.user-details-table th {
    background: #667eea;
    color: white;
    font-weight: 500;
}

.user-details-table tr:hover {
    background: #f5f5f5;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .modal-content {
        width: 95%;
        margin: 20px auto;
    }

    .calendar-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .appid-bar {
        width: 40%;
    }
}

/* 关键词搜索结果样式 */
.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.conversation-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.conversation-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.conversation-index {
    font-size: 1.2em;
    font-weight: bold;
    color: #667eea;
}

.conversation-badge {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9em;
}

.conversation-info {
    margin-bottom: 15px;
}

.info-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    gap: 10px;
}

.info-label {
    font-weight: 500;
    color: #666;
    min-width: 80px;
}

.info-value {
    color: #333;
    font-family: 'Courier New', monospace;
    flex: 1;
}

.btn-copy {
    background: #f0f0f0;
    border: none;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.2s;
}

.btn-copy:hover {
    background: #e0e0e0;
}

.conversation-preview {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 12px;
    margin: 15px 0;
    border-radius: 6px;
}

.preview-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 8px;
}

.preview-content {
    color: #333;
    line-height: 1.6;
}

.conversation-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.conversation-actions .btn {
    flex: 1;
}

/* 自定义模态框样式 */
.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.custom-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #667eea;
    color: white;
    border-radius: 12px 12px 0 0;
}

.custom-modal .modal-header h3 {
    margin: 0;
}

.custom-modal .modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
}

.custom-modal .modal-body {
    background: white;
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 0 0 12px 12px;
}

.matched-messages-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.matched-messages-info p {
    margin: 5px 0;
}

.message-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.message-item.user {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.message-item.assistant {
    background: #f3e5f5;
    border-left: 4px solid #9c27b0;
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.message-role {
    font-weight: bold;
    color: #667eea;
}

.message-time {
    color: #999;
    font-size: 0.9em;
}

.message-content {
    line-height: 1.6;
    color: #333;
}

/* Toast动画 */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
