/* ================================================================ */
/*  検索付きプルダウン（コンボボックス）共通スタイル                */
/*  SearchableSelect.tsx 用。全ページ共通（index.html で常時ロード）。 */
/*  すべて .searchable-select 配下にスコープし、既存の複数選択        */
/*  multiselect-dropdown（RankingPage / UsersPage のチェックボックス）*/
/*  には影響させない。                                               */
/* ================================================================ */

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

/* ---- トリガーボタン（ネイティブ select 風の見た目・サイドバー外でも成立） ---- */
.searchable-select .multiselect-button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: calc(1.5em + 0.75rem + 2px);
    padding: 0.375rem 1.75rem 0.375rem 0.75rem;
    /* 入力/ボタン/プルダウン/マルチ選択と全文脈で 12px に統一（--font-xs） */
    font-size: var(--font-xs);
    line-height: 1.5;
    /* プルダウンの値テキスト色を全文脈で統一（--color-text） */
    color: var(--color-text);
    background-color: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    text-align: left;
    cursor: pointer;
    position: relative;
}

.searchable-select .multiselect-button:disabled {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

/* 右端の下矢印キャレット */
.searchable-select .multiselect-button.dropdown-toggle::after {
    display: block;
    position: absolute;
    right: 12px;
    top: 50%;
    margin-top: -2px;
    content: '';
    border-top: 5px solid #6c757d;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 0;
}

/* 選択済みテキスト / プレースホルダー（長い時は省略） */
.searchable-select .multiselect-selected-text,
.searchable-select .multiselect-placeholder {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
    width: 100%;
}

.searchable-select .multiselect-placeholder {
    /* 未選択時プレースホルダーも値テキストと同じ色に統一（学年プルダウンと揃える） */
    color: var(--color-text);
}

/* ---- ドロップダウン本体（Bootstrap の .dropdown-menu.show を上書き） ---- */
.searchable-select-menu {
    width: 100%;
    min-width: 0;
    margin-top: 2px;
    padding: 0;
    border: 1px solid #ced4da;
    border-radius: var(--radius-sm, 0.25rem);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.15));
    z-index: 1100;
}

/* 上部の検索欄（スクロールしても固定） */
.searchable-select-search {
    position: sticky;
    top: 0;
    padding: 8px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border-subtle, #e6e8ee);
    border-top-left-radius: var(--radius-sm, 0.25rem);
    border-top-right-radius: var(--radius-sm, 0.25rem);
}

.searchable-select-search .form-control {
    width: 100%;
    height: 32px;
    font-size: var(--font-xs, 0.8125rem);
}

/* 選択肢リスト */
.searchable-select-options {
    max-height: 280px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .searchable-select-options {
        max-height: 220px;
    }
}

.searchable-select-option {
    padding: 7px 12px;
    font-size: var(--font-xs, 0.8125rem);
    /* 選択肢テキスト色を値テキストと統一（--color-text） */
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-select-option:hover {
    background-color: #f1f3f8;
}

.searchable-select-option.active {
    background-color: #eef2fb;
    color: #0c2360;
    font-weight: var(--font-weight-semibold, 600);
}

.searchable-select-empty {
    padding: 10px 12px;
    font-size: var(--font-xs, 0.8125rem);
    color: #8794ad;
    text-align: center;
}

/* 無限スクロール：末尾の追加読み込みセンチネル */
.searchable-select-load-more {
    padding: 8px 12px;
    font-size: var(--font-xs, 0.8125rem);
    text-align: center;
}

/* クリア（指定なしに戻す）項目は控えめに */
.searchable-select-clear {
    color: #8794ad;
}

/* ---- 幅広バリアント（親セルに縛られず行いっぱいに広げる。RecordsPage
       サイドバーのフィルタ行など2列レイアウト用。サイドバーは
       overflow:hidden のため右端基準で左方向に展開して内側に収める） ---- */
.searchable-select--wide .searchable-select-menu {
    width: calc(200% + var(--space-2, 0.5rem));
    max-width: none;
    left: auto;
    right: 0;
}
