/* ========================================
   全局基础样式
======================================== */
html, body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    line-height: 1.5;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

/* ========================================
   内容容器
======================================== */
#content {
    display: flex;
    flex-direction: column;
    padding: 10px;
    width: 100%;
    max-width: 100%;
    /* 2026-4-8 */
    /* overflow-x: hidden; */
}

/* ========================================
   表单 & 输入框
======================================== */
.field-container {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    position: relative;
    flex-wrap: wrap;
    gap: 4px;
}
.input-select-pair {
    width: 100% !important; /* 取消50%限制，占满整行 */
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
}

.input-with-suggestions,
.input-value {
    flex: 1 !important; /* 自适应宽度，自动腾出空间 */
    min-width: 80px !important;
    max-width: 120px !important;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    flex-wrap: wrap !important;
}

/* 下拉建议框 */
.suggestions,
.field-suggestions,
.value-suggestions {
    position: absolute;
    list-style: none;
    padding: 0;
    margin: 0;
    background: #fff;
    border: 1px solid #ccc;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    width: 200px;
    border-radius: 0 0 4px 4px;
}

.suggestions,
.field-suggestions {
    top: 100%;
    left: 0;
}

.value-suggestions {
    top: 100%;
    left: 210px;
}

.suggestion-item {
    padding: 6px 10px;
    cursor: pointer;
}

.suggestion-item:hover {
    background-color: #f0f0f0;
}

/* 包含/排除框加宽，占更多空间 */
.js-example-basic-multiple,
.js-example-basic-exclude {
    width: 30% !important; /* 从28%加宽到35%，条件列更宽 */
}

/* 固定“仅查空值”标签宽度，防止挤压换行 */
.only-empty-label {
    width: 60px !important;
    flex-shrink: 0 !important; /* 禁止被压缩 */
    margin: 0 !important;
    white-space: nowrap !important;
  }
/* ========================================
   按钮样式
======================================== */
.button-container {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.clear-all-values-btn {
    background: #007bff;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.clear-all-values-btn:hover {
    background: #dc3545;
}

/* ========================================
   弹出层
======================================== */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 1000;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* ========================================
   表格 & 滚动容器（电脑+手机全适配）
======================================== */
#query-results {
    width: 100%;
    margin-top: 10px;
}

.scrollable-table {
    width: 100%;
    /* 核心修复：取消overflow，让sticky能粘到页面顶部 */
    overflow-x: visible !important;
    overflow-y: visible !important;

    -webkit-overflow-scrolling: touch;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.scrollable-table table {
    width: 100%;
    min-width: 320px;
    border-collapse: collapse;
    table-layout: fixed;
}

.scrollable-table th,
.scrollable-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    vertical-align: top;
    word-wrap: break-word;
    white-space: normal;
}

.scrollable-table th {
    background: #f8f9fa;
    font-weight: bold;
    /* 🔥 电脑 + 手机 双兼容粘性定位 */
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 99999 !important;
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
/* 🔥 移动端表格专属兼容：给表头行也加固定 */
.scrollable-table thead tr {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
}

.scrollable-table tr:nth-child(even) {
    background: #fafafa;
}

.scrollable-table tr:hover {
    background: #f1f1f1;
}

/* ========================================
   文本域
======================================== */
.form-control {
    resize: none;
    overflow-y: auto;
    min-height: 50px;
    max-height: 200px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* ========================================
   标签样式
======================================== */
.query-condition-label {
    color: #007bff;
    font-weight: 500;
}

/* ========================================
   🔥 可编辑单元格（最终完美版：高度永不塌陷）
======================================== */
.editable-cell {
    position: relative;
    height: auto;
    min-height: 36px;
    padding: 8px;
    vertical-align: top;
}

.cell-value {
    display: block;
    visibility: visible;
    min-height: 36px;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-all;
}

/* 编辑状态：文字隐藏但占位，高度不变 */
.editing .cell-value {
    visibility: hidden;
    pointer-events: none;
}

/* 编辑框：完美覆盖单元格 */
.cell-edit {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    min-height: 36px;
    padding: 8px;
    margin: 0;
    border: 1px solid #2196F3;
    background: #fff;
    z-index: 99;
    resize: none;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: inherit;
    font-size: inherit;
}
/* ========================================
   🔥 彩色精致款 操作按钮+下拉菜单
======================================== */
.action-dropdown {
    position: relative;
    display: block;
    width: 100%;

}
.action-btn {
    width: 100% !important;
    background: #6c39ab !important;
    color: #fff !important;
    border: none !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    font-size: 12px !important;
    cursor: pointer !important;
    line-height: 1 !important;
}
.action-btn:hover {
    background: #c608e3da !important;
}
.action-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 2px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100% !important;
    z-index: 9999;
    display: none;
}
.menu-item {
    padding: 6px 8px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.edit-item { background: #e3f2fd; color: #0d6efd; }
.delete-item { background: #f8d7da; color: #dc3545; }
.copy-item { background: #d1e7dd; color: #198754; }
.menu-item:hover {
    opacity: 0.9;
    background: #db14149a; /*  hover背景，交互清晰 */
}