/* ==========================================================================
   Universal Searchable Select Component Styles
   Theme: Polika Platform Dark / Cyberpunk Neon
   ========================================================================== */

/* Hidden native select (kept accessible to form submissions & DOM queries) */
select.searchable-select-hidden {
    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 !important;
    pointer-events: none !important;
}

/* Wrapper Container */
.searchable-select-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-main, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    user-select: none;
    vertical-align: middle;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

/* Inherit flex behaviors if the select was in a flexbox */
.searchable-select-wrapper.is-flex {
    flex: 1 1 auto;
}

/* Dropdown Trigger */
.ss-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: var(--text-primary, #ffffff);
    font-size: 0.92rem;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    gap: 8px;
    outline: none;
}

.ss-trigger:hover:not(.is-disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.5);
}

.ss-trigger:focus:not(.is-disabled),
.searchable-select-wrapper.is-open .ss-trigger {
    border-color: var(--accent-color, #00f0ff);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15), 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Trigger Content & Label */
.ss-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    color: #ffffff;
    font-weight: 400;
}

.ss-label.is-placeholder {
    color: var(--text-secondary, #888888);
}

/* Trigger Arrow */
.ss-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #a0a0a0);
    font-size: 0.78rem;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.searchable-select-wrapper.is-open .ss-arrow {
    transform: rotate(180deg);
    color: var(--accent-color, #00f0ff);
}

/* Disabled State */
.searchable-select-wrapper.is-disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

.searchable-select-wrapper.is-disabled .ss-trigger {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.4);
}

/* Dropdown Panel */
.ss-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 220px;
    width: 100%;
    background: #141414;
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 10px;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.9), 0 0 15px rgba(0, 240, 255, 0.1);
    z-index: 99999;
    display: none;
    opacity: 0;
    transform: translateY(-6px) scale(0.99);
    transition: opacity 0.18s ease, transform 0.18s ease;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-sizing: border-box;
}

/* Open state for dropdown */
.searchable-select-wrapper.is-open .ss-dropdown {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Upwards opening when near bottom of screen */
.searchable-select-wrapper.is-open-up .ss-dropdown {
    top: auto;
    bottom: calc(100% + 6px);
    transform: translateY(6px) scale(0.99);
}

.searchable-select-wrapper.is-open.is-open-up .ss-dropdown {
    transform: translateY(0) scale(1);
}

/* Search Box Container */
.ss-search-container {
    position: relative;
    padding: 10px;
    background: #0d0d0d;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.ss-search-icon {
    position: absolute;
    left: 20px;
    color: var(--accent-color, #00f0ff);
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0.8;
}

.ss-search-input {
    width: 100%;
    padding: 8px 30px 8px 32px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ffffff;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.ss-search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
}

.ss-search-input:focus {
    background: rgba(0, 0, 0, 0.6);
    border-color: var(--accent-color, #00f0ff);
    box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.2);
}

/* Clear search button */
.ss-clear-btn {
    position: absolute;
    right: 18px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, transform 0.15s ease;
}

.ss-clear-btn:hover {
    color: #ffffff;
    transform: scale(1.1);
}

/* Options List Container */
.ss-options-list {
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 240, 255, 0.3) rgba(255, 255, 255, 0.03);
}

.ss-options-list::-webkit-scrollbar {
    width: 6px;
}

.ss-options-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
}

.ss-options-list::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.25);
    border-radius: 3px;
}

.ss-options-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.5);
}

/* Option Item */
.ss-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    color: #dddddd;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, padding-left 0.12s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    word-break: break-word;
    box-sizing: border-box;
}

.ss-option:last-child {
    border-bottom: none;
}

.ss-option:hover,
.ss-option.is-highlighted {
    background: rgba(0, 240, 255, 0.12);
    color: #ffffff;
    padding-left: 17px;
}

.ss-option.is-selected {
    background: rgba(0, 240, 255, 0.18);
    color: var(--accent-color, #00f0ff);
    font-weight: 500;
    border-left: 3px solid var(--accent-color, #00f0ff);
}

.ss-option.is-selected .ss-check-icon {
    display: inline-block;
}

.ss-option.is-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.ss-option-text {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ss-check-icon {
    display: none;
    color: var(--accent-color, #00f0ff);
    font-size: 0.8rem;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Option Highlight Match */
.ss-highlight-match {
    color: var(--accent-color, #00f0ff);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Optgroup Header */
.ss-optgroup-label {
    padding: 8px 12px 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-color, #00f0ff);
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.ss-optgroup-label:first-child {
    border-top: none;
}

/* No Results Message */
.ss-no-results {
    padding: 20px 14px;
    text-align: center;
    color: var(--text-secondary, #888888);
    font-size: 0.88rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.ss-no-results i {
    font-size: 1.2rem;
    opacity: 0.5;
    margin-bottom: 2px;
}

/* Small / Compact Table Row Dropdowns */
.ss-compact .ss-trigger {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 0.85rem;
    border-radius: 6px;
}

.ss-compact .ss-option {
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Full Width Utility */
.w-full > .searchable-select-wrapper,
.searchable-select-wrapper.w-full {
    width: 100%;
}
