/* ============================================================
   forms.css — styles for custom-select and other form widgets
   Pairs with assets/js/forms.js.
   ============================================================ */

/* The original native <select> is hidden once the JS upgrades it.
   We keep it in the DOM so form submissions / autofill still work. */
.js-form-select.is-enhanced {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* The visual replacement container */
.fselect {
    position: relative;
    width: 100%;
}

/* The button users actually see and click */
.fselect__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.625rem 0.875rem;       /* matches form-input */
    background: #fff;
    border: 1px solid #d6d3d1;        /* stone-300 */
    border-radius: 0.5rem;
    font: inherit;
    color: #1c1917;                   /* stone-900 */
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.fselect__trigger:hover {
    border-color: #a8a29e;             /* stone-400 */
}
.fselect__trigger:focus,
.fselect.is-open .fselect__trigger {
    outline: none;
    border-color: #15803d;             /* forest-700 */
    box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.15);
}
.fselect__value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fselect__value.is-placeholder {
    color: #78716c;                    /* stone-500 */
}
.fselect__chevron {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    margin-left: 0.5rem;
    color: #57534e;                    /* stone-600 */
    transition: transform 0.2s ease;
    pointer-events: none;
}
.fselect.is-open .fselect__chevron {
    transform: rotate(180deg);
}

/* The dropdown panel that shows the options */
.fselect__panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 18rem;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d6d3d1;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.10), 0 8px 10px -6px rgba(0,0,0,0.10);
    padding: 0.25rem;
    /* hidden by default; shown by the .is-open class on .fselect */
    display: none;
}
.fselect.is-open .fselect__panel {
    display: block;
}

.fselect__option {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    color: #1c1917;
    cursor: pointer;
    font: inherit;
    text-align: left;
    background: none;
    border: 0;
    line-height: 1.4;
}
.fselect__option:hover,
.fselect__option.is-focused {
    background: #f5f5f4;               /* stone-100 */
    color: #14532d;                    /* forest-900 */
}
.fselect__option.is-selected {
    background: #14532d;               /* forest-900 */
    color: #fff;
    font-weight: 500;
}
.fselect__option.is-selected:hover,
.fselect__option.is-selected.is-focused {
    background: #166534;               /* forest-800 */
    color: #fff;
}
.fselect__option[aria-disabled="true"] {
    color: #a8a29e;
    cursor: not-allowed;
}

/* Mobile tweaks */
@media (max-width: 640px) {
    .fselect__panel {
        max-height: 60vh;
    }
}
