/* ============================================================
   Fancy Select — modern dropdown component
   Progressively enhances native <select> elements site-wide.
   Brand: primary-blue #211594 · primary-green #26c221
   ============================================================ */

.fs-wrap { position: relative; width: 100%; font-family: inherit; }
.fs-wrap.fs-disabled { opacity: .55; pointer-events: none; }

/* Hide the native select but keep it accessible to screen readers / form */
.fs-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none;
}

/* The visible button that mimics the original select */
.fs-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    color: #1f2937;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .05s;
    text-align: left;
    line-height: 1.4;
    user-select: none;
}
.fs-button:hover:not(:disabled) { border-color: #c7c9d6; }
.fs-button:focus,
.fs-wrap.fs-open .fs-button {
    outline: none;
    border-color: #211594;
    box-shadow: 0 0 0 3px rgba(33,21,148,.12);
}
.fs-button:active:not(:disabled) { transform: translateY(1px); }
.fs-button[disabled] { background: #f3f4f6; color: #9ca3af; cursor: not-allowed; }

.fs-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-label.fs-placeholder { color: #9ca3af; }
.fs-arrow {
    flex-shrink: 0;
    margin-left: 10px;
    width: 18px; height: 18px;
    transition: transform .2s ease;
    color: #6b7280;
}
.fs-wrap.fs-open .fs-arrow { transform: rotate(180deg); color: #211594; }

/* Dropdown panel */
.fs-panel {
    position: absolute;
    z-index: 1000;
    left: 0; right: 0;
    margin-top: 6px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15,23,42,.12), 0 4px 12px rgba(15,23,42,.06);
    max-height: 320px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: fs-fade-in .14s ease-out;
}
.fs-wrap.fs-open .fs-panel { display: flex; }
.fs-wrap.fs-up .fs-panel { bottom: 100%; top: auto; margin-top: 0; margin-bottom: 6px; }

@keyframes fs-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Search box */
.fs-search-wrap {
    position: relative;
    padding: 10px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}
.fs-search {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    background: #f9fafb;
    color: #111827;
    font-family: inherit;
}
.fs-search:focus {
    border-color: #211594;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(33,21,148,.08);
}
.fs-search-icon {
    position: absolute;
    left: 22px; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: #9ca3af;
    pointer-events: none;
}

/* Options list */
.fs-list {
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 6px;
    flex: 1;
}
.fs-list::-webkit-scrollbar { width: 8px; }
.fs-list::-webkit-scrollbar-track { background: transparent; }
.fs-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.fs-list::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.fs-option {
    padding: 9px 12px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: background-color .1s, color .1s;
    line-height: 1.4;
}
.fs-option:hover,
.fs-option.fs-active {
    background: #f3f4ff;
    color: #211594;
}
.fs-option.fs-selected {
    background: #211594;
    color: #fff;
    font-weight: 600;
}
.fs-option.fs-selected:hover,
.fs-option.fs-selected.fs-active {
    background: #1a1077;
    color: #fff;
}
.fs-option.fs-disabled {
    opacity: .5;
    cursor: not-allowed;
    color: #9ca3af;
}
.fs-option.fs-disabled:hover { background: transparent; color: #9ca3af; }
.fs-check {
    flex-shrink: 0;
    width: 16px; height: 16px;
    opacity: 0;
}
.fs-option.fs-selected .fs-check { opacity: 1; }

/* Group headers (optgroup) */
.fs-group {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Empty state */
.fs-empty {
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* Mobile tweaks */
@media (max-width: 640px) {
    .fs-button { padding: 13px 14px; font-size: 15px; }
    .fs-panel { max-height: 70vh; }
    .fs-search { font-size: 16px; } /* prevent iOS zoom */
    .fs-option { padding: 12px; font-size: 15px; }
}

/* Compatibility: when wrapping selects that had specific classes,
   inherit the rounded look but keep behavior identical */
.fs-wrap.fs-size-sm .fs-button { padding: 8px 12px; font-size: 13px; border-radius: 8px; }
.fs-wrap.fs-size-lg .fs-button { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
