/* ============================================================
   Dropdown buatan sendiri (pengganti daftar opsi bawaan browser).
   <select> aslinya tetap ada & tetap jadi sumber nilai; yang diganti
   hanya panah dan daftar pilihannya. Lihat js/custom-select.js.
   Opt-out untuk satu select: tambahkan atribut data-native.
   ============================================================ */

/* Panah kustom di <select>; kotak, warna, dan font tetap dari CSS halaman masing-masing. */
select:not([multiple]):not([size]):not([data-native]):not(.jf-native) {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237b8599' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 14px !important;
    padding-right: 34px !important;
    cursor: pointer;
    text-overflow: ellipsis;
}
select:not([multiple]):not([size]):not([data-native]):not(.jf-native):disabled { cursor: not-allowed; }
select.cs-open:not([multiple]):not([size]) {
    border-color: var(--gold, #C89C3D) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold, #C89C3D) 22%, transparent) !important;
}

/* Daftar pilihan */
.cs-pop {
    position: fixed;
    z-index: 2147483000;
    box-sizing: border-box;
    margin: 0;
    padding: 6px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    color: var(--navy, #192C4D);
    border: 1px solid color-mix(in srgb, var(--navy, #192C4D) 14%, #fff);
    border-radius: 12px;
    box-shadow: 0 16px 36px color-mix(in srgb, var(--navy, #192C4D) 18%, transparent);
    scrollbar-width: thin;
    animation: cs-in .12s ease-out;
}
.cs-pop[data-up] { transform-origin: bottom; }
@keyframes cs-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cs-pop { animation: none; } }

.cs-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.35;
    user-select: none;
}
.cs-item + .cs-item { margin-top: 1px; }
.cs-item.is-active { background: color-mix(in srgb, var(--navy, #192C4D) 8%, #fff); }
.cs-item.is-selected { font-weight: 600; }
.cs-item.is-selected::after {
    content: "";
    flex: none;
    width: 14px;
    height: 14px;
    background: var(--gold, #C89C3D);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.cs-item.is-disabled { opacity: .45; cursor: not-allowed; }
.cs-item.is-placeholder { color: #8a93a6; }
.cs-group {
    padding: 8px 12px 4px;
    font-size: .85em;
    font-weight: 600;
    color: #8a93a6;
    cursor: default;
}
.cs-group:not(:first-child) { margin-top: 4px; border-top: 1px solid color-mix(in srgb, var(--navy, #192C4D) 8%, #fff); }

/* Mode gelap dashboard */
html[data-dashboard-theme="dark"] select:not([multiple]):not([size]):not([data-native]):not(.jf-native) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23b4bccd' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
}
html[data-dashboard-theme="dark"] .cs-pop {
    background: #1d2a44;
    color: #eef1f7;
    border-color: rgba(255, 255, 255, .14);
    box-shadow: 0 16px 36px rgba(0, 0, 0, .5);
}
html[data-dashboard-theme="dark"] .cs-item.is-active { background: rgba(255, 255, 255, .09); }
html[data-dashboard-theme="dark"] .cs-item.is-placeholder,
html[data-dashboard-theme="dark"] .cs-group { color: #9aa5bd; }
html[data-dashboard-theme="dark"] .cs-group:not(:first-child) { border-top-color: rgba(255, 255, 255, .1); }

/* Mode grid: daftar panjang berisi pilihan pendek (mis. Semester 1..8) */
.cs-pop.cs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 4px;
}
.cs-grid .cs-item { justify-content: center; text-align: center; padding: 9px 6px; margin: 0; white-space: nowrap; }
.cs-grid .cs-item + .cs-item { margin-top: 0; }
.cs-grid .cs-item.cs-span { grid-column: 1 / -1; justify-content: flex-start; }
.cs-grid .cs-item.is-selected::after { display: none; }
.cs-grid .cs-item.is-selected:not(.cs-span) {
    background: color-mix(in srgb, var(--gold, #C89C3D) 20%, #fff);
    box-shadow: inset 0 0 0 1.5px var(--gold, #C89C3D);
}
.cs-grid .cs-item.is-selected.is-active:not(.cs-span) { background: color-mix(in srgb, var(--gold, #C89C3D) 30%, #fff); }
html[data-dashboard-theme="dark"] .cs-grid .cs-item.is-selected:not(.cs-span) { background: rgba(200, 156, 61, .22); }

/* Select yang sudah dapat panah kustom di atas tidak perlu ikon chevron tambahan di sebelahnya
   (sebelumnya tampil dobel, mis. di Kelola Kajian). Select dengan data-native tetap memakai chevron-nya. */
.filter-select-wrap select:not([multiple]):not([size]):not([data-native]):not(.jf-native) ~ .filter-chevron { display: none; }
