/* Shared Custom Dropdown Component Styles */

/* ===== Dropdown Animations ===== */
@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes dropdownOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
}

@keyframes dropdownInTop {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes dropdownOutTop {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }
}

@keyframes optionIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select-wrapper select {
    display: none !important;
}

.custom-select {
    position: relative;
    display: flex;
    flex-direction: column;
}

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 16px;
    height: 36px;
    color: var(--md-on-surface);
    background: var(--md-surface-container-low);
    cursor: pointer;
    border: none;
    border-radius: 32px;
    transition: all var(--md-duration-s) var(--md-easing-standard);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 2px 5px rgba(0, 0, 0, 0.05);
    gap: 8px;
}

.dark .custom-select-trigger {
    background: var(--md-surface-container-high);
    color: var(--md-on-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.custom-select-trigger:hover {
    background: var(--md-surface-container);
}

.dark .custom-select-trigger:hover,
.dark .open .custom-select-trigger {
    background: var(--md-surface-container-highest);
}

.custom-select.open .custom-select-trigger {
    border-radius: 20px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background: var(--md-surface-container-low);
}

.dark .custom-select.open .custom-select-trigger {
    background: var(--md-surface-container-high);
}

.custom-select-trigger .arrow {
    display: flex;
    align-items: center;
    transition: transform var(--md-duration-s) var(--md-easing-standard);
    color: var(--md-on-surface-variant) !important;
    margin: 0;
}

.dark .custom-select-trigger .arrow {
    color: var(--md-on-surface-variant) !important;
}

.custom-select.open .custom-select-trigger .arrow {
    transform: rotate(180deg);
}

.custom-options {
    position: fixed;
    display: block;
    width: auto;
    max-width: calc(100vw - 32px);
    border: none;
    background: var(--md-surface-container-low);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px) scale(0.95);
    transform-origin: top;
    border-radius: 0 0 20px 20px;
    z-index: 2500;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.custom-options.show {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    animation: dropdownIn 0.25s var(--md-easing-enter) forwards;
}

.custom-options.hiding {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    animation: dropdownOut 0.2s var(--md-easing-exit) forwards;
}

.custom-options.open-top {
    transform: translateY(8px) scale(0.95);
    transform-origin: bottom;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
}

.custom-options.open-top.show {
    animation: dropdownInTop 0.25s var(--md-easing-enter) forwards;
}

.custom-options.open-top.hiding {
    animation: dropdownOutTop 0.2s var(--md-easing-exit) forwards;
}

.custom-select.align-right .custom-options {
    left: auto;
    right: 0;
}

.custom-options-inner {
    max-height: 70vh;
    overflow-y: auto;
    padding: 4px 8px;
}

.dark .custom-options {
    background: var(--md-surface-container);
}

.custom-group-label {
    padding: 5px 20px 0 7px;
    font-size: 14px;
    font-weight: 600;
    color: var(--md-on-surface-variant);
    letter-spacing: 0.2px;
    opacity: 0;
    animation: optionIn 0.2s var(--md-easing-standard) forwards;
}

.custom-options.show .custom-group-label {
    animation: optionIn 0.2s var(--md-easing-standard) forwards;
}

.custom-option {
    position: relative;
    display: block;
    padding: 4px 12px;
    margin: 2px 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--md-on-surface);
    cursor: pointer;
    transition: background var(--md-duration-s) var(--md-easing-standard), color var(--md-duration-s) var(--md-easing-standard);
    border-radius: 24px;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-4px);
}

.custom-options.show .custom-option {
    animation: optionIn 0.25s var(--md-easing-standard) forwards;
}

.custom-option.selected {
    background: var(--md-primary-container);
    color: var(--md-on-primary-container);
}

.custom-option:hover {
    background: var(--md-surface-container-high);
}

/* Keyboard-navigation highlight (aria-activedescendant target) */
.custom-option.kb-active {
    background: var(--md-surface-container-high);
    outline: var(--md-focus-ring-width) solid var(--md-focus-ring-color);
    outline-offset: -2px;
}

/* Two-line option (name + description). Only applies when the source <option>
   carries a data-desc/data-i18n-desc attribute (see ui-utils.js addOption).
   Options without a description keep the single-line nowrap layout above. */
.custom-option.has-desc {
    white-space: normal;
    padding: 6px 12px;
}

.custom-option-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-option-desc {
    display: block;
    font-size: 12px;
    color: var(--md-on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-option.selected .custom-option-desc {
    color: var(--md-on-primary-container);
    opacity: 0.85;
}

/* Custom Select Open Top Support */
.custom-select.open-top .custom-select-trigger {
    border-radius: 20px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.current-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}
