body {
    font-family: Arial, sans-serif;
    position: relative;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

.close-button{
    position: absolute;
    top: 10px;
    right: 10px;
}

.container {
    display: flex;
    height: calc(100vh - 50px); /* 調整高度以適應頂部工具列 */
}
.sidebar {
    width: 250px; /* 調整側邊欄寬度以容納更多內容 */
    border-right: 1px solid #000;
    padding: 10px;
    overflow-y: auto;
}
.sidebar h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 16px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
}
.table-list, .query-list {
    list-style: none;
    padding: 0;
}
.table-list li, .query-list li {
    margin: 8px 0;
    cursor: pointer;
    user-select: none;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    transition: background-color 0.3s;
}
.table-list li:hover, .query-list li:hover {
    background-color: #f0f0f0;
}
.topbar {
    display: flex;
    justify-content: flex-start;
    padding: 10px;
    border-bottom: 1px solid #000;
    gap: 10px;
    height: 50px;
    box-sizing: border-box;
    align-items: center;
}
.topbar button {
    padding: 5px 10px;
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    border-radius: 4px;
    transition: background-color 0.3s;
}
.topbar button:hover {
    background-color: #e0e0e0;
}
/* 新增樣式：將合計按鈕改為核取鈕 */
.topbar label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.topbar input[type="checkbox"] {
    margin-right: 5px;
    width: 16px;
    height: 16px;
}
.query-builder {
    display: flex;
    gap: 20px;
    padding: 20px;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.table-area {
    display: flex;
    gap: 100px; /* 調整間距為半張表寬 */
    border: 1px solid #000;
    padding: 10px;
    min-height: 200px;
    position: relative;
    resize: vertical;
    overflow: auto;
    flex-wrap: nowrap;
    background-color: #f9f9f9;
}
.table-box {
    border: 1px solid #000;
    padding: 10px;
    width: 200px;
    position: relative;
    background-color: #fafafa;
    border-radius: 4px;
    height: min-content;
}
.table-header {
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
}
.table-field {
    margin: 5px 0;
    cursor: pointer;
    user-select: none;
    position: relative;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.table-field:hover {
    background-color: #e0e0e0;
}
.condition-box {
    margin-top: 20px;
    border: 1px solid #000;
    padding: 10px;
}
/* 移除欄位篩選條件標題 */
/* .filter-box h3 {
    display: none;
} */
.filter-box {
    border-top: 1px solid #000;
    padding-top: 10px;
    resize: vertical;
    overflow: auto;
}
.filter-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    min-height: 150px; /* 確保有足夠的高度來接受拖曳 */
    border: 1px dashed #ccc; /* 添加虛線邊框以提示用戶可以放置 */
    padding: 10px;
    flex-wrap: nowrap;
    align-items: flex-start;
}
.filter-column {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: 1px solid #000;
    padding: 10px;
    background-color: #fff;
    border-radius: 4px;
    cursor: move;
    width: 300px; /* 調整寬度以容納更多內容 */
}
.filter-column.dragging {
    opacity: 0.5;
}
.filter-column.over {
    border: 2px dashed #000;
}
/* 新增連接線相關樣式 */
.connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* 讓線不阻止其他元素的事件 */
    z-index: 0;
}
.connection-line {
    stroke: red;
    stroke-width: 2;
    fill: none;
    cursor: pointer;
    pointer-events: all; /* 確保可以接收事件 */
}
/* 定義箭頭標記 */
.filter-box {
    border-top: 1px solid #000;
    padding-top: 10px;
    resize: vertical;
    overflow: auto;
}
.filter-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    min-height: 50px; /* 確保有足夠的高度來接受拖曳 */
    border: 1px dashed #ccc; /* 添加虛線邊框以提示用戶可以放置 */
    padding: 10px;
    flex-wrap: nowrap;
}
/* 自訂右鍵選單樣式 */
.context-menu {
    position: absolute;
    background-color: #fff;
    border: 1px solid #ccc;
    z-index: 1000;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    display: none;
}
.context-menu ul {
    list-style: none;
    padding: 5px 0;
    margin: 0;
}
.context-menu ul li {
    padding: 5px 20px;
    cursor: pointer;
}
.context-menu ul li:hover {
    background-color: #f0f0f0;
}
/* 新增 SQL 代碼顯示區塊的樣式 */
.sql-display {
    border: 1px solid #000;
    background-color: #f5f5f5;
    padding: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    overflow: auto;
    font-family: Consolas, monospace;
    font-size: 14px;
    /* z-index: 1; 確保在其他元素之上 */
    border-radius: 4px;
    margin-top: 20px;
}
.sql-display h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    text-align: center;
}
.sql-content {
    width: 100%;
    height: 150px;
    resize: vertical;
    font-family: Consolas, monospace;
    font-size: 14px;
}


/* 自訂右鍵選單樣式 */
.custom-context-menu {
    position: absolute;
    display: none;
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    width: 150px;
}

.custom-context-menu ul {
    list-style: none;
    margin: 0;
    padding: 5px 0;
}

.custom-context-menu ul li {
    padding: 8px 12px;
    cursor: pointer;
}

.custom-context-menu ul li:hover {
    background-color: #f0f0f0;
}

/* 模態對話框樣式 */
.modal {
    display: none; /* 隱藏模態對話框 */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5); /* 半透明背景 */
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 400px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
