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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #f5f5f5;
}

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

/* 页面标题 */
.page-header {
    background: white;
    padding: 20px 24px;
    margin-bottom: 16px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.page-header h1 {
    font-size: 20px;
    font-weight: 500;
    color: #333;
}

/* Tab 导航 */
.tabs {
    background: white;
    padding: 0 24px;
    margin-bottom: 16px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    display: flex;
    gap: 32px;
}

.tab-item {
    padding: 16px 0;
    cursor: pointer;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
    user-select: none;
}

.tab-item:hover {
    color: #1890ff;
}

.tab-item.active {
    color: #1890ff;
    border-bottom-color: #1890ff;
}

/* Tab 内容 */
.tab-content {
    display: none;
    background: white;
    padding: 24px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

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

/* 工具栏 */
.toolbar {
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
}

/* 筛选栏 */
.filter-bar {
    margin-bottom: 16px;
    padding: 16px;
    background: #fafafa;
    border-radius: 2px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.filter-bar label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
}

.filter-bar input,
.filter-bar select {
    width: 160px;
    padding: 4px 11px;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    font-size: 14px;
    transition: all 0.3s;
    height: 32px;
    line-height: 1.5715;
}

/* 筛选栏中的自定义下拉框固定宽度 */
.filter-bar .custom-dropdown {
    width: 200px;
}

.filter-bar .dropdown-trigger {
    width: 200px;
}

.filter-bar .dropdown-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-bar input:focus,
.filter-bar select:focus {
    border-color: #40a9ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

/* 筛选按钮容器 - 独立一行 */
.filter-bar .filter-actions {
    width: 100%;
    display: flex;
    gap: 8px;
}

/* 按钮 */
.btn {
    padding: 4px 15px;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    color: #333;
    line-height: 1.5715;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    color: #40a9ff;
    border-color: #40a9ff;
}

.btn-primary {
    background: #1890ff;
    border-color: #1890ff;
    color: white;
}

.btn-primary:hover {
    background: #40a9ff;
    border-color: #40a9ff;
    color: white;
}

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

.btn-danger {
    color: #ff4d4f;
    border-color: #ff4d4f;
}

.btn-danger:hover {
    color: white;
    background: #ff4d4f;
    border-color: #ff4d4f;
}

/* 表格 */
.table-container {
    overflow-x: auto;
    margin-bottom: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    table-layout: fixed;
    min-width: 100%;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* BizCode列 - 固定宽度20%，超出显示省略号 */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    width: 30%;
    max-width: 30%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* VendorKey列 - 固定宽度15% */
.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    width: 15%;
    max-width: 15%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Bucket列 - 固定宽度15% */
.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    width: 15%;
    max-width: 15%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* BucketType列 - 固定宽度10% */
.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    width: 10%;
    max-width: 10%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Memo列 - 固定宽度25%，超出显示省略号 */
.data-table th:nth-child(5),
.data-table td:nth-child(5) {
    width: 20%;
    max-width: 20%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 操作列 - 固定宽度15% */
.data-table th:nth-child(6),
.data-table td:nth-child(6) {
    width: 10%;
    max-width: 10%;
}

/* VendorConfig表格列宽样式 */
#vendor-tab .data-table th:nth-child(1),
#vendor-tab .data-table td:nth-child(1) {
    width: 10%;
    max-width: 10%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#vendor-tab .data-table th:nth-child(2),
#vendor-tab .data-table td:nth-child(2) {
    width: 10%;
    max-width: 10%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#vendor-tab .data-table th:nth-child(3),
#vendor-tab .data-table td:nth-child(3) {
    width: 10%;
    max-width: 10%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#vendor-tab .data-table th:nth-child(4),
#vendor-tab .data-table td:nth-child(4) {
    width: 15%;
    min-width: 15%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#vendor-tab .data-table th:nth-child(5),
#vendor-tab .data-table td:nth-child(5) {
    width: 15%;
    min-width: 15%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#vendor-tab .data-table th:nth-child(6),
#vendor-tab .data-table td:nth-child(6) {
    width: 20%;
    max-width: 20%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#vendor-tab .data-table th:nth-child(7),
#vendor-tab .data-table td:nth-child(7) {
    width: 20%;
    max-width: 20%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 鼠标悬停显示完整内容 - 仅对BizCode和Memo列生效 */
.data-table td:nth-child(1):hover,
.data-table td:nth-child(5):hover {
    overflow: visible;
    white-space: normal;
    word-break: break-all;
    position: relative;
    z-index: 10;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.data-table th {
    background: #fafafa;
    color: #666;
    font-weight: 500;
}

.data-table tbody tr:hover {
    background: #fafafa;
}

.data-table td.loading,
.data-table td.empty {
    text-align: center;
    color: #999;
    padding: 40px;
}

.data-table .actions {
    display: flex;
    gap: 8px;
}

.data-table .actions .btn {
    padding: 2px 8px;
    height: 24px;
    font-size: 12px;
}

/* Code列容器样式 */
.code-cell {
    position: relative;
    padding-left: 32px !important;
}

/* 展开按钮样式 */
.expand-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    color: #1890ff;
    font-size: 12px;
    user-select: none;
    transition: color 0.3s;
}

.expand-btn:hover {
    color: #40a9ff;
}

/* Code文本样式 */
.code-text {
    display: inline-block;
}

/* 版本行样式 - 直接插入主表格 */
.version-row {
    background: #fafafa;
}

.version-row:hover {
    background: #f5f5f5 !important;
}

.version-row td {
    padding: 10px 16px;
    font-size: 13px;
    color: #666;
    border-bottom: 1px solid #f0f0f0;
}

.version-row td.empty {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

/* 版本加载行样式 */
.version-loading-row {
    background: #fafafa;
}

.version-loading-row td {
    padding: 16px;
    text-align: center;
    color: #999;
    border-bottom: 1px solid #f0f0f0;
}

/* 版本缩进 - 添加树形结构视觉指示 */
.version-indent {
    position: relative;
}

.version-indent::before {
    content: '└─';
    position: absolute;
    left: 12px;
    color: #d9d9d9;
    font-weight: normal;
}

/* 版本行中的code文本偏移 */
.version-indent .code-text {
    padding-left: 32px;
}

/* 小按钮样式 */
.btn-sm {
    padding: 1px 6px;
    height: 20px;
    font-size: 12px;
    line-height: 1.2;
}

.version-row .actions {
    display: flex;
    gap: 6px;
}

.version-row .actions .btn-sm {
    padding: 2px 6px;
    height: 22px;
}

/* 分页 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.page-info {
    color: #666;
    font-size: 14px;
}

/* 对话框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.close {
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-group label .required {
    color: #ff4d4f;
    margin-right: 4px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 4px 11px;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
}

.form-group textarea {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    resize: vertical;
    min-height: 120px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #40a9ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #999;
    font-size: 12px;
}

.form-group .error-msg {
    color: #ff4d4f;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.form-group .error-msg.show {
    display: block;
}

.form-group .json-toolbar {
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
}

.form-group .json-toolbar .btn {
    padding: 2px 8px;
    height: 24px;
    font-size: 12px;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

/* UrlPattern 前缀+后缀容器 */
.url-pattern-container {
    display: flex;
    align-items: stretch;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    transition: all 0.3s;
    overflow: hidden;
}

.url-pattern-container:focus-within {
    border-color: #40a9ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.url-pattern-prefix {
    padding: 4px 11px;
    background-color: #f5f5f5;
    color: #666;
    white-space: nowrap;
    border-right: 1px solid #d9d9d9;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    display: flex;
    align-items: center;
    user-select: none;
}

#form-urlPattern-suffix {
    flex: 1;
    border: none;
    padding: 4px 11px;
    outline: none;
    font-size: 14px;
    min-width: 0;
}

.form-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

/* 自定义下拉框组件 */
.custom-dropdown {
    position: relative;
    width: 100%;
}

/* 下拉框触发器 - 模拟标准select外观 */
.dropdown-trigger {
    width: 100%;
    padding: 4px 30px 4px 11px;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 32px;
    user-select: none;
}

.dropdown-trigger:hover {
    border-color: #40a9ff;
}

.dropdown-trigger.active {
    border-color: #40a9ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

/* 显示当前选中值 */
.dropdown-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.dropdown-value.placeholder {
    color: #bfbfbf;
}

/* 下拉箭头 */
.dropdown-arrow {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 12px;
    transition: transform 0.3s;
    pointer-events: none;
}

.dropdown-trigger.active .dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* 下拉面板 */
.dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    display: none;
    flex-direction: column;
    max-height: 300px;
    min-width: 300px;
}

.dropdown-panel.show {
    display: flex;
}

/* 下拉面板中的搜索框 */
.dropdown-search {
    width: 100%;
    padding: 8px 11px;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    outline: none;
    flex-shrink: 0;
}

.dropdown-search:focus {
    border-bottom-color: #40a9ff;
}

/* 选项列表容器 */
.dropdown-options {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* 单个选项 */
.dropdown-option {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.3s;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-option:hover {
    background-color: #f5f5f5;
}

.dropdown-option.selected {
    background-color: #e6f7ff;
    color: #1890ff;
    font-weight: 500;
}

.dropdown-option.disabled {
    color: #bfbfbf;
    cursor: not-allowed;
    background-color: #fafafa;
}

.dropdown-option.disabled:hover {
    background-color: #fafafa;
}

/* 无结果提示 */
.dropdown-options .no-results {
    padding: 16px 12px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* 提示消息 */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: white;
    border-radius: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 8px;
    max-width: 500px;
}

.toast.show {
    display: flex;
    animation: slideDown 0.3s ease;
}

.toast.success {
    border-left: 4px solid #52c41a;
}

.toast.error {
    border-left: 4px solid #ff4d4f;
}

.toast.info {
    border-left: 4px solid #1890ff;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 配置面板 */
.config-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 12px 16px;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.config-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

.config-panel input {
    width: 200px;
    padding: 2px 8px;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    font-size: 12px;
}

/* 响应式 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar label {
        width: 100%;
    }

    .filter-bar input {
        width: 100%;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .config-panel {
        position: static;
        margin-top: 16px;
    }

    .config-panel label {
        flex-direction: column;
        align-items: stretch;
    }

    .config-panel input {
        width: 100%;
    }

    /* 移动端下拉面板调整 */
    .dropdown-panel {
        max-height: 250px;
    }
}
