/* Custom Dropdown with Search - TorgAI 2025 */

/* Common dropdown styling for all custom dropdowns */
.custom-dropdown {
    position: relative;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    z-index: 1000;
}

/* Type dropdown specific width */
.type-dropdown {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
}

/* Price dropdown specific width */
.price-dropdown {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
}

/* Region dropdown specific width */
.region-dropdown {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
}

/* Selected value display - match site design */
.dropdown-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    padding-right: 40px;
    background: rgba(43, 43, 43, 0.9);
    border: 2px solid rgba(243, 159, 27, 0.2);
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: auto;
    backdrop-filter: blur(10px);
    font-size: 14px;
    font-weight: 500;
}

.dropdown-selected:hover {
    border-color: rgba(243, 159, 27, 1);
    background: rgba(43, 43, 43, 0.95);
}

.dropdown-selected.active {
    border-color: rgba(243, 159, 27, 1);
    box-shadow: 0 0 0 3px rgba(243, 159, 27, 0.1);
}

.dropdown-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(243, 159, 27, 1);
    transition: transform 0.2s ease;
}

.dropdown-selected.active .dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* Dropdown panel - ABSOLUTE MAXIMUM Z-INDEX */
.dropdown-panel {
    position: fixed !important;
    /* Position will be set by JavaScript */
    min-width: 200px;
    background: rgba(30, 30, 30, 0.98) !important;
    border: 2px solid rgba(243, 159, 27, 0.3) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8) !important;
    z-index: 2147483647 !important; /* Maximum possible z-index */
    isolation: isolate !important; /* Create new stacking context */
    transform: translateZ(9999px) !important; /* Force to top layer */
    animation: dropdownOpen 0.2s ease;
    backdrop-filter: blur(10px);
}

@keyframes dropdownOpen {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search input wrapper */
.dropdown-search-wrapper {
    position: relative;
    padding: 12px;
    border-bottom: 2px solid rgba(243, 159, 27, 0.1);
    background: rgba(0, 0, 0, 0.3);
    z-index: 2147483648 !important;
}

.dropdown-search {
    width: 100%;
    padding: 10px 36px 10px 12px;
    background: rgba(43, 43, 43, 0.8);
    border: 1px solid rgba(243, 159, 27, 0.2);
    border-radius: 6px;
    color: #ffffff;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
}

.dropdown-search::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.dropdown-search:focus {
    background: rgba(43, 43, 43, 0.95);
    border-color: rgba(243, 159, 27, 0.6);
}

.search-icon-small {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

/* Dropdown list */
.dropdown-list {
    min-height: 100px;
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    background: transparent;
    position: relative;
    z-index: 2147483648 !important;
}

/* Custom scrollbar */
.dropdown-list::-webkit-scrollbar {
    width: 8px;
}

.dropdown-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.dropdown-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.dropdown-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Region items */
.dropdown-item {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    z-index: 2147483649 !important;
}

.dropdown-item:hover {
    background: rgba(243, 159, 27, 0.15);
    color: #ffffff;
}

.dropdown-item.selected {
    background: rgba(243, 159, 27, 0.2);
    color: rgba(243, 159, 27, 1);
}

.dropdown-item.highlighted {
    background: rgba(243, 159, 27, 0.1);
    outline: 1px solid rgba(243, 159, 27, 0.3);
}

/* Region name and count */
.region-name {
    flex: 1;
    font-weight: 500;
}

.region-count {
    margin-left: 12px;
    padding: 2px 6px;
    background: rgba(243, 159, 27, 0.15);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(243, 159, 27, 0.8);
}

.dropdown-item:hover .region-count {
    background: rgba(243, 159, 27, 0.25);
    color: rgba(243, 159, 27, 1);
}

.dropdown-item.selected .region-count {
    background: rgba(243, 159, 27, 0.3);
    color: #ffffff;
}

/* No results message */
.no-results {
    padding: 24px 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .custom-dropdown {
        min-width: 100%;
    }

    .dropdown-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 70vh;
        border-radius: 24px 24px 0 0;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .dropdown-list {
        max-height: calc(70vh - 80px);
    }
}

/* Dark overlay for mobile */
@media (max-width: 768px) {
    .dropdown-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        animation: fadeIn 0.2s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* Highlighted search match */
.match-highlight {
    color: rgba(243, 159, 27, 1);
    font-weight: 600;
    text-decoration: underline;
}