/**
 * Випадаючі списки калькулятора у стилі сайту (wst-calc-select.js)
 *
 * Блоки:
 * - .wst-dd-native — нативний select лишається в DOM (джерело правди), але не видно
 * - .wst-dd-head — поле: ті самі CSS-змінні BA Forms, що й у нативного select (ba-style.css),
 *   тому виглядає однаково в усіх формах калькулятора
 * - .wst-dd-list — список (position: fixed, координати ставить JS), стиль — як у списків
 *   на картці товару магазину (store-page.css: .ba-custom-select)
 * - .wst-opt-badge — бейдж «sale» (сам стиль бейджа — у shared/wst-discount.css)
 *
 * Залежності: shared/wst-discount.css (.wst-opt-badge), змінні BA Forms (--field-*)
 * Використовується в: templates/gridbox/index.php (разом з wst-calc-select.js)
 *
 * Історія змін:
 * - 2026-10-30: Створено
 */

.wst-dd-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0);
}

.wst-dd {
    position: relative;
    margin-top: 8px; /* як у select калькулятора (calculator-page.css) */
}

.wst-dd-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    cursor: pointer;
    text-align: left;
    box-sizing: border-box;
    box-shadow: 0 0 34px 0 rgba(0, 0, 0, 0.1);
    background: var(--field-background-color);
    border-top: calc(var(--field-border-top) * var(--field-border-width)) solid var(--field-border-color);
    border-right: calc(var(--field-border-right) * var(--field-border-width)) solid var(--field-border-color);
    border-bottom: calc(var(--field-border-bottom) * var(--field-border-width)) solid var(--field-border-color);
    border-left: calc(var(--field-border-left) * var(--field-border-width)) solid var(--field-border-color);
    border-radius: var(--field-border-radius);
    color: var(--field-typography-color);
    font-family: var(--field-typography-font-family);
    font-size: var(--field-typography-font-size);
    font-style: var(--field-typography-font-style);
    font-weight: var(--field-typography-font-weight);
    letter-spacing: var(--field-typography-letter-spacing);
    line-height: var(--field-typography-line-height);
    height: calc(var(--field-typography-line-height) + var(--field-padding-top) + var(--field-padding-bottom) + (var(--field-border-top) * var(--field-border-width)) + (var(--field-border-bottom) * var(--field-border-width)));
    padding: 0 var(--field-padding-right) 0 var(--field-padding-left);
    transition: border-color 0.2s ease;
}

.wst-dd-head:focus,
.wst-dd.is-open .wst-dd-head {
    outline: none;
    border-color: var(--theme-color);
}

.wst-dd-value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Бейдж у полі — лише коли обрано опцію зі знижкою */
.wst-dd .wst-dd-head-badge {
    display: none;
    margin-left: 0;
    flex: 0 0 auto;
}
.wst-dd--sale .wst-dd-head-badge {
    display: inline-block;
}

/* Стрілка */
.wst-dd-caret {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    margin: -4px 2px 0 4px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.25s ease, margin 0.25s ease;
    opacity: 0.8;
}
.wst-dd.is-open .wst-dd-caret {
    transform: rotate(-135deg);
    margin-top: 4px;
}

.wst-dd--disabled .wst-dd-head {
    cursor: no-drop;
    opacity: 0.6;
}

/* Список */
.wst-dd-list {
    display: none;
    position: fixed;
    z-index: 10050;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    overflow-y: auto;
    box-sizing: border-box;
    background: var(--field-background-color, #222222);
    border: 1px solid var(--field-border-color, #333333);
    border-radius: var(--field-border-radius, 5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.wst-dd.is-open .wst-dd-list {
    display: block;
}

.wst-dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px var(--field-padding-right, 12px) 9px var(--field-padding-left, 12px);
    margin: 0;
    cursor: pointer;
    color: var(--field-typography-color, #ffffff);
    font-family: var(--field-typography-font-family);
    font-size: var(--field-typography-font-size);
    font-weight: var(--field-typography-font-weight);
    line-height: 1.3;
    list-style: none;
}
.wst-dd-item::before,
.wst-dd-item::after {
    display: none !important;
}
.wst-dd-item:hover {
    background: rgba(255, 255, 255, 0.06);
}
.wst-dd-item.is-selected {
    background: #26489e; /* як обраний пункт у списках магазину */
}
.wst-dd-item.is-disabled {
    cursor: no-drop;
    opacity: 0.45;
}
.wst-dd-item .wst-opt-badge {
    margin-left: auto;
}
.wst-dd-text {
    min-width: 0;
}
