/* 自定义样式 */
body {
    background-color: #f8f9fa;
}

/* 业务规则管理页面全高度布局 */
#business-rules-section {
    height: calc(100vh - 120px); /* 减去导航栏和padding的高度 */
}

#business-rules-section .row {
    height: 100%;
}

#business-rules-section .card {
    min-height: 100%;
}

/* 左侧分类树区域自适应高度 */
#business-rules-section .col-md-2 .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#business-rules-section .col-md-2 .card-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    min-height: 0; /* 确保flex子项可以收缩 */
}

#business-rules-section .col-md-2 .card-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(0,0,0,.125);
}

#business-rules-categories-tree {
    height: 100%;
    overflow-y: auto;
    max-height: calc(100vh - 300px); /* 限制最大高度，为数据库选择器留出空间 */
}

/* 搜索框高亮样式 */
.search-highlight {
    background-color: #fff3cd;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

/* 搜索结果信息样式 */
.alert-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

/* 业务规则卡片样式优化 */
#business-rules-list .card {
    border: 1px solid #e3e6f0;
    transition: all 0.15s ease-in-out;
}

#business-rules-list .card:hover {
    border-color: #5a6c7d;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

/* 搜索框样式优化 */
#business-rules-search:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.tab-content {
    display: none;
}

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

.nav-link {
    cursor: pointer;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.125);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.template-item {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.template-item:hover {
    background-color: #f8f9fa;
    border-color: #0d6efd;
}

.template-item.selected {
    background-color: #e7f3ff;
    border-color: #0d6efd;
}

.query-result {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: white;
}

.query-result.success {
    border-left: 4px solid #198754;
}

.query-result.warning {
    border-left: 4px solid #ffc107;
}

.query-result.error {
    border-left: 4px solid #dc3545;
}

.match-item {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.confidence-high {
    color: #198754;
    font-weight: bold;
}

.confidence-medium {
    color: #ffc107;
    font-weight: bold;
}

.confidence-low {
    color: #6c757d;
    font-weight: bold;
}

.term-item {
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background-color: white;
}

.term-category {
    background-color: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

.btn-loading {
    position: relative;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.alert-custom {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.code-block {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.badge-category {
    background-color: #6f42c1;
}

/* Intent Type 标签样式 */
.badge-intent-type {
    background-color: #17a2b8;
    color: white;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
}

.badge-intent-type.intent-data-query {
    background-color: #007bff;
}

.badge-intent-type.intent-data-analysis {
    background-color: #28a745;
}

.badge-intent-type.intent-report-generation {
    background-color: #ffc107;
    color: #212529;
}

.badge-intent-type.intent-user-management {
    background-color: #6f42c1;
}

.badge-intent-type.intent-system-config {
    background-color: #fd7e14;
}

.badge-intent-type.intent-general-inquiry {
    background-color: #6c757d;
}

.badge-intent-type.intent-other {
    background-color: #dc3545;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .card-body {
        padding: 1rem 0.5rem;
    }
    
    .btn-group .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* 移动端业务规则管理布局优化 */
    #business-rules-section {
        height: calc(100vh - 80px); /* 移动端减少导航栏高度 */
    }
    
    #business-rules-section .row {
        flex-direction: column;
        height: auto;
    }
    
    #business-rules-section .col-md-6 {
        margin-bottom: 1rem;
    }
    
    #business-rules-section .col-md-2 {
        margin-bottom: 1rem;
        height: 40vh; /* 移动端分类树占用40%视窗高度 */
    }
    
    #business-rules-section .col-md-2 .card {
        height: 100%;
    }
    
    #business-rules-section .col-md-5,
    #business-rules-section .col-md-6 {
        margin-bottom: 1rem;
    }
    
    #business-rules-section .col-md-6:first-child {
        order: 2; /* 在移动端将表单放到下方 */
    }
    
    #business-rules-section .col-md-6:last-child {
        order: 1; /* 在移动端将列表放到上方 */
        flex: 1;
    }
    
    /* 移动端搜索框样式 */
    #business-rules-search {
        font-size: 16px; /* 防止iOS Safari缩放 */
    }
}

/* 小屏设备进一步优化 */
@media (max-width: 576px) {
    #business-rules-section .card-body {
        padding: 0.75rem;
    }
    
    #business-rules-section .btn-group-sm .btn {
        padding: 0.125rem 0.25rem;
        font-size: 0.75rem;
    }
    
    #business-rules-section .card-title {
        font-size: 0.9rem;
    }
    
    #business-rules-section .card-text {
        font-size: 0.8rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 表格样式 */
.table-custom {
    --bs-table-bg: white;
}

.table-custom th {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    font-weight: 600;
}

/* 统计卡片动画 */
.card.stats-card {
    transition: transform 0.2s ease-in-out;
}

.card.stats-card:hover {
    transform: translateY(-2px);
}

/* 加载状态 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* 文件拖拽区域 */
.file-drop-zone {
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    padding: 2rem;
    text-align: center;
    background-color: #f8f9fa;
    transition: all 0.15s ease-in-out;
}

.file-drop-zone.dragover {
    border-color: #0d6efd;
    background-color: #e7f3ff;
}

.file-drop-zone:hover {
    border-color: #0d6efd;
}

/* 成功/错误状态指示器 */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

.status-success {
    background-color: #198754;
}

.status-warning {
    background-color: #ffc107;
}

.status-error {
    background-color: #dc3545;
}

/* 模态框优化 */
.modal-content {
    border-radius: 0.5rem;
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

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

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

/* 工具提示样式 */
.tooltip-custom {
    font-size: 0.875rem;
}

/* 分页样式 */
.pagination-custom .page-link {
    border-color: #dee2e6;
    color: #6c757d;
}

.pagination-custom .page-link:hover {
    background-color: #f8f9fa;
    border-color: #0d6efd;
    color: #0d6efd;
}

.pagination-custom .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* 高亮搜索结果 */
.search-highlight {
    background-color: #fff3cd;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

/* 动画效果 */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-down {
    animation: slideDown 0.3s ease-in-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 多SQL语句结果显示样式 */
.multi-sql-results .card {
    border: 1px solid #e3e6f0;
    transition: all 0.15s ease-in-out;
}

.multi-sql-results .card:hover {
    border-color: #5a6c7d;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.multi-sql-results .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e3e6f0;
}

.multi-sql-results .card-header h6 {
    color: #495057;
}

.multi-sql-results .card-header .btn-link {
    color: #495057;
    text-decoration: none;
}

.multi-sql-results .card-header .btn-link:hover {
    color: #0d6efd;
}

.multi-sql-results .card-header .btn-link:focus {
    box-shadow: none;
}

.multi-sql-results .table th {
    background-color: #f8f9fa;
    border-color: #e3e6f0;
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
}

.multi-sql-results .table td {
    font-size: 0.875rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multi-sql-results .table-responsive {
    border: 1px solid #e3e6f0;
    border-radius: 0.375rem;
    background-color: white;
}

.multi-sql-results .badge {
    font-size: 0.75rem;
}

.multi-sql-results .btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* SQL结果详情弹窗样式 */
#sql-result-detail-modal .modal-dialog {
    max-width: 90vw;
}

#sql-result-detail-modal .table-responsive {
    max-height: 60vh;
    border: 1px solid #e3e6f0;
    border-radius: 0.375rem;
}

#sql-result-detail-modal .table {
    margin-bottom: 0;
}

#sql-result-detail-modal .table th {
    background-color: #343a40;
    color: white;
    border-color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
}

#sql-result-detail-modal .table td {
    max-width: 300px;
    word-wrap: break-word;
    white-space: normal;
}

/* SQL语句详情弹窗样式 */
#sql-statement-detail-modal pre {
    background-color: #f8f9fa;
    border: 1px solid #e3e6f0;
    border-radius: 0.375rem;
    color: #495057;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* 语句折叠动画 */
.multi-sql-results .collapse {
    transition: height 0.35s ease;
}

.multi-sql-results .collapsing {
    transition: height 0.35s ease;
}

/* 统计信息样式 */
.multi-sql-results .alert-info {
    background-color: #e7f3ff;
    border-color: #b8daff;
    color: #004085;
}

/* 响应式设计优化 */
@media (max-width: 768px) {
    .multi-sql-results .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .multi-sql-results .btn-group .btn {
        margin-bottom: 0.25rem;
        border-radius: 0.375rem !important;
    }
    
    .multi-sql-results .card-header .row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .multi-sql-results .card-header .col-md-6 {
        text-align: left;
    }
    
    .multi-sql-results .table td {
        max-width: 150px;
        font-size: 0.8rem;
    }
    
    #sql-result-detail-modal .modal-dialog {
        max-width: 95vw;
        margin: 0.5rem;
    }
    
    #sql-result-detail-modal .table-responsive {
        max-height: 50vh;
    }
    
    #sql-result-detail-modal .table td {
        max-width: 200px;
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .multi-sql-results .card-body {
        padding: 0.75rem;
    }
    
    .multi-sql-results .btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    .multi-sql-results .table {
        font-size: 0.75rem;
    }
    
    .multi-sql-results .table td {
        max-width: 100px;
        padding: 0.25rem;
    }
}

/* Monaco Editor 容器样式 */
.monaco-sql-container {
    border-radius: 0.375rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.monaco-sql-container .monaco-editor {
    border-radius: 0.375rem;
}

/* 查询结果中的匹配项样式 */
.match-item {
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: #fff;
    transition: box-shadow 0.2s ease;
}

.match-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.confidence-high {
    color: #198754;
    font-weight: bold;
}

.confidence-medium {
    color: #fd7e14;
    font-weight: bold;
}

.confidence-low {
    color: #dc3545;
    font-weight: bold;
}

/* 富文本编辑器样式 */
.rich-text-editor {
    min-height: 80px;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background: white;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-wrap: break-word;
    position: relative;
}

.rich-text-editor:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.rich-text-editor:empty:before {
    content: attr(data-placeholder);
    color: #6c757d;
    font-style: italic;
}

/* 实体识别loading状态样式 */
.rich-text-editor.entity-recognizing {
    border-color: #17a2b8;
    background-color: #f8fffe;
    position: relative;
}

.rich-text-editor.entity-recognizing::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 12px;
    width: 16px;
    height: 16px;
    border: 2px solid #17a2b8;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: entity-recognition-spin 1s linear infinite;
    z-index: 10;
}

.rich-text-editor.entity-recognizing::before {
    content: "主体和术语识别中...";
    position: absolute;
    top: 8px;
    right: 35px;
    font-size: 0.75rem;
    color: #17a2b8;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 10;
    font-weight: 500;
}

@keyframes entity-recognition-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 编辑器中的实体标签样式 */
.rich-text-editor .entity-tag {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 2px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.rich-text-editor .entity-tag:hover {
    opacity: 0.8;
}

.rich-text-editor .entity-tag.removable:after {
    content: '×';
    margin-left: 4px;
    opacity: 0.7;
    font-weight: bold;
}

.rich-text-editor .entity-tag.removable:hover:after {
    opacity: 1;
}

/* 不同类型实体的内联标签颜色 */
.rich-text-editor .entity-tag.type-fund {
    background-color: #198754;
    color: white;
}

.rich-text-editor .entity-tag.type-institution {
    background-color: #0dcaf0;
    color: #000;
}

.rich-text-editor .entity-tag.type-project {
    background-color: #ffc107;
    color: #000;
}

.rich-text-editor .entity-tag.type-person {
    background-color: #6c757d;
    color: white;
}

.rich-text-editor .entity-tag.type-financial {
    background-color: #dc3545;
    color: white;
}

.rich-text-editor .entity-tag.type-date {
    background-color: #212529;
    color: white;
}

.rich-text-editor .entity-tag.type-number {
    background-color: #0d6efd;
    color: white;
}

.rich-text-editor .entity-tag.type-terminology {
    background-color: #6f42c1;
    color: white;
}

.rich-text-editor .entity-tag.type-default {
    background-color: #6c757d;
    color: white;
}



/* 实体标签特殊样式 */
.recognition-results .badge.text-dark {
    color: #212529 !important;
}

.recognition-results .badge .opacity-75 {
    opacity: 0.75;
}

/* 术语和实体标签的不同样式 */
.recognition-results .badge[title*="术语"] {
    border: 1px solid rgba(255,255,255,0.3);
}

.recognition-results .badge[title*="实体"] {
    border: 1px solid rgba(0,0,0,0.1);
}