/**
 * MÓDULO FILTROS DE CATEGORÍAS - Estilos
 * Mayoreo Joinet v1.0
 * Prefijo: jn-fc- (filter-categories)
 */

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */
.jn-fc-container {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px 20px;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: visible;
    position: relative;
    z-index: 100;
}

/* ========================================
   HEADER DEL FILTRO
   ======================================== */
.jn-fc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.jn-fc-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.jn-fc-title i {
    color: #ff0000;
    font-size: 16px;
}

.jn-fc-toggle-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.jn-fc-toggle-btn:hover {
    background: #f0f0f0;
    color: #ff0000;
}

.jn-fc-toggle-btn i {
    transition: transform 0.3s ease;
}

.jn-fc-container.collapsed .jn-fc-toggle-btn i {
    transform: rotate(180deg);
}

/* ========================================
   CONTENIDO (COLLAPSIBLE)
   ======================================== */
.jn-fc-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow: visible;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.jn-fc-container.collapsed .jn-fc-content {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ========================================
   FILA DE FILTROS PRINCIPALES
   ======================================== */
.jn-fc-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    overflow: visible;
}

/* Fila inline - todos los filtros en una línea */
.jn-fc-row.jn-fc-row-inline {
    flex-wrap: nowrap;
    gap: 15px;
}

/* ========================================
   GRUPO DE FILTRO INDIVIDUAL
   ======================================== */
.jn-fc-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
    flex: 1;
    overflow: visible;
}

.jn-fc-group.jn-fc-group-small {
    flex: 0 0 auto;
    min-width: 120px;
}

/* Anchos específicos para fila inline - columnas iguales */
.jn-fc-row-inline .jn-fc-group-ordenar,
.jn-fc-row-inline .jn-fc-group-stock,
.jn-fc-row-inline .jn-fc-group-categorias,
.jn-fc-row-inline .jn-fc-group-marcas {
    flex: 1 1 0;
    min-width: 150px;
}

.jn-fc-row-inline .jn-fc-group-limpiar {
    flex: 0 0 auto;
    min-width: auto;
}

.jn-fc-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.jn-fc-label i {
    color: #ff0000;
    font-size: 12px;
}

/* ========================================
   SELECT DE FILTRO
   ======================================== */
.jn-fc-select {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background: white;
    cursor: pointer;
    transition: all 0.2s 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='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

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

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

.jn-fc-select.active {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.05);
}

/* ========================================
   BOTÓN LIMPIAR FILTROS
   ======================================== */
.jn-fc-clear-btn {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.jn-fc-clear-btn:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    transform: translateY(-1px);
}

.jn-fc-clear-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   SECCIÓN DE CATEGORÍAS - DROPDOWN
   ======================================== */
.jn-fc-categories-section {
    margin-top: 5px;
    overflow: visible;
    position: relative;
}

/* ========================================
   DROPDOWN CONTAINER
   ======================================== */
.jn-fc-dropdown {
    position: relative;
    width: 100%;
    z-index: 1000;
}

.jn-fc-dropdown.open {
    z-index: 9999;
}

.jn-fc-dropdown-btn {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    position: relative;
}

.jn-fc-dropdown-btn:hover {
    border-color: #ff0000;
}

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

.jn-fc-dropdown.open .jn-fc-dropdown-btn {
    border-color: #ff0000;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.jn-fc-dropdown-text {
    flex: 1;
    color: #333;
}

.jn-fc-dropdown-count {
    background: #ff0000;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: none;
}

.jn-fc-dropdown-count.visible {
    display: inline-block;
}

.jn-fc-dropdown-arrow {
    position: absolute;
    right: 12px;
    color: #666;
    transition: transform 0.2s ease;
}

.jn-fc-dropdown.open .jn-fc-dropdown-arrow {
    transform: rotate(180deg);
}

/* ========================================
   DROPDOWN MENU
   ======================================== */
.jn-fc-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #ff0000;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    z-index: 99999;
    display: none;
    max-height: 400px;
    overflow: hidden;
}

.jn-fc-dropdown.open .jn-fc-dropdown-menu {
    display: block;
    animation: jn-fc-slideDown 0.2s ease;
}

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

/* Buscador */
.jn-fc-dropdown-search {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
}

.jn-fc-dropdown-search i {
    color: #999;
}

.jn-fc-dropdown-search input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    outline: none;
}

.jn-fc-dropdown-search input::placeholder {
    color: #aaa;
}

/* Acciones rápidas */
.jn-fc-dropdown-actions {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.jn-fc-action-btn {
    background: none;
    border: 1px solid #ddd;
    color: #666;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.jn-fc-action-btn:hover {
    border-color: #ff0000;
    color: #ff0000;
    background: rgba(255, 0, 0, 0.05);
}

/* Lista de categorías */
.jn-fc-dropdown-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 5px;
}

.jn-fc-dropdown-list::-webkit-scrollbar {
    width: 6px;
}

.jn-fc-dropdown-list::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.jn-fc-dropdown-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.jn-fc-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #ff0000;
}

/* ========================================
   ITEM DE CATEGORÍA EN LA LISTA
   ======================================== */
.jn-fc-category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.jn-fc-category-item:last-child {
    border-bottom: none;
}

.jn-fc-category-item:hover {
    background: #fff5f5;
}

.jn-fc-category-item.checked {
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.08) 0%, rgba(255, 0, 0, 0.03) 100%);
}

.jn-fc-category-item.hidden {
    display: none;
}

.jn-fc-category-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #ff0000;
    cursor: pointer;
    flex-shrink: 0;
}

.jn-fc-category-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jn-fc-category-count {
    font-size: 11px;
    color: #666;
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 12px;
    flex-shrink: 0;
    font-weight: 500;
}

.jn-fc-category-item.checked .jn-fc-category-count {
    background: #ff0000;
    color: white;
}

/* ========================================
   BOTÓN "SOLO" PARA FILTRAR UNA CATEGORÍA
   ======================================== */
.jn-fc-solo-btn {
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.jn-fc-category-item:hover .jn-fc-solo-btn {
    opacity: 1;
    transform: scale(1);
}

.jn-fc-solo-btn:hover {
    background: linear-gradient(135deg, #cc0000 0%, #990000 100%);
    transform: scale(1.05);
}

.jn-fc-category-item.checked .jn-fc-solo-btn {
    opacity: 1;
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

.jn-fc-category-item.checked .jn-fc-solo-btn:hover {
    background: linear-gradient(135deg, #1e7e34 0%, #155724 100%);
}

/* ========================================
   CHIPS DE FILTROS ACTIVOS
   ======================================== */
.jn-fc-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    margin-top: 10px;
}

.jn-fc-active-label {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    display: flex;
    align-items: center;
    padding-right: 5px;
}

.jn-fc-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    animation: jn-fc-chipIn 0.2s ease;
}

@keyframes jn-fc-chipIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.jn-fc-chip-remove {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.jn-fc-chip-remove:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.jn-fc-chip-more {
    background: #6c757d;
    cursor: pointer;
}

.jn-fc-chip-more:hover {
    background: #5a6268;
}

/* ========================================
   CONTADOR DE RESULTADOS
   ======================================== */
.jn-fc-results-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #333;
    padding: 8px 12px;
    background: #e8f5e9;
    border-radius: 6px;
    border-left: 3px solid #28a745;
}

.jn-fc-results-count i {
    color: #28a745;
}

.jn-fc-results-count strong {
    color: #28a745;
}

/* ========================================
   ESTADO LOADING
   ======================================== */
.jn-fc-loading {
    position: relative;
    pointer-events: none;
}

.jn-fc-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */
@media (max-width: 1024px) {
    .jn-fc-row.jn-fc-row-inline {
        flex-wrap: wrap;
    }

    .jn-fc-row-inline .jn-fc-group-ordenar,
    .jn-fc-row-inline .jn-fc-group-stock,
    .jn-fc-row-inline .jn-fc-group-categorias,
    .jn-fc-row-inline .jn-fc-group-marcas {
        flex: 1 1 calc(50% - 10px);
        min-width: 150px;
    }

    .jn-fc-row-inline .jn-fc-group-limpiar {
        order: 5;
    }
}

/* ========================================
   RESPONSIVE - MÓVIL
   ======================================== */
@media (max-width: 768px) {
    .jn-fc-container {
        padding: 12px 15px;
        margin: 10px 0;
    }

    .jn-fc-row {
        flex-direction: column;
        gap: 10px;
    }

    .jn-fc-row.jn-fc-row-inline {
        flex-direction: column;
        flex-wrap: wrap;
    }

    .jn-fc-row-inline .jn-fc-group-ordenar,
    .jn-fc-row-inline .jn-fc-group-stock,
    .jn-fc-row-inline .jn-fc-group-categorias,
    .jn-fc-row-inline .jn-fc-group-marcas,
    .jn-fc-row-inline .jn-fc-group-limpiar {
        flex: 1 1 100%;
        min-width: 100% !important;
        order: unset;
    }

    .jn-fc-group {
        width: 100%;
        min-width: 100% !important;
    }

    .jn-fc-group.jn-fc-group-small {
        min-width: 100%;
    }

    .jn-fc-clear-btn {
        width: 100%;
        justify-content: center;
    }

    .jn-fc-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .jn-fc-active-filters {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .jn-fc-chip {
        font-size: 10px;
        padding: 4px 8px;
    }

    /* Dropdown en móvil */
    .jn-fc-dropdown-menu {
        max-height: 350px;
    }

    .jn-fc-dropdown-list {
        max-height: 250px;
    }

    .jn-fc-category-item {
        padding: 12px;
    }

    .jn-fc-solo-btn {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================
   RESPONSIVE - MÓVIL PEQUEÑO
   ======================================== */
@media (max-width: 480px) {
    .jn-fc-container {
        padding: 10px 12px;
        border-radius: 8px;
    }

    .jn-fc-title {
        font-size: 13px;
    }

    .jn-fc-select {
        padding: 8px 30px 8px 10px;
        font-size: 12px;
    }

    .jn-fc-label {
        font-size: 10px;
    }

    .jn-fc-dropdown-btn {
        padding: 10px 35px 10px 10px;
        font-size: 12px;
    }

    .jn-fc-category-item {
        padding: 10px;
    }

    .jn-fc-category-name {
        font-size: 12px;
    }

    .jn-fc-category-count {
        font-size: 10px;
        padding: 2px 6px;
    }

    .jn-fc-action-btn {
        font-size: 10px;
        padding: 3px 8px;
    }

    .jn-fc-clear-btn {
        font-size: 12px;
        padding: 8px 15px;
    }

    .jn-fc-solo-btn {
        opacity: 1;
        transform: scale(1);
        padding: 3px 8px;
        font-size: 10px;
    }
}

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

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

/* Transición suave para categorías ocultas */
.jn-cat-item.jn-fc-hidden {
    display: none !important;
}

.jn-cat-content.jn-fc-hidden {
    display: none !important;
}

/* Highlight de categoría filtrada */
.jn-cat-item.jn-fc-highlighted {
    box-shadow: 0 0 0 2px #28a745, 0 4px 12px rgba(40, 167, 69, 0.3);
}
