/* ===================================
   达梦 8 Web 数据库管理工具 - 美化样式
   =================================== */

/* 全局变量 */
:root {
    --primary-color: #2196F3;
    --success-color: #4CAF50;
    --danger-color: #F44336;
    --warning-color: #FF9800;
    --dark-bg: #1a1a2e;
    --light-bg: #f5f6fa;
    --border-color: #e0e0e0;
    --sidebar-width: 250px;
}

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'SimSun', Arial, sans-serif;
    font-size: 14px;
    background-color: var(--light-bg);
    color: #333;
    overflow-x: hidden;
}

/* 导航栏渐变背景 */
.bg-gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 主容器 */
.main-container {
    height: calc(100vh - 56px - 60px);
    margin-top: 0;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    min-height: 56px;
}

/* 对象浏览器侧边栏 - 完全贴合左侧 */
.sidebar {
    height: calc(100vh - 112px);
    overflow-y: auto;
    overflow-x: hidden;
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* 对象浏览器搜索框 - 无间隙 */
#objectBrowserSearch {
    border-radius: 4px;
}

/* 树形节点美化 */
.tree-node {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 2px 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
}

.tree-node:hover {
    background-color: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.2);
}

.tree-node.selected {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 500;
}

.tree-children {
    margin-left: 24px;
    border-left: 2px solid var(--border-color);
    padding-left: 8px;
}

.tree-icon {
    margin-right: 8px;
    width: 18px;
    text-align: center;
    display: inline-block;
    font-size: 16px;
}

/* 工具栏面板 */
.toolbar-panel {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* SQL 编辑器美化 */
.sql-editor {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    min-height: 120px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s ease;
    background-color: #fafafa;
}

.sql-editor:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    background-color: white;
}

.editor-hint {
    position: absolute;
    bottom: -25px;
    right: 0;
}

/* 结果面板 */
.result-panel {
    height: calc(100vh - 260px);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-radius: 0;
    margin: 0;
    display: flex;           /* 使用 flex 布局 */
    flex-direction: column;  /* 垂直排列 */
}

.tab-content {
    flex: 1;                 /* 占满剩余空间 */
    overflow: visible;       /* ✅ 允许溢出，让内部处理 */
    background-color: white;
    display: flex;           /* flex 布局 */
    flex-direction: column;  /* 垂直排列 */
    position: relative;      /* 为子元素提供定位参考 */
}

.result-scroll,
.message-scroll {
    flex: 1;                 /* 占满剩余空间 */
    overflow: auto;          /* ✅ 双向自动滚动 */
    min-height: 0;           /* 关键：允许 flex 子项缩小 */
}

/* 表格包装器 - 用于固定分页 */
.table-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;        /* ✅ 隐藏溢出，让#resultTable 自己滚动 */
}

/* 确保表格容器支持滚动 */
#resultTable {
    flex: 1;                 /* 占满 table-wrapper 的剩余空间（减去工具栏和分页）*/
    overflow-x: auto;        /* ✅ 横向滚动 */
    overflow-y: auto;        /* ✅ 纵向滚动 */
    min-height: 0;           /* 关键：允许 flex 子项缩小 */
}

/* 结果表格美化 */
.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background-color: white;
    table-layout: auto; /* 自动列宽，支持横向滚动 */
    min-width: max-content; /* 最小宽度为内容宽度 */
}

.result-table th,
.result-table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: center; /* 数据居中显示 */
    vertical-align: middle;
    transition: background-color 0.2s ease;
    white-space: nowrap; /* 不换行，支持横向滚动 */
}

.result-table th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #333;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    user-select: none;
}

.result-table th:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.result-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.result-table tr:nth-child(odd) {
    background-color: white;
}

.result-table tr:hover {
    background-color: #f8f9ff;
}

.result-table tr.selected {
    background-color: rgba(102, 126, 234, 0.15);
}

/* 状态栏 */
footer {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.status-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
}

/* 按钮美化 */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.btn-primary {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
}

.btn-warning {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #F44336 0%, #D32F2F 100%);
}

/* 消息提示美化 */
.message-success {
    color: #2e7d32;
    padding: 10px 15px;
    margin: 6px 0;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(76, 175, 80, 0.05) 100%);
    border-left: 4px solid #4CAF50;
    border-radius: 4px;
}

.message-error {
    color: #c62828;
    padding: 10px 15px;
    margin: 6px 0;
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.1) 0%, rgba(244, 67, 54, 0.05) 100%);
    border-left: 4px solid #F44336;
    border-radius: 4px;
}

.message-info {
    color: #0277bd;
    padding: 10px 15px;
    margin: 6px 0;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.1) 0%, rgba(33, 150, 243, 0.05) 100%);
    border-left: 4px solid #2196F3;
    border-radius: 4px;
}

/* 模态框美化 */
.modal-content {
    border-radius: 12px;
    overflow: hidden;
}

.modal-header {
    border-bottom: none;
}

.modal-body {
    padding: 2rem;
}

.form-control {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-label {
    color: #555;
    margin-bottom: 0.5rem;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 5px;
    border: 2px solid #f1f1f1;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* 标签页美化 */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
}

.nav-tabs .nav-link {
    border: none;
    color: #666;
    font-weight: 500;
    padding: 12px 20px;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: transparent;
}

.nav-tabs .nav-link:hover {
    border-color: var(--border-color);
    background-color: rgba(102, 126, 234, 0.05);
}

/* 加载动画 */
.loading {
    text-align: center;
    padding: 40px 20px;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

/* 空状态提示 */
.text-center.text-muted {
    color: #999 !important;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .main-container {
        height: calc(100vh - 112px - 60px);
    }
    
    .sidebar-header h6 {
        font-size: 12px;
    }
    
    .toolbar-panel .btn-group {
        margin-bottom: 8px;
    }
    
    .result-panel {
        height: calc(100vh - 320px);
    }
    
    /* 移动端分页控件调整 */
    .pagination-container {
        flex-direction: column;       /* 垂直排列 */
        gap: 8px;
    }
    
    .pagination-left,
    .pagination-right {
        min-width: auto;
        text-align: center;
    }
    
    .pagination-center {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-success,
.message-error,
.message-info {
    animation: fadeIn 0.3s ease;
}

/* 下拉菜单美化 */
.dropdown-menu {
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 8px 0;
}

.dropdown-item {
    padding: 10px 20px;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
}

/* 徽章美化 */
.badge {
    padding: 6px 12px;
    font-weight: 500;
    border-radius: 20px;
}

/* 表格工具栏 - Navicat 风格 */
.table-toolbar {
    position: sticky;
    top: 0;
    z-index: 50;
}

.table-toolbar .btn-group .btn {
    margin-right: 4px;
}

.search-box input {
    transition: all 0.2s ease;
}

.search-box input:focus {
    width: 250px !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

/* 分页控件样式 - Bootstrap 风格（内嵌在表格区域顶部）*/
.pagination-container {
    position: sticky;        /* ✅ 粘性定位在顶部 */
    top: 0;                  /* ✅ 粘在工具栏下面 */
    z-index: 40;             /* ✅ 在表头之上 (表头 sticky-top) */
}

.pagination-left {
    min-width: 200px;
}

.pagination-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination-center .btn-group .btn {
    padding: 6px 14px;
    font-size: 13px;
    margin: 0 2px;
    transition: all 0.2s ease;
}

.pagination-center .btn-group .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pagination-center .page-number {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #666;
}

.pagination-right {
    min-width: 120px;
    text-align: right;
}

.pagination-info {
    color: #666;
    font-size: 13px;
    white-space: nowrap;
}

/* SQL 智能提示下拉框 */
.autocomplete-dropdown {
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    overflow: hidden;
}

.autocomplete-item {
    padding: 8px 12px;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: rgba(102, 126, 234, 0.1);
    cursor: pointer;
}

.autocomplete-item .fw-bold {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.autocomplete-item .text-muted {
    font-size: 12px;
}

/* 列设置复选框样式优化 */
#columnModal .form-check-input {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    cursor: pointer;
}

#columnModal .form-check-label {
    cursor: pointer;
    word-break: break-all;
    max-width: calc(100% - 30px);
}

#columnModal .card-sm {
    min-height: 50px;
}
