/**
 * MÓDULO BÚSQUEDA - Estilos
 * Mayoreo Joinet v1.0
 * Prefijo: jn-search-
 */

/* ========================================
   FUENTE LOCAL - MONTSERRAT (Solo módulo búsqueda)
   ======================================== */

/* Excepciones para iconos */
.jn-search-container .fa,
.jn-search-container .fas,
.jn-search-container .far,
.jn-search-container .fal,
.jn-search-container .fab,
.jn-search-container [class*="fa-"] {
    font-family: 'Font Awesome 6 Free' !important;
}

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */
.jn-search-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin: 20px 0;
}

.jn-search-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ========================================
   FILA DE BÚSQUEDA PRINCIPAL
   ======================================== */
.jn-search-row {
    display: flex;
    gap: 15px;
    align-items: stretch;
}

.jn-search-main {
    flex-wrap: nowrap;
}

/* ========================================
   INPUT DE BÚSQUEDA
   ======================================== */
.jn-search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.jn-search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 18px;
    pointer-events: none;
}

.jn-search-input {
    width: 100%;
    padding: 14px 20px 14px 50px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
}

.jn-search-input:focus {
    outline: none;
    border-color: #ff0000;
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.jn-search-input::placeholder {
    color: #adb5bd;
}

/* ========================================
   BOTÓN DE BÚSQUEDA
   ======================================== */
.jn-search-btn {
    background: linear-gradient(135deg, #333333 0%, #000000 100%);
    color: white;
    border: none;
    padding: 14px 35px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.jn-search-btn:hover {
    background: linear-gradient(135deg, #444444 0%, #111111 100%);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

.jn-search-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.jn-search-btn i {
    font-size: 18px;
}

/* ========================================
   FILTROS
   ======================================== */
.jn-search-filters {
    flex-wrap: wrap;
}

.jn-search-filter {
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jn-search-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
}

.jn-search-label i {
    color: #ff0000;
    font-size: 14px;
}

.jn-search-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23495057' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

.jn-search-select:focus {
    outline: none;
    border-color: #ff0000;
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.jn-search-select:hover {
    border-color: #ff0000;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 992px) {
    .jn-search-filter {
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .jn-search-container {
        padding: 20px 15px;
    }

    .jn-search-main {
        flex-direction: column;
    }

    .jn-search-input-wrapper {
        min-width: 100%;
    }

    .jn-search-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }

    .jn-search-filter {
        min-width: 100%;
    }

    .jn-search-filters {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .jn-search-container {
        padding: 12px 8px;
        margin: 8px 0;
    }

    .jn-search-input-wrapper {
        min-width: 100%;
    }

    .jn-search-input {
        padding: 11px 12px 11px 40px;
        font-size: 13px;
    }

    .jn-search-icon {
        font-size: 15px;
        left: 10px;
    }

    .jn-search-btn {
        font-size: 14px;
        padding: 11px 18px;
    }

    .jn-search-select {
        padding: 9px 32px 9px 10px;
        font-size: 12px;
    }

    .jn-search-label {
        font-size: 11px;
    }

    .jn-search-label i {
        font-size: 12px;
    }
}

/* ========================================
   ANIMACIONES
   ======================================== */
@keyframes jn-search-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.jn-search-container {
    animation: jn-search-fadeIn 0.3s ease-out;
}

/* ========================================
   ESTADOS DE CARGA
   ======================================== */
.jn-search-form.loading .jn-search-btn {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.jn-search-form.loading .jn-search-btn::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: jn-search-spin 0.6s linear infinite;
}

@keyframes jn-search-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   FILTROS EN TIEMPO REAL - Estilos Pro
   ======================================== */

/* Efecto al cambiar filtro */
.jn-filter-active {
    border-color: #ff0000 !important;
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.2) !important;
    transform: scale(1.02);
    transition: all 0.2s ease;
}

/* Loading overlay */
.jn-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
    backdrop-filter: blur(2px);
}

.jn-loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.jn-loading-spinner span {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.jn-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f0f0f0;
    border-top-color: #ff0000;
    border-radius: 50%;
    animation: jn-search-spin 0.8s linear infinite;
}

/* Container en loading */
.jn-results-container.jn-loading {
    position: relative;
    min-height: 200px;
}

.jn-results-container.jn-loading .jn-results-table {
    opacity: 0.4;
    pointer-events: none;
}

/* Filtros con efecto hover mejorado */
.jn-search-select {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.jn-search-select:hover {
    border-color: #ff0000;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.jn-search-select:focus {
    transform: translateY(-1px);
}

/* Filtro con valor seleccionado */
.jn-search-select:not([value=""]):valid {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.03);
}

/* Badge de filtro activo */
.jn-search-filter.has-value .jn-search-label::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    margin-left: 6px;
    animation: jn-pulse 2s infinite;
}

@keyframes jn-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* Animación de entrada para filas */
.jn-fade-in {
    animation: jn-fadeInRow 0.3s ease-out forwards;
}

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

/* Stagger animation para filas */
.jn-results-row:nth-child(1) { animation-delay: 0.02s; }
.jn-results-row:nth-child(2) { animation-delay: 0.04s; }
.jn-results-row:nth-child(3) { animation-delay: 0.06s; }
.jn-results-row:nth-child(4) { animation-delay: 0.08s; }
.jn-results-row:nth-child(5) { animation-delay: 0.10s; }
.jn-results-row:nth-child(n+6) { animation-delay: 0.12s; }

/* Sin resultados */
.jn-no-results {
    padding: 60px 20px !important;
    text-align: center;
}

.jn-no-results-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.jn-no-results-content i {
    font-size: 48px;
    color: #ccc;
}

.jn-no-results-content h4 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.jn-no-results-content p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Error */
.jn-error {
    padding: 40px 20px !important;
    text-align: center;
    color: #dc3545;
    font-size: 16px;
}

.jn-error i {
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
}

/* Tiempo de búsqueda */
.jn-search-time {
    font-size: 12px;
    color: #28a745;
    font-weight: 500;
    margin-left: 8px;
}

/* Filtros row mejorado */
.jn-search-filters {
    background: rgba(0, 0, 0, 0.02);
    padding: 15px;
    border-radius: 8px;
    margin-top: 5px;
}

/* Labels de filtros con icono */
.jn-search-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
}

/* Indicador de resultados en filtro */
.jn-search-select option {
    padding: 8px;
}

/* Transición suave en contenedor */
.jn-results-container {
    transition: opacity 0.3s ease;
}

/* Form en modo loading */
.jn-search-form.jn-loading .jn-search-select {
    pointer-events: none;
    opacity: 0.6;
}

.jn-search-form.jn-loading .jn-search-input {
    pointer-events: none;
    opacity: 0.6;
}

/* Tooltip en filtros */
.jn-search-filter {
    position: relative;
}

/* Highlight del filtro seleccionado */
.jn-search-select:focus option:checked {
    background: linear-gradient(135deg, #ff0000, #cc0000);
    color: white;
}

/* ========================================
   BUSCADOR DE MARCA - Mismo estilo que principal
   ======================================== */

.jn-search-brand {
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
}

.jn-brand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.jn-brand-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.jn-brand-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.jn-brand-name {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: #ff0000;
}

.jn-brand-count {
    font-size: 13px;
    color: #495057;
    font-weight: 500;
}

/* Responsive para buscador de marca */
@media (max-width: 768px) {
    .jn-brand-name {
        font-size: 20px;
    }

    .jn-brand-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========================================
   BUSCADOR DE CATEGORÍA - Mismo estilo que marca
   ======================================== */

.jn-search-category {
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
}

/* ========================================
   BUSCADOR ESPECIAL (Rebaja/Remate)
   ======================================== */

.jn-search-special {
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
}

/* ========================================
   TOGGLE BÚSQUEDA GLOBAL/LOCAL
   ======================================== */

.jn-search-scope {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
    border-radius: 8px;
    border: 1px solid #ffc107;
}

/* Toggle switch container */
.jn-scope-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

/* Hidden checkbox */
.jn-scope-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Toggle slider */
.jn-scope-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: #ccc;
    border-radius: 26px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.jn-scope-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Toggle activo */
.jn-scope-toggle input:checked + .jn-scope-slider {
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
}

.jn-scope-toggle input:checked + .jn-scope-slider::before {
    transform: translateX(22px);
}

/* Hover en toggle */
.jn-scope-toggle:hover .jn-scope-slider {
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.3);
}

.jn-scope-toggle input:checked + .jn-scope-slider:hover {
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.2);
}

/* Label del toggle */
.jn-scope-label {
    font-size: 14px;
    color: #495057;
    line-height: 1.4;
}

.jn-scope-label strong {
    color: #ff0000;
    font-weight: 700;
}

/* Botón reset/volver */
.jn-scope-reset {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    color: #495057;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.jn-scope-reset:hover {
    border-color: #ff0000;
    color: #ff0000;
    background: #fff5f5;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 0, 0, 0.15);
    text-decoration: none;
}

.jn-scope-reset i {
    font-size: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .jn-search-scope {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .jn-scope-reset {
        width: 100%;
        justify-content: center;
    }

    .jn-scope-label {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .jn-search-scope {
        padding: 10px 12px;
    }

    .jn-scope-slider {
        width: 42px;
        height: 24px;
    }

    .jn-scope-slider::before {
        width: 18px;
        height: 18px;
    }

    .jn-scope-toggle input:checked + .jn-scope-slider::before {
        transform: translateX(18px);
    }

    .jn-scope-label {
        font-size: 12px;
    }

    .jn-scope-reset {
        font-size: 12px;
        padding: 7px 14px;
    }
}
