/**
 * NIC Registry Platform - Accessible Custom UI Select Component
 * 
 * Complies with WAI-ARIA 1.2 Combobox pattern & Constitution Article 1.2.
 */

.ui-select-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    user-select: none;
    font-family: inherit;
}

/* Native select is hidden visually but stays functional for form submits & screen readers */
.ui-select-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;
    pointer-events: none;
}

/* Custom Combobox Trigger Button */
.ui-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    outline: none;
}

.ui-select-trigger:hover {
    border-color: var(--primary);
}

.ui-select-trigger:focus-visible,
.ui-select-wrapper.is-open .ui-select-trigger {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.ui-select-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.ui-select-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform 0.2s ease, color 0.15s ease;
}

.ui-select-wrapper.is-open .ui-select-arrow {
    transform: rotate(180deg);
    color: var(--primary);
}

/* Dropdown Popup Listbox */
.ui-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px 0;
    list-style: none;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.ui-select-wrapper.is-open .ui-select-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Option Items */
.ui-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.ui-select-option:hover,
.ui-select-option.is-active {
    background-color: var(--primary-light);
    color: var(--primary);
}

[data-theme="dark"] .ui-select-option:hover,
[data-theme="dark"] .ui-select-option.is-active {
    background-color: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.ui-select-option.is-selected {
    font-weight: 700;
    color: var(--primary);
    background-color: var(--primary-light);
}

[data-theme="dark"] .ui-select-option.is-selected {
    background-color: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
}

.ui-select-check {
    opacity: 0;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 800;
}

.ui-select-option.is-selected .ui-select-check {
    opacity: 1;
}

/* Scrollbar styling */
.ui-select-dropdown::-webkit-scrollbar {
    width: 6px;
}

.ui-select-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.ui-select-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* Flag & Label alignment styles */
.ui-select-label-wrap,
.ui-select-value {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.ui-select-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    line-height: 1;
    flex-shrink: 0;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
    vertical-align: middle;
}

.ui-select-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lang-select-container {
    min-width: 140px;
    flex-shrink: 0;
}
