/* ==========================================================================
   KoaSelect — Pure Vanilla JS Searchable Single/Multi/Infinite Dropdown
   Faithful to the BanaBulBi KoaSelect design system, zero jQuery/FontAwesome.
   ========================================================================== */

.koa-select {
    position: relative;
    display: block;
    width: 100%;
    user-select: none;
    -webkit-user-select: none;
}

.koa-select.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

.koa-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 0 10px 0 12px;
    width: 100%;
    height: 36px;
    border: 1px solid #e4eaf5;
    border-radius: 6px;
    background-color: #F7F9FB;
    cursor: pointer;
    font-size: 13.5px;
    transition: border-color 0.15s, background-color 0.15s;
}

.koa-btn:hover,
.koa-select.is-open .koa-btn {
    border-color: var(--bbb-secondary, #46A5DC);
    background-color: #fff;
}

.koa-title {
    color: #666;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    flex: 1;
}

.koa-select.has-value .koa-title {
    color: var(--bbb-secondary, #46A5DC);
}

.koa-top-cancel {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: #9aa5b5;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    transition: background-color 0.15s, color 0.15s;
}

.koa-top-cancel:hover {
    background-color: #ffe5ea;
    color: #FF385C;
}

.koa-select.has-value .koa-top-cancel {
    display: inline-flex;
}

.koa-icon {
    display: inline-flex;
    align-items: center;
    color: var(--bbb-secondary, #46A5DC);
    font-size: 12px;
    flex-shrink: 0;
}

/* Dropdown Menu */
.koa-menu {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    background: #fff;
    border: 1px solid #d0d8e8;
    border-radius: 0 0 10px 10px;
    min-width: 100%;
    width: max-content;
    max-width: 340px;
    box-shadow: 0 8px 24px rgba(24, 69, 139, 0.14);
    padding: 10px;
    flex-direction: column;
    z-index: 1060;
}

.koa-select.is-open .koa-menu,
.koa-menu.is-mobile-open,
.koa-menu.is-desktop-open {
    display: flex;
}

.koa-menu-title {
    display: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--bbb-primary-dark, #18458B);
    margin: 0 0 10px;
    text-align: center;
}

/* Search Box */
.koa-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 6px;
}

.koa-search {
    width: 100%;
    height: 32px;
    padding: 4px 28px 4px 10px;
    border: 1px solid #e4eaf5;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    background: #fafcff;
}

.koa-search:focus {
    outline: none;
    border-color: var(--bbb-secondary, #46A5DC);
    background: #fff;
}

.koa-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #b0b8c5;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: none;
    line-height: 1;
}

.koa-search-wrap.has-query .koa-search-clear {
    display: block;
}

.koa-search-clear:hover {
    color: #FF385C;
}

/* Scrollable List */
.koa-list {
    list-style: none;
    padding: 0;
    margin: 0 0 6px;
    max-height: 270px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #c5d0e3 transparent;
    color: var(--bbb-primary, #3e67a7);
}

.koa-list::-webkit-scrollbar { width: 6px; }
.koa-list::-webkit-scrollbar-thumb {
    background: rgba(150, 165, 190, 0.55);
    border-radius: 10px;
}

.koa-list li {
    list-style: none;
    padding: 0;
    margin: 0;
}

.koa-item-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e55;
    cursor: pointer;
    margin: 0;
    transition: background-color 0.12s;
}

.koa-item-label:hover {
    background-color: #F4F7FC;
}

/* Custom Checkbox (Multi = Square, Single = Circle) */
.koa-checkbox {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 19px;
    height: 19px;
    min-width: 19px;
    border: 1.5px solid var(--bbb-secondary, #46A5DC);
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.koa-select[data-mode="single"] .koa-checkbox,
.koa-menu[data-mode="single"] .koa-checkbox {
    border-radius: 50%;
}

.koa-checkbox:checked {
    background-color: var(--bbb-secondary, #46A5DC);
    border-color: var(--bbb-secondary, #46A5DC);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.2 8.4l3 3 6.6-6.6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px 12px;
}

.koa-loading,
.koa-empty {
    text-align: center;
    padding: 10px;
    font-size: 12.5px;
    color: #7c899e;
}

/* Footer Buttons (Exact BanaBulBi colors: #FF385C & #3AACED) */
.koa-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #e4eaf5;
}

.koa-clear-btn,
.koa-apply-btn {
    border: none;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.15s;
}

.koa-clear-btn { background-color: #FF385C; }
.koa-apply-btn { background-color: #3AACED; }
.koa-clear-btn:hover, .koa-apply-btn:hover { opacity: 0.9; }

/* Validation */
.koa-select.is-invalid .koa-btn {
    border-color: #dc3545 !important;
}
.koa-validation-msg {
    display: none;
    color: #dc3545;
    font-size: 0.78rem;
    margin-top: 4px;
    font-weight: 600;
}
.koa-select.is-invalid + .koa-validation-msg {
    display: block;
}

/* Mobile Fullscreen Sheet + Overlay (above Bootstrap offcanvas 1045) */
.koa-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 42, 62, 0.72);
    z-index: 1080;
}
.koa-overlay.is-visible { display: block; }

@media (max-width: 767.98px) {
    .koa-menu {
        position: fixed;
        inset: 0;
        top: 10%;
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 16px;
        z-index: 1090;
    }
    .koa-menu-title { display: block; }
    .koa-list {
        max-height: none;
        flex: 1;
    }
    .koa-item-label {
        flex-direction: row-reverse;
        justify-content: space-between;
        padding: 10px 6px;
        font-size: 15px;
        border-bottom: 1px solid #f2f5fa;
    }
}
