/*
 * Hobi Community - Generic custom select
 *
 * Deze stylesheet bevat uitsluitend generieke componentstyling.
 * De inhoud en betekenis van een veld worden bepaald door de JSON-configuratie.
 *
 * De kleuren worden centraal beheerd in 000-app.css.
 */

.hobi-field {
    width: 100%;
}

.hobi-field__label {
    display: block;
    margin-bottom: 8px;
    color: var(--hobi-color-text);
    font-weight: 700;
}

.hobi-field__required {
    margin-left: 3px;
    color: var(--hobi-color-error);
}

.hobi-field__description {
    margin: 8px 0 0;
    color: var(--hobi-color-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.hobi-custom-select {
    position: relative;
    width: 100%;
}

.hobi-custom-select,
.hobi-custom-select * {
    box-sizing: border-box;
}

/*
 * De native select blijft aanwezig voor:
 *
 * - formulierverwerking;
 * - browservalidatie;
 * - toegankelijkheid;
 * - externe scripts die op het change-event luisteren.
 */
.hobi-custom-select__native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/*
 * Zichtbare selectknop.
 */
.hobi-custom-select__button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 54px;
    padding: 10px 14px;
    color: var(--hobi-color-text);
    background: var(--hobi-color-background);
    border: 1px solid var(--hobi-color-border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background-color 160ms ease;
}

.hobi-custom-select__button:hover {
    border-color: var(--hobi-color-border-hover);
}

.hobi-custom-select__button:focus-visible {
    outline: none;
    border-color: var(--hobi-color-border-focus);
    box-shadow:
        0 0 0 4px var(--hobi-color-focus-ring);
}

.hobi-custom-select.is-open .hobi-custom-select__button {
    border-color: var(--hobi-color-border-focus);
    box-shadow:
        0 0 0 4px var(--hobi-color-focus-ring-open);
}

.hobi-custom-select.is-disabled .hobi-custom-select__button,
.hobi-custom-select__button:disabled {
    color: var(--hobi-color-disabled-text);
    background: var(--hobi-color-disabled-background);
    cursor: not-allowed;
    opacity: 0.75;
}

/*
 * Huidig geselecteerde waarde.
 */
.hobi-custom-select__value {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
    gap: 12px;
}

.hobi-custom-select__placeholder {
    min-width: 0;
    overflow: hidden;
    color: var(--hobi-color-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/*
 * Generieke visual-container.
 *
 * De visual kan bijvoorbeeld een afbeelding, icoon of kleurvlak zijn.
 * De component kent de betekenis daarvan niet.
 */
.hobi-custom-select__visual {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    overflow: hidden;
    color: inherit;
}

.hobi-custom-select__visual-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.hobi-custom-select__visual-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.15rem;
}

.hobi-custom-select__visual-swatch {
    display: block;
    width: 22px;
    height: 22px;
    background-color: var(
        --hobi-option-visual-color,
        transparent
    );
    border: 1px solid var(--hobi-color-visual-border);
    border-radius: 50%;
}

.hobi-custom-select__visual-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    color: var(--hobi-color-text-secondary);
    background: var(--hobi-color-surface-strong);
    border-radius: 6px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/*
 * Tekstuele inhoud van de geselecteerde waarde en opties.
 */
.hobi-custom-select__content {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
    gap: 8px;
}

.hobi-custom-select__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hobi-custom-select__secondary {
    margin-left: auto;
    color: var(--hobi-color-muted);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

/*
 * Uitklappijl.
 */
.hobi-custom-select__arrow {
    width: 10px;
    height: 10px;
    margin-left: 16px;
    flex: 0 0 10px;
    border-right: 2px solid var(--hobi-color-muted);
    border-bottom: 2px solid var(--hobi-color-muted);
    transform: rotate(45deg) translateY(-3px);
    transition: transform 160ms ease;
}

.hobi-custom-select.is-open .hobi-custom-select__arrow {
    transform: rotate(225deg) translate(-2px, -2px);
}

/*
 * Uitklappaneel.
 */
.hobi-custom-select__panel {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    display: none;
    overflow: hidden;
    background: var(--hobi-color-background);
    border: 1px solid var(--hobi-color-border);
    border-radius: 12px;
    box-shadow:
        0 12px 30px rgba(17, 24, 39, 0.14);
}

.hobi-custom-select.is-open .hobi-custom-select__panel {
    display: block;
}

/*
 * Zoekveld.
 */
.hobi-custom-select__search-wrap {
    padding: 12px;
    background: var(--hobi-color-surface);
    border-bottom: 1px solid var(--hobi-color-border-light);
}

.hobi-custom-select__search {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    color: var(--hobi-color-text);
    background: var(--hobi-color-background);
    border: 1px solid var(--hobi-color-border);
    border-radius: 9px;
    font: inherit;
}

.hobi-custom-select__search::placeholder {
    color: var(--hobi-color-muted);
}

.hobi-custom-select__search:hover {
    border-color: var(--hobi-color-border-hover);
}

.hobi-custom-select__search:focus {
    outline: none;
    border-color: var(--hobi-color-border-focus);
    box-shadow:
        0 0 0 3px var(--hobi-color-focus-ring-open);
}

/*
 * Optielijst.
 */
.hobi-custom-select__list {
    max-height: 300px;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    list-style: none;
}

.hobi-custom-select__option {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 46px;
    padding: 8px 10px;
    gap: 12px;
    color: var(--hobi-color-text);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
}

.hobi-custom-select__option:hover,
.hobi-custom-select__option.is-active {
    background: var(--hobi-color-option-hover);
}

.hobi-custom-select__option.is-selected {
    color: var(--hobi-color-selected-text);
    background: var(--hobi-color-selected-background);
    font-weight: 700;
}

.hobi-custom-select__option[aria-disabled="true"] {
    color: var(--hobi-color-disabled-text);
    background: var(--hobi-color-disabled-background);
    cursor: not-allowed;
    opacity: 0.5;
}

/*
 * Bericht wanneer geen opties beschikbaar zijn.
 */
.hobi-custom-select__empty {
    padding: 20px 14px;
    color: var(--hobi-color-muted);
    text-align: center;
}

/*
 * De JSON-clientconfiguratie is niet zichtbaar.
 */
.hobi-custom-select__config {
    display: none;
}

/*
 * Mobiele weergave.
 */
@media (max-width: 560px) {
    .hobi-custom-select__panel {
        position: fixed;
        top: auto;
        right: 12px;
        bottom: 12px;
        left: 12px;
        max-height: calc(100vh - 24px);
    }

    .hobi-custom-select__list {
        max-height: 55vh;
    }
}

/*
 * Bescherming tegen CSS van thema's en pagebuilders.
 */
.hobi-field.hobi-select-field {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
}

.hobi-field.hobi-select-field .hobi-custom-select {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
}

.hobi-field.hobi-select-field .hobi-custom-select__button {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box !important;
    flex-wrap: nowrap !important;
}

.hobi-field.hobi-select-field .hobi-custom-select__value {
    display: flex !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

.hobi-field.hobi-select-field .hobi-custom-select__content {
    display: flex !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

.hobi-field.hobi-select-field .hobi-custom-select__arrow {
    display: block !important;
    width: 10px !important;
    min-width: 10px !important;
    max-width: 10px !important;
    height: 10px !important;
    min-height: 10px !important;
    max-height: 10px !important;
    flex: 0 0 10px !important;
    margin-left: 12px !important;
    align-self: center !important;
}

.hobi-field.hobi-select-field .hobi-custom-select__panel {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}