/* public/css/sorting.css */

.csc-sorting-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.csc-result-count {
    font-size: 0.9em;
    color: #718096;
    font-weight: 600;
}

.csc-sorting-select-wrapper {
    position: relative;
}

/* El select nativo se mantiene visible por defecto (Móviles) */
.csc-sorting-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    font-size: 0.9em;
    font-weight: 600;
    padding: 10px 35px 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    min-width: 200px;
    
    /* Flecha personalizada */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.csc-sorting-select:hover {
    border-color: #cbd5e0;
    background-color: #fff;
}

.csc-sorting-select:focus {
    border-color: var(--csc-primary-color, #E74C3C);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

/* Dropdown customizado oculto por defecto en Móviles */
.csc-custom-select-desktop {
    display: none;
}

/* --- ESTILOS EXCLUSIVOS PARA MODO ESCRITORIO --- */
@media (min-width: 768px) {
    /* Ocultar el select nativo del navegador */
    .csc-sorting-select {
        display: none !important;
    }

    /* Mostrar y dar formato al dropdown premium */
    .csc-custom-select-desktop {
        display: block;
        position: relative;
        min-width: 200px;
        font-family: inherit;
    }

    .csc-custom-select-trigger {
        background-color: #f8fafc;
        border: 1px solid #e2e8f0;
        color: #4a5568;
        font-size: 0.9em;
        font-weight: 600;
        padding: 10px 35px 10px 15px;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        user-select: none;
        box-sizing: border-box;
        
        /* Flecha SVG */
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 14px;
    }

    .csc-custom-select-trigger:hover {
        border-color: #cbd5e0;
        background-color: #fff;
    }

    /* Estado Abierto (Open) */
    .csc-custom-select-desktop.open .csc-custom-select-trigger {
        border-color: var(--csc-primary-color, #E74C3C);
        background-color: #fff;
        box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
        
        /* Rotar flecha */
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'%3E%3C/polyline%3E%3C/svg%3E");
    }

    /* Caja contenedora de opciones */
    .csc-custom-select-options {
        position: absolute;
        top: calc(100% + 5px);
        left: 0;
        right: 0;
        background-color: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
        z-index: 100;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-5px);
        transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
        overflow: hidden;
        padding: 4px;
        box-sizing: border-box;
    }

    .csc-custom-select-desktop.open .csc-custom-select-options {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* Opciones individuales */
    .csc-csc-custom-option,
    .csc-custom-option {
        padding: 8px 12px;
        font-size: 0.9em;
        font-weight: 500;
        color: #4a5568;
        cursor: pointer;
        border-radius: 6px;
        transition: all 0.15s ease;
        text-align: left;
        user-select: none;
        box-sizing: border-box;
    }

    .csc-custom-option:hover {
        background-color: #f1f5f9;
        color: #1a202c;
    }

    /* Opción Seleccionada (Highlight de marca) */
    .csc-custom-option.selected {
        background-color: var(--csc-primary-color, #E74C3C);
        color: var(--csc-primary-text-color, #fff);
    }
}

/* Responsive */
@media (max-width: 767px) {
    .csc-sorting-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .csc-sorting-select, .csc-sorting-select-wrapper {
        width: 100%;
    }
}