/* ===================================
   可搜尋的下拉選擇器組件
   用於國家/地區、語言等複雜選項
   =================================== */

.searchable-select-wrapper {
    position: relative;
    width: 100%;
}

.searchable-select-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.searchable-select-input {
    width: 100%;
    padding: var(--spacing-md);
    padding-left: 2.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.2s;
}

.searchable-select-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.searchable-select-input::placeholder {
    color: var(--text-quaternary);
}

/* 搜尋圖標 */
.searchable-select-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 1rem;
    pointer-events: none;
}

/* 已選地點：右側清除鈕，隱藏搜尋圖示 */
.searchable-select-clear {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.searchable-select-clear:hover {
    color: var(--text-primary);
    background: var(--bg-secondary, #F3F4F6);
}

.searchable-select-clear[hidden] {
    display: none !important;
}

.searchable-select-input-container.has-selection .searchable-select-icon {
    display: none;
}

.searchable-select-input.is-location-selected {
    cursor: default;
    background: var(--bg-secondary, #F9FAFB);
    padding-right: 2.75rem;
}

/* 旗幟圖示（國家選擇） */
.selected-flag {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 1;
}

/* 下拉列表 */
.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.searchable-select-dropdown li {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.searchable-select-dropdown li:last-child {
    border-bottom: none;
}

.searchable-select-dropdown li:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
}

.searchable-select-dropdown li.selected {
    background-color: #eff6ff;
    color: var(--primary-dark);
    font-weight: var(--font-weight-semibold);
}

.searchable-select-dropdown li.no-results {
    text-align: center;
    color: var(--text-tertiary);
    padding: 1rem;
    cursor: default;
}

.searchable-select-dropdown li.no-results:hover {
    background-color: transparent;
    color: var(--text-tertiary);
}

/* 國家選擇的旗幟顯示 */
.searchable-select-dropdown li .country-flag {
    font-size: 1.25rem;
    min-width: 1.5rem;
}

.searchable-select-dropdown li .country-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.searchable-select-dropdown li .country-name {
    font-weight: var(--font-weight-medium);
}

.searchable-select-dropdown li .country-code {
    font-size: 0.8rem;
    color: var(--text-quaternary);
}

/* 語言選擇的語言碼顯示 */
.searchable-select-dropdown li .language-code {
    font-size: 0.8rem;
    color: var(--text-quaternary);
    margin-left: auto;
}

/* 隱藏狀態 */
.searchable-select-dropdown[style*="display: none"] {
    display: none !important;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .searchable-select-dropdown {
        max-height: 250px;
    }

    .searchable-select-input {
        font-size: 16px; /* 防止 iOS 縮放 */
    }
}

/* 滾動條樣式 */
.searchable-select-dropdown::-webkit-scrollbar {
    width: 6px;
}

.searchable-select-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.searchable-select-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.searchable-select-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--text-quaternary);
}
