/*
 * Searchable Select Styles
 * Custom styles for searchable dropdown
 */

.searchable-select-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.searchable-input {
    width: 100%;
    height: 50px;
    padding: 0 20px;
    border: 1px solid #f6f7f8;
    border-radius: 3px;
    background-color: #f6f7f8;
    font-size: 14px;
    font-weight: normal;
    line-height: 1;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-sizing: border-box;
    outline: none !important;
}

/* Remove outline for all focus states */
.searchable-input:focus,
.searchable-input:active,
.searchable-input:focus-visible,
.searchable-input:focus-within {
    outline: none !important;
    outline-style: none !important;
    outline-width: 0 !important;
    outline-color: transparent !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Additional comprehensive outline removal */
.searchable-select-wrapper input,
.searchable-select-wrapper input[type="text"] {
    outline: none !important;
    outline-style: none !important;
    outline-width: 0 !important;
    outline-offset: 0 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    border-radius: 3px !important;
}

.searchable-input:focus,
.searchable-select-wrapper.open .searchable-input {
    cursor: text;
    outline: none !important;
    box-shadow: none !important;
}

.searchable-arrow {
    position: absolute;
    right: 22px;
    top: 50%;
    width: 5px;
    height: 5px;
    margin-top: -4px;
    border-bottom: 2px solid #90a1b5;
    border-right: 2px solid #90a1b5;
    transform: rotate(45deg);
    transform-origin: 66% 66%;
    transition: all 0.15s ease-in-out;
    pointer-events: none;
    cursor: pointer;
}

.searchable-select-wrapper.open .searchable-arrow {
    transform: rotate(-135deg);
}

.searchable-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid rgba(68, 88, 112, 0.11);
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(68, 88, 112, 0.11);
    max-height: 300px;
    overflow-y: auto;
    z-index: 999;
    margin: 0;
    padding: 0;
    list-style: none;
    display: none;
    margin-top: 4px;
}

.searchable-select-wrapper.open .searchable-dropdown {
    display: block;
}

.searchable-option {
    padding: 12px 18px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    border-bottom: 1px solid #f6f7f8;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-option:last-child {
    border-bottom: none;
}

.searchable-option:hover,
.searchable-option.highlight {
    background-color: #f6f7f9;
    color: #333;
}

.searchable-option.selected {
    background-color: transparent;
    color: #333;
    font-weight: bold;
}

.searchable-option.selected:hover,
.searchable-option.selected.highlight {
    background-color: #f6f7f9;
    color: #333;
}

.no-results {
    padding: 12px 18px;
    color: #90a1b5;
    font-style: italic;
    cursor: default;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .searchable-dropdown {
        max-height: 200px;
    }
    
    .searchable-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Integration with existing form styles */
.section-field .searchable-select-wrapper {
    margin-bottom: 20px;
}

.box .searchable-select-wrapper {
    width: 100%;
}

/* Custom scrollbar for dropdown */
.searchable-dropdown::-webkit-scrollbar {
    width: 6px;
}

.searchable-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.searchable-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.searchable-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading state */
.searchable-select-wrapper.loading .searchable-input {
    background-image: url('data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><circle cx="10" cy="10" r="8" fill="none" stroke="%23ccc" stroke-width="2"/><path fill="%23666" d="M10 2a8 8 0 0 1 8 8"/></svg>');
    background-repeat: no-repeat;
    background-position: right 40px center;
    background-size: 16px 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Disabled state */
.searchable-select-wrapper.disabled .searchable-input {
    background-color: #e9ecef;
    color: #90a1b5;
    cursor: not-allowed;
    border-color: #e7ecf2;
    opacity: 0.6;
}

.searchable-select-wrapper.disabled .searchable-arrow {
    border-color: #cdd5de;
    opacity: 0.6;
}

.searchable-select-wrapper.disabled:hover .searchable-input {
    cursor: not-allowed;
}

/* Ensure disabled state overrides other states */
.searchable-select-wrapper.disabled .searchable-input:hover,
.searchable-select-wrapper.disabled .searchable-input:focus {
    background-color: #e9ecef !important;
    color: #90a1b5 !important;
    cursor: not-allowed !important;
    border-color: #e7ecf2 !important;
}

/* Error state */
.searchable-select-wrapper.error .searchable-input {
    border-color: #dc3545;
}

/* Success state */
.searchable-select-wrapper.success .searchable-input {
    border-color: #28a745;
}
