/**
 * Product Categories Widget Styles
 * Diseño limpio y moderno
 */

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */
.pcw-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    box-sizing: border-box;
}

.pcw-widget *,
.pcw-widget *::before,
.pcw-widget *::after {
    box-sizing: inherit;
}

/* ========================================
   TÍTULO
   ======================================== */
.pcw-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 15px 0;
    padding: 0;
    line-height: 1.4;
}

/* ========================================
   CAMPO DE BÚSQUEDA
   ======================================== */
.pcw-search-wrapper {
    position: relative;
    margin-bottom: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pcw-search-wrapper:focus-within {
    border-color: #2e7d32;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.pcw-search-input {
    width: 100%;
    padding: 12px 40px 12px 14px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: #333;
    outline: none;
}

.pcw-search-input::placeholder {
    color: #999;
}

.pcw-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   LISTA DE CATEGORÍAS
   ======================================== */
.pcw-categories-list {
    margin-bottom: 10px;
}

.pcw-category-item {
    margin-bottom: 12px;
    transition: opacity 0.3s ease;
}

.pcw-category-item.pcw-hidden-category {
    display: none;
}

.pcw-category-item.pcw-search-hidden {
    display: none;
}

.pcw-category-label-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 8px;
    margin: -6px -8px;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.pcw-category-label-wrapper:hover {
    background-color: rgba(46, 125, 50, 0.08);
}

.pcw-category-label-wrapper:hover .pcw-category-label {
    color: #2e7d32;
}

.pcw-category-label {
    flex: 1;
    font-size: 14px;
    color: #333;
    transition: color 0.2s ease;
    line-height: 1.4;
}

.pcw-category-count {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 28px;
    text-align: center;
    font-weight: 500;
}

/* ========================================
   CHECKBOX PERSONALIZADO
   ======================================== */
.pcw-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.pcw-checkbox:hover {
    border-color: #2e7d32;
}

.pcw-checkbox:checked {
    background-color: #2e7d32;
    border-color: #2e7d32;
}

.pcw-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.pcw-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}

/* ========================================
   SUBCATEGORÍAS (HIJOS)
   ======================================== */
.pcw-category-children {
    padding-left: 20px;
    margin-top: 8px;
    border-left: 2px solid #f0f0f0;
    margin-left: 8px;
}

.pcw-child-category {
    margin-bottom: 8px;
}

.pcw-child-category .pcw-category-label {
    font-size: 13px;
    color: #555;
}

.pcw-child-category .pcw-category-count {
    font-size: 11px;
    padding: 1px 6px;
}

/* ========================================
   BOTÓN VER MÁS
   ======================================== */
.pcw-show-more {
    background: none;
    border: none;
    color: #2e7d32;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    margin-top: 5px;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pcw-show-more:hover {
    color: #1b5e20;
    text-decoration: underline;
}

.pcw-show-more:focus {
    outline: none;
    text-decoration: underline;
}

/* ========================================
   FILTRO DE PRECIOS
   ======================================== */
.pcw-price-filter {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.pcw-price-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 15px 0;
    color: #1a1a1a;
}

.pcw-price-ranges {
    margin-bottom: 15px;
}

.pcw-price-range-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.2s ease;
}

.pcw-price-range-item:hover .pcw-price-range-label {
    color: #2e7d32;
}

.pcw-price-range-label {
    font-size: 14px;
    color: #333;
    transition: color 0.2s ease;
}

/* ========================================
   PRECIO PERSONALIZADO
   ======================================== */
.pcw-custom-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.pcw-price-input {
    width: 80px;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pcw-price-input:focus {
    outline: none;
    border-color: #2e7d32;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.pcw-price-input::placeholder {
    color: #999;
}

/* Ocultar flechas del input number */
.pcw-price-input::-webkit-outer-spin-button,
.pcw-price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pcw-price-input[type=number] {
    -moz-appearance: textfield;
}

.pcw-price-separator {
    color: #999;
    font-size: 14px;
}

.pcw-apply-btn {
    padding: 10px 25px;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.pcw-apply-btn:hover {
    background: #1b5e20;
}

.pcw-apply-btn:active {
    transform: scale(0.98);
}

.pcw-apply-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.3);
}

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

.pcw-category-item.pcw-animate-in {
    animation: pcw-fadeIn 0.3s ease forwards;
}

/* ========================================
   ESTADO DE CARGA
   ======================================== */
.pcw-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.pcw-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2e7d32;
    border-radius: 50%;
    animation: pcw-spin 0.8s linear infinite;
}

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

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .pcw-title {
        font-size: 16px;
    }
    
    .pcw-search-input {
        padding: 10px 36px 10px 12px;
        font-size: 14px;
    }
    
    .pcw-category-label {
        font-size: 13px;
    }
    
    .pcw-custom-price {
        flex-direction: column;
        align-items: stretch;
    }
    
    .pcw-custom-price .pcw-price-input {
        width: 100%;
    }
    
    .pcw-custom-price .pcw-apply-btn {
        width: 100%;
        margin-top: 5px;
    }
    
    .pcw-price-separator {
        display: none;
    }
}

@media (max-width: 480px) {
    .pcw-checkbox {
        width: 20px;
        height: 20px;
    }
    
    .pcw-checkbox:checked::after {
        left: 6px;
        top: 3px;
        width: 5px;
        height: 10px;
    }
}

/* ========================================
   MODO OSCURO (opcional)
   ======================================== */
@media (prefers-color-scheme: dark) {
    .pcw-widget.pcw-dark-mode {
        background-color: #1a1a1a;
    }
    
    .pcw-dark-mode .pcw-title {
        color: #f0f0f0;
    }
    
    .pcw-dark-mode .pcw-search-wrapper {
        background: #2a2a2a;
        border-color: #3a3a3a;
    }
    
    .pcw-dark-mode .pcw-search-input {
        color: #f0f0f0;
    }
    
    .pcw-dark-mode .pcw-category-label {
        color: #e0e0e0;
    }
    
    .pcw-dark-mode .pcw-category-count {
        background: #3a3a3a;
        color: #aaa;
    }
    
    .pcw-dark-mode .pcw-checkbox {
        background: #2a2a2a;
        border-color: #4a4a4a;
    }
}

/* ========================================
   ACCESIBILIDAD
   ======================================== */
.pcw-checkbox:focus-visible,
.pcw-search-input:focus-visible,
.pcw-price-input:focus-visible,
.pcw-apply-btn:focus-visible,
.pcw-show-more:focus-visible {
    outline: 2px solid #2e7d32;
    outline-offset: 2px;
}

/* Reducir movimiento para usuarios que lo prefieran */
@media (prefers-reduced-motion: reduce) {
    .pcw-widget * {
        animation: none !important;
        transition: none !important;
    }
}
