/**
 * Custom Select Component - Estilos globales
 * Select personalizado reutilizable con colores corporativos
 */

/* Wrapper del select */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* El select original se oculta visualmente pero sigue funcional */
.custom-select-wrapper select.custom-select-original {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
    z-index: -1;
}

/* Display del valor seleccionado */
.custom-select-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md, 8px);
    cursor: pointer;
    transition: all 0.2s;
    height: 42px;
    min-width: 140px;
    font-size: 0.95rem;
    color: #333;
    box-sizing: border-box;
}

.custom-select-display:hover {
    border-color: var(--primary-color, #e91e8c);
}

.custom-select-display.open {
    border-color: var(--primary-color, #e91e8c);
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.15);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-display .selected-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select-display .selected-text.placeholder {
    color: #999;
}

.custom-select-display .select-arrow {
    margin-left: 10px;
    color: #666;
    transition: transform 0.2s;
    font-size: 0.8rem;
}

.custom-select-display.open .select-arrow {
    transform: rotate(180deg);
}

/* Dropdown de opciones */
.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: 400px;
    background: white;
    border: 1px solid var(--primary-color, #e91e8c);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    z-index: 10000;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
}

/* Cuando el dropdown está dentro de un modal, el JS calculará la posición */
.custom-select-dropdown.in-modal {
    position: fixed;
    z-index: 100001;
    border-top: 1px solid var(--primary-color, #e91e8c);
    border-radius: 8px;
    /* El minWidth se establece por JS, width: max-content permite expandirse al contenido */
    width: max-content;
    max-width: 90vw;
}

.custom-select-dropdown.show {
    display: block;
    animation: selectDropdownFadeIn 0.15s ease;
}

@keyframes selectDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Opciones individuales */
.custom-select-option {
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.custom-select-option:hover {
    background: var(--primary-light, #fce4f1);
}

.custom-select-option.selected {
    background: var(--primary-color, #e91e8c);
    color: white;
}

.custom-select-option.selected:hover {
    background: var(--primary-dark, #c4177a);
}

.custom-select-option:last-child {
    border-radius: 0 0 8px 8px;
}

/* Icono de check para opción seleccionada */
.custom-select-option .option-check {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    opacity: 0;
}

.custom-select-option.selected .option-check {
    opacity: 1;
}

/* Separador de grupos */
.custom-select-separator {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

/* Búsqueda dentro del select */
.custom-select-search {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.custom-select-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
}

.custom-select-search input:focus {
    border-color: var(--primary-color, #e91e8c);
}

.custom-select-search input::placeholder {
    color: #aaa;
}

/* Mensaje sin resultados */
.custom-select-no-results {
    padding: 15px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* Scrollbar personalizado */
.custom-select-dropdown::-webkit-scrollbar {
    width: 6px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 0 0 8px 0;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
    background: var(--primary-color, #e91e8c);
    border-radius: 3px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark, #c4177a);
}

/* Estados deshabilitado */
.custom-select-wrapper.disabled .custom-select-display {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.custom-select-wrapper.disabled .custom-select-display:hover {
    border-color: #ddd;
}

/* Tamaño pequeño */
.custom-select-wrapper.select-sm .custom-select-display {
    padding: 6px 10px;
    min-height: 34px;
    font-size: 0.85rem;
}

.custom-select-wrapper.select-sm .custom-select-option {
    padding: 8px 10px;
    font-size: 0.85rem;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .custom-select-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 50vh;
        border-radius: 16px 16px 0 0;
        border: none;
        box-shadow: 0 -5px 30px rgba(0,0,0,0.2);
    }

    .custom-select-dropdown.show {
        animation: selectDropdownSlideUp 0.2s ease;
    }

    @keyframes selectDropdownSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .custom-select-dropdown::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
        margin: 10px auto;
    }

    .custom-select-option {
        padding: 14px 16px;
    }

    .custom-select-option:last-child {
        border-radius: 0;
        margin-bottom: 10px;
    }
}

/* Overlay para móvil */
.custom-select-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
}

.custom-select-overlay.show {
    display: block;
}
