/**
 * AtAutocomplete - 仿 bootstrap-select 樣式
 * 搭配 /js/at-autocomplete.js 使用
 */

/* 容器 */
.at-ac-container {
    position: relative;
    width: 100%;
}

/* 選取框 */
.at-ac-selection {
    display: flex;
    align-items: center;
    height: 29px;
    padding: 0 8px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    background-color: #fff;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.at-ac-selection:hover {
    border-color: #b0b7bf;
}
.at-ac-open .at-ac-selection {
    border-color: #80bdff;
    box-shadow: 0 0 0 .2rem rgba(0,123,255,.25);
}

/* 顯示文字 */
.at-ac-rendered {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .875rem;
    color: #495057;
    line-height: 27px;
}
.at-ac-placeholder {
    color: #999;
}

/* × 清除按鈕 */
.at-ac-clear {
    font-size: 14px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    line-height: 27px;
    display: none;
}
.at-ac-clear:hover {
    color: #333;
}

/* ▼ 箭頭 */
.at-ac-arrow {
    display: flex;
    align-items: center;
    padding-left: 4px;
}
.at-ac-arrow b {
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
    border-width: 5px 4px 0 4px;
}
.at-ac-open .at-ac-arrow b {
    border-color: transparent transparent #555 transparent;
    border-width: 0 4px 5px 4px;
}

/* 下拉面板（對齊 Bootstrap .dropdown-menu） */
.at-ac-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1060;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-top: 0;
    border-radius: 0 0 3px 3px;
    box-shadow: 0 6px 12px rgba(0,0,0,.175);
    font-size: 1rem;
    color: #212529;
}

/* 搜尋框 */
.at-ac-search {
    padding: 4px 8px;
    border-bottom: 1px solid #ced4da;
}
.at-ac-search-field {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: .875rem;
    height: 29px;
    outline: 0;
    box-sizing: border-box;
}
.at-ac-search-field:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 .2rem rgba(0,123,255,.25);
}

/* 結果列表 */
.at-ac-results {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}
/* 選項（對齊 Bootstrap .dropdown-item + 專案自訂 bootstrap-select 樣式） */
.at-ac-option {
    padding: 8px 20px;
    font-weight: 400 !important;
    line-height: 1.4;
    cursor: pointer;
    color: #212529;
}

/* hover：淺灰 */
.at-ac-option.at-ac-highlighted {
    background-color: #f8f9fa;
}

/* 單選：已選取藍色 */
.at-ac-option.at-ac-selected {
    background-color: #007bff;
    color: #fff;
}

/* 單選：已選取 + hover 深藍 */
.at-ac-option.at-ac-selected.at-ac-highlighted {
    background-color: #0062cc;
    color: #fff;
}

/* 多選：已選取顯示 ✓，背景不變只加粗 */
.at-ac-multi .at-ac-option.at-ac-selected {
    background-color: transparent;
    color: #212529;
    font-weight: 600 !important;
}
.at-ac-multi .at-ac-option.at-ac-selected::before {
    content: "✓ ";
    color: #007bff;
}
.at-ac-multi .at-ac-option.at-ac-selected.at-ac-highlighted {
    background-color: #f8f9fa;
    color: #212529;
}

/* 訊息（搜尋中、無結果等） */
.at-ac-message {
    padding: 8px 20px;
    color: #999;
    list-style: none;
}

/* input-group 內 */
.input-group .at-ac-container {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}
.input-group .at-ac-selection {
    border-radius: 0 3px 3px 0;
}
.input-group .at-ac-open .at-ac-selection {
    border-radius: 0 3px 0 0;
}

/* ===== 多選模式 ===== */

/* 多選：選取框允許換行，高度自動 */
.at-ac-multi .at-ac-selection {
    height: auto;
    min-height: 29px;
    flex-wrap: wrap;
    gap: 3px;
    padding: 3px 6px;
    overflow: visible;
}

/* tag 容器 */
.at-ac-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    flex: 1;
    align-items: center;
    min-width: 0;
}

/* 單一 tag chip */
.at-ac-tag {
    display: inline-flex;
    align-items: center;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 3px;
    padding: 1px 4px;
    font-size: .8rem;
    font-weight: 400 !important;
    color: #495057;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* tag 內的 × 移除按鈕 */
.at-ac-tag-remove {
    margin-left: 4px;
    cursor: pointer;
    color: #6c757d;
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
}
.at-ac-tag-remove:hover {
    color: #dc3545;
}

/* 多選 disabled 狀態：tag 的 × 隱藏 */
.at-ac-disabled .at-ac-tag-remove {
    display: none;
}

/* ===== End 多選模式 ===== */

/* disabled 狀態 */
.at-ac-disabled .at-ac-selection {
    background-color: #e9ecef;
    cursor: not-allowed;
}
.at-ac-disabled .at-ac-rendered {
    color: #6c757d;
}
