/**
 * ==========================================================================
 * SISTEM KOMPONEN MODERN DROPLIST (IKKH LIBRARY COMPONENT)
 * Mengadopsi standar modern UI/UX dari modul Katalog & Tipe Keanggotaan
 * Menggantikan tampilan native browser <select> dengan custom floating menu
 * ==========================================================================
 */

/* Kontainer Utama Custom Dropdown */
.custom-select-dropdown {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Elevasikan layer saat dropdown aktif agar melayang di atas input & kontainer lain */
.custom-select-dropdown.is-open {
    z-index: 1050 !important;
}

/* Tombol Pemicu (Toggle Button) */
.custom-dropdown-toggle {
    width: 100%;
    min-height: 40px;
    height: 40px;
    padding: 0 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    font-size: 0.83rem;
    color: #334155;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    box-sizing: border-box;
    text-align: left;
    user-select: none;
    -webkit-appearance: none;
    appearance: none;
}

.custom-dropdown-toggle:hover {
    border-color: #94a3b8;
    background-color: #f8fafc;
}

.custom-select-dropdown.is-open .custom-dropdown-toggle,
.custom-dropdown-toggle:focus {
    outline: none;
    border-color: #09a89e;
    box-shadow: 0 0 0 3px rgba(9, 168, 158, 0.15);
    background-color: #ffffff;
}

/* Teks Label Pilihan */
.custom-dropdown-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    color: #64748b;
    font-weight: 500;
}

.custom-select-dropdown.has-value .custom-dropdown-label {
    color: #0f172a;
    font-weight: 600;
}

/* Ikon Panah Dropdown (Rotasi Halus) */
.custom-dropdown-arrow {
    flex-shrink: 0;
    color: #64748b;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
    pointer-events: none;
}

.custom-select-dropdown.is-open .custom-dropdown-arrow {
    transform: rotate(180deg);
    color: #09a89e;
}

/* Panel Menu Dropdown Melayang (Floating Panel Solid Elegan) */
.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    width: 100%;
    min-width: 100%;
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 14px 35px -4px rgba(15, 23, 42, 0.22), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    z-index: 1060 !important;
    display: none;
    padding: 0.35rem;
    box-sizing: border-box;
}

.custom-select-dropdown.is-open .custom-dropdown-menu {
    display: block;
    animation: customDropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes customDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Kotak Pencarian di Dalam Dropdown (Untuk Opsi Lebih dari 7) */
.custom-dropdown-search {
    position: sticky;
    top: 0;
    background: #ffffff;
    padding: 0.25rem 0.25rem 0.4rem 0.25rem;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 0.3rem;
    z-index: 2;
}

.custom-dropdown-search input {
    width: 100%;
    height: 32px;
    padding: 0 0.65rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.78rem;
    color: #1e293b;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    background-color: #f8fafc;
    transition: all 0.15s ease;
}

.custom-dropdown-search input:focus {
    border-color: #09a89e;
    background-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(9, 168, 158, 0.12);
}

/* Label Grup (Optgroup) */
.custom-dropdown-group-label {
    padding: 0.45rem 0.75rem 0.25rem 0.75rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    user-select: none;
    background-color: #f8fafc;
    border-radius: 4px;
    margin: 0.25rem 0 0.15rem 0;
}

/* Item Pilihan */
.custom-dropdown-item {
    padding: 0.55rem 0.85rem;
    font-size: 0.82rem;
    color: #334155;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: background-color 0.12s ease, color 0.12s ease;
    user-select: none;
    box-sizing: border-box;
    line-height: 1.4;
}

.custom-dropdown-item.in-group {
    padding-left: 1.25rem;
}

.custom-dropdown-item:hover,
.custom-dropdown-item.is-highlighted {
    background-color: #f1f5f9;
    color: #09a89e;
}

/* Item Aktif / Terpilih */
.custom-dropdown-item.is-active {
    background-color: #e6f7f6;
    color: #078f86;
    font-weight: 600;
}

.custom-dropdown-item.is-active::after {
    content: "";
    width: 6px;
    height: 10px;
    border: solid #078f86;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-right: 4px;
    flex-shrink: 0;
}

/* Opsi Kosong saat Pencarian */
.custom-dropdown-empty {
    padding: 0.85rem 0.75rem;
    font-size: 0.78rem;
    color: #94a3b8;
    text-align: center;
    font-style: italic;
}

/* Item Disabled */
.custom-dropdown-item.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* State Nonaktif Keseluruhan (Disabled State) */
.custom-select-dropdown.is-disabled .custom-dropdown-toggle {
    background-color: #f8fafc;
    border-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}

.custom-select-dropdown.is-disabled .custom-dropdown-label {
    color: #94a3b8;
    font-style: italic;
}

.custom-select-dropdown.is-disabled .custom-dropdown-arrow {
    color: #cbd5e1;
}

/* Ukuran Fleksibel Berdasarkan Ukuran Form */
.custom-select-dropdown.select-sm .custom-dropdown-toggle {
    min-height: 32px;
    height: 32px;
    padding: 0 0.65rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

.custom-select-dropdown.select-sm .custom-dropdown-item {
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
}

/* Opsi Inline / Toolbar Filter */
.custom-select-dropdown.is-inline,
.inbox-per-page-wrap .custom-select-dropdown {
    width: auto !important;
    min-width: 95px;
    display: inline-block !important;
    vertical-align: middle;
}

.inbox-per-page-wrap .custom-select-dropdown .custom-dropdown-toggle {
    min-height: 30px;
    height: 30px;
    padding: 0 0.55rem;
    font-size: 0.74rem;
}


/* Status Validasi Error */
.custom-select-dropdown.is-invalid .custom-dropdown-toggle {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

/* Custom Scrollbar Rapi */
.custom-dropdown-menu::-webkit-scrollbar {
    width: 5px;
}
.custom-dropdown-menu::-webkit-scrollbar-track {
    background: #f8fafc;
    border-radius: 4px;
}
.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #09a89e;
}

/* Elevasi layer kontainer pembungkus & tabel saat dropdown terbuka */
.has-open-dropdown,
.form-group-custom:has(.custom-select-dropdown.is-open),
.form-group:has(.custom-select-dropdown.is-open),
.form-grid-2:has(.custom-select-dropdown.is-open),
.form-row:has(.custom-select-dropdown.is-open) {
    z-index: 1040 !important;
}

tr:has(.custom-select-dropdown.is-open),
tr.has-open-dropdown,
td:has(.custom-select-dropdown.is-open),
td.has-open-dropdown {
    position: relative !important;
    z-index: 1055 !important;
}

.table-container-responsive:has(.custom-select-dropdown.is-open),
.table-container-responsive.has-open-dropdown,
.modern-card:has(.custom-select-dropdown.is-open),
.modern-card.has-open-dropdown {
    overflow: visible !important;
}

/* Menyembunyikan select native secara aman agar form submit & validasi tetap bekerja 100% */
select.custom-select-native-hidden {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    top: 0 !important;
    left: 0 !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
}

/* Dukungan untuk elemen select yang berada di dalam .input-icon-wrapper */
.input-icon-wrapper .custom-select-dropdown {
    width: 100%;
    position: relative;
}

.input-icon-wrapper .custom-select-dropdown .custom-dropdown-toggle {
    padding-left: 2.35rem !important;
    padding-right: 0.85rem !important;
}

.input-icon-wrapper .input-prefix-icon {
    z-index: 5 !important;
    pointer-events: none !important;
}


