/* ── Custom Dropdown Component ──
   Replaces native <select> with a floating overlay panel.
   Usage: add data-custom-dropdown to any <select>, or call CustomDropdown.init(selectEl).
*/

/* ── Trigger (the native select, visually styled) ── */
select[data-custom-dropdown] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.7rem;
    cursor: pointer;
}

select[data-custom-dropdown]:focus {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233a86ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

select[data-custom-dropdown]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Overlay panel ── */
.cd-panel {
    position: fixed;
    z-index: 99999;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    overflow: hidden;
    pointer-events: none;
}

.cd-panel--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ── Scrollable list ── */
.cd-list {
    max-height: 450px;
    overflow-y: auto;
    padding: 4px;
}

.cd-list::-webkit-scrollbar {
    width: 4px;
}

.cd-list::-webkit-scrollbar-track {
    background: transparent;
}

.cd-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

/* ── Individual item ── */
.cd-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: inherit;
    line-height: 1.4;
    color: #334155;
    background-color: #ffffff;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.cd-item:hover {
    background-color: #e8f0fe;
}

/* ── Checkmark ── */
.cd-check {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: color 0.1s ease;
}

.cd-item--selected .cd-check {
    color: #3a86ff;
}

.cd-item--selected {
    font-weight: 500;
}

/* ── Item text ── */
.cd-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Empty state ── */
.cd-empty {
    padding: 12px 8px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.8rem;
}
