/* 历史记录模态框样式 */

/* 主模态框 */
.history-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: historyModalFadeIn 0.3s ease;
}

.history-modal-overlay.history-modal-closing {
    animation: historyModalFadeOut 0.3s ease forwards;
}

.history-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
    overflow: hidden;
    animation: historyModalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 模态框头部 */
.history-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.history-modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
}

.history-modal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-search-btn,
.history-export-btn,
.history-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #666;
}

.history-search-btn:hover,
.history-export-btn:hover {
    background: #e9ecef;
    color: #333;
}

.history-modal-close {
    font-size: 24px;
    width: 30px;
    height: 30px;
}

.history-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* 模态框主体 */
.history-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* 搜索容器 */
.history-search-container {
    padding: 16px 24px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.history-search-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.history-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.history-search-clear:hover {
    background: #e9ecef;
    color: #333;
}

/* 历史记录列表 */
.history-list {
    padding: 24px;
}

.no-history {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

/* 历史记录项 */
.history-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    background: #ffffff;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.1);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 16px;
}

.history-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    flex: 1;
    line-height: 1.4;
}

.history-timestamp {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* 表单数据预览 */
.history-preview {
    margin-bottom: 12px;
}

.form-data-preview {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
}

.preview-item {
    display: flex;
    margin-bottom: 6px;
    font-size: 13px;
}

.preview-item:last-child {
    margin-bottom: 0;
}

.preview-label {
    font-weight: 500;
    color: #333;
    min-width: 80px;
    margin-right: 8px;
    flex-shrink: 0;
}

.preview-value {
    color: #666;
    flex: 1;
    word-break: break-word;
}

.preview-more {
    font-size: 12px;
    color: #888;
    font-style: italic;
    margin-top: 6px;
}

.no-data {
    color: #999;
    font-size: 13px;
    font-style: italic;
}

/* 标签 */
.history-tags {
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.history-tag {
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* 历史记录操作按钮 */
.history-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-load-btn,
.history-view-btn,
.history-delete-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.history-load-btn {
    background: #007bff;
    color: white;
}

.history-load-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.history-view-btn {
    background: #6c757d;
    color: white;
}

.history-view-btn:hover {
    background: #545b62;
    transform: translateY(-1px);
}

.history-delete-btn {
    background: #dc3545;
    color: white;
}

.history-delete-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.history-actions .material-icons {
    font-size: 16px;
}

/* 模态框底部 */
.history-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.history-stats {
    font-size: 14px;
    color: #666;
}

.history-pagination {
    display: flex;
    gap: 8px;
}

/* 详情模态框 */
.history-details-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    animation: historyModalFadeIn 0.3s ease;
}

.history-details-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    animation: historyModalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
    font-family: inherit;
}

.history-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.history-details-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.history-details-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.history-details-close:hover {
    background: #f0f0f0;
    color: #333;
}

.history-details-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* 详情节 */
.details-section {
    margin-bottom: 24px;
}

.details-section:last-child {
    margin-bottom: 0;
}

.details-section h4 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 2px solid #007bff;
    padding-bottom: 6px;
}

.details-content {
    line-height: 1.6;
}

.details-content p {
    margin: 8px 0;
    font-size: 14px;
    color: #666;
}

.details-content p strong {
    color: #333;
    font-weight: 500;
}

/* 表单数据显示 */
.form-data-display {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.form-data-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e9ecef;
}

.form-data-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.form-data-label {
    font-weight: 500;
    color: #333;
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}

.form-data-value {
    color: #666;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    background: #ffffff;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

/* 结果内容显示 - 支持 markdown 和 HTML 渲染 */
.result-content-display {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    word-break: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

/* Support for markdown content within result-content-display */
.result-content-display .markdown-content {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

/* Plain text content styling */
.result-content-display .plain-text-content {
    white-space: pre-wrap;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
}

/* Table wrapper for responsive tables */
.result-content-display .table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

/* Markdown table styles within result-content-display */
.result-content-display .markdown-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background-color: #ffffff;
    font-size: 13px;
}

.result-content-display .markdown-table th,
.result-content-display .markdown-table td {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    text-align: left;
    word-break: break-word;
    transition: background-color 0.2s ease;
}

.result-content-display .markdown-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #1e293b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-content-display .markdown-table tr:nth-child(2n) {
    background-color: #f8fafc;
}

.result-content-display .markdown-table tr:hover {
    background-color: #f1f5f9;
}

/* Markdown headings within result-content-display */
.result-content-display .markdown-heading {
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.3;
}

.result-content-display h1.markdown-heading {
    font-size: 24px;
    color: #1e293b;
}

.result-content-display h2.markdown-heading {
    font-size: 20px;
    color: #334155;
}

.result-content-display h3.markdown-heading {
    font-size: 18px;
    color: #475569;
}

.result-content-display h4.markdown-heading {
    font-size: 16px;
    color: #64748b;
}

/* Markdown lists within result-content-display */
.result-content-display .markdown-list {
    margin: 12px 0;
    padding-left: 20px;
}

.result-content-display .markdown-list li {
    margin: 6px 0;
    line-height: 1.5;
}

/* Markdown blockquotes within result-content-display */
.result-content-display .markdown-blockquote {
    margin: 16px 0;
    padding: 12px 16px;
    border-left: 4px solid #3b82f6;
    background-color: #f0f9ff;
    border-radius: 0 6px 6px 0;
}

.result-content-display .markdown-blockquote p {
    margin: 0;
    color: #1e40af;
    font-style: italic;
}

/* Anchor links within result-content-display */
.result-content-display .anchor-link {
    color: #6b7280;
    text-decoration: none;
    margin-right: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.result-content-display .markdown-heading:hover .anchor-link {
    opacity: 1;
}

/* Error display styling */
.result-content-display .format-error {
    color: #dc2626;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    padding: 12px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
}

.result-content-display .no-content {
    color: #6b7280;
    font-style: italic;
    text-align: center;
    padding: 24px;
}

.history-details-footer {
    padding: 20px 24px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
}

/* 动画效果 */
@keyframes historyModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes historyModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes historyModalFadeOut {
    from { 
        opacity: 1; 
        transform: scale(1);
    }
    to { 
        opacity: 0; 
        transform: scale(0.95);
    }
}

/* 暗色主题适配 */
[data-theme="dark"] .history-modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .history-modal {
    background: #1f2937;
    color: #f3f4f6;
}

[data-theme="dark"] .history-modal-header {
    background: #1f2937;
    border-bottom-color: #374151;
}

[data-theme="dark"] .history-modal-header h3 {
    color: #f3f4f6;
}

[data-theme="dark"] .history-search-btn,
[data-theme="dark"] .history-export-btn,
[data-theme="dark"] .history-modal-close {
    color: #9ca3af;
}

[data-theme="dark"] .history-search-btn:hover,
[data-theme="dark"] .history-export-btn:hover {
    background: #374151;
    color: #f3f4f6;
}

[data-theme="dark"] .history-modal-close:hover {
    background: #374151;
    color: #f3f4f6;
}

[data-theme="dark"] .history-search-container {
    background: #1f2937;
    border-bottom-color: #374151;
}

[data-theme="dark"] .history-search-input {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

[data-theme="dark"] .history-search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .history-search-clear {
    color: #9ca3af;
}

[data-theme="dark"] .history-search-clear:hover {
    background: #374151;
    color: #f3f4f6;
}

[data-theme="dark"] .history-item {
    background: #374151;
    border-color: #4b5563;
}

[data-theme="dark"] .history-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .history-title {
    color: #f3f4f6;
}

[data-theme="dark"] .history-timestamp,
[data-theme="dark"] .history-description {
    color: #9ca3af;
}

[data-theme="dark"] .form-data-preview {
    background: #1f2937;
}

[data-theme="dark"] .preview-label {
    color: #f3f4f6;
}

[data-theme="dark"] .preview-value {
    color: #d1d5db;
}

[data-theme="dark"] .history-modal-footer {
    background: #1f2937;
    border-top-color: #374151;
}

[data-theme="dark"] .history-stats {
    color: #9ca3af;
}

/* 详情模态框暗色主题 */
[data-theme="dark"] .history-details-modal {
    background: #1f2937;
    color: #f3f4f6;
}

[data-theme="dark"] .history-details-header {
    background: #1f2937;
    border-bottom-color: #374151;
}

[data-theme="dark"] .history-details-header h3 {
    color: #f3f4f6;
}

[data-theme="dark"] .history-details-close {
    color: #9ca3af;
}

[data-theme="dark"] .history-details-close:hover {
    background: #374151;
    color: #f3f4f6;
}

[data-theme="dark"] .details-section h4 {
    color: #f3f4f6;
    border-bottom-color: #3b82f6;
}

[data-theme="dark"] .details-content p {
    color: #d1d5db;
}

[data-theme="dark"] .details-content p strong {
    color: #f3f4f6;
}

[data-theme="dark"] .form-data-display {
    background: #374151;
}

[data-theme="dark"] .form-data-item {
    border-bottom-color: #4b5563;
}

[data-theme="dark"] .form-data-label {
    color: #f3f4f6;
}

[data-theme="dark"] .form-data-value {
    background: #1f2937;
    border-color: #4b5563;
    color: #d1d5db;
}

[data-theme="dark"] .result-content-display {
    background: #374151;
    color: #d1d5db;
}

[data-theme="dark"] .result-content-display .markdown-content {
    background: transparent;
}

[data-theme="dark"] .result-content-display .plain-text-content {
    color: #e5e7eb;
}

/* Dark theme table styles */
[data-theme="dark"] .result-content-display .table-wrapper {
    border-color: #374151;
    background: #111827;
}

[data-theme="dark"] .result-content-display .markdown-table {
    background-color: #111827;
    color: #f3f4f6;
}

[data-theme="dark"] .result-content-display .markdown-table th,
[data-theme="dark"] .result-content-display .markdown-table td {
    border-color: #374151;
    color: #f3f4f6;
}

[data-theme="dark"] .result-content-display .markdown-table th {
    background-color: #0f172a;
    color: #f1f5f9;
}

[data-theme="dark"] .result-content-display .markdown-table tr:nth-child(2n) {
    background-color: #0f172a;
}

[data-theme="dark"] .result-content-display .markdown-table tr:hover {
    background-color: #1e293b;
}

/* Dark theme headings */
[data-theme="dark"] .result-content-display h1.markdown-heading {
    color: #f1f5f9;
}

[data-theme="dark"] .result-content-display h2.markdown-heading {
    color: #e2e8f0;
}

[data-theme="dark"] .result-content-display h3.markdown-heading {
    color: #cbd5e1;
}

[data-theme="dark"] .result-content-display h4.markdown-heading {
    color: #94a3b8;
}

/* Dark theme blockquotes */
[data-theme="dark"] .result-content-display .markdown-blockquote {
    border-left-color: #3b82f6;
    background-color: #1e3a8a;
    color: #dbeafe;
}

[data-theme="dark"] .result-content-display .markdown-blockquote p {
    color: #bfdbfe;
}

/* Dark theme anchor links */
[data-theme="dark"] .result-content-display .anchor-link {
    color: #9ca3af;
}

/* Dark theme error display */
[data-theme="dark"] .result-content-display .format-error {
    color: #fca5a5;
    background-color: #450a0a;
    border-color: #7f1d1d;
}

[data-theme="dark"] .result-content-display .no-content {
    color: #9ca3af;
}

[data-theme="dark"] .history-details-footer {
    background: #1f2937;
    border-top-color: #374151;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .history-modal {
        width: 98%;
        max-height: 90vh;
    }

    .history-modal-header {
        padding: 16px 20px;
    }

    .history-modal-header h3 {
        font-size: 16px;
    }

    .history-list {
        padding: 16px;
    }

    .history-item {
        padding: 16px;
    }

    .history-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .history-timestamp {
        align-self: flex-end;
    }

    .history-actions {
        justify-content: flex-start;
    }

    .history-modal-footer {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
} 