/* ==========================================================================
   Husky Topbar Layout
   ========================================================================== */

/* Shop Desktop Tweaks */
h1.page-title {
    margin-top: 40px;
}

.woocommerce ul.products {
    padding-bottom: 80px;
}

.k-topbar-wrapper {
    margin-bottom: 30px;
    border-top: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
    padding: 15px 0;
    width: 100%;
    position: relative;
    z-index: 99;
}

/* Controls Row */
.k-topbar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.k-topbar-left {
    display: flex;
    align-items: center;
}

.k-topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-end;
}

/* WooCommerce Standard Ordering in Topbar */
.k-topbar-right .woocommerce-ordering {
    margin: 0;
}
.k-topbar-right .woocommerce-result-count {
    margin: 0;
    font-size: 14px;
    color: #666;
}

/* Toggle Button */
.btn-topbar-toggle {
    background: #fff;
    border: 1px solid #e9e9e9;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a2e;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    transition: all 0.2s;
}

.btn-topbar-toggle:hover {
    background: #f8f9fa;
    color: #000;
}

/* Filters Container */
.k-topbar-filters-container {
    padding-top: 20px;
    margin-top: 15px;
    border-top: 1px dashed #eaeaea;
}

/* Force WOOF to display horizontally */
.k-topbar-filters-container .woof_container,
.k-topbar-filters-container .k-custom-split-filter {
    display: inline-block;
    vertical-align: top;
    margin-right: 15px;
    margin-bottom: 15px;
    width: auto !important;
    min-width: 180px;
}

/* Hide Husky master title */
.k-topbar-filters-container .woof_container h4 {
    display: none !important;
}

/* Hide the original master Recomendaciones filter via JS class */
.k-hidden-original-filter {
    display: none !important;
}

/* Hide Husky master title (covers various title elements Husky might use) */
.k-topbar-filters-container .woof_container h3,
.k-topbar-filters-container .woof_container h4,
.k-topbar-filters-container .woof_container h5,
.k-topbar-filters-container .woof_container label.woof_wc_tax_label,
.k-topbar-filters-container .woof_wcga_label_hide {
    display: none !important;
}

/* Base Select styling to add custom SVG arrow */
.k-topbar-filters-container .woof_container select,
.k-topbar-filters-container .k-split-select {
    width: 100% !important;
    min-width: 180px;
    appearance: none !important; /* Hide native arrow */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' fill='none' stroke='%23333' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9'></path></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 18px !important;
    padding-right: 35px !important;
    height: 40px;
    border-radius: 4px;
    border: 1px solid #ddd;
    color: #333;
    background-color: #fff;
    cursor: pointer;
}

/* Ensure custom selects match width */
.k-topbar-filters-container .chosen-container {
    width: 100% !important;
    min-width: 180px;
    position: relative;
}

/* If Chosen JS is active, style its containers to match and add the arrow */
.k-topbar-filters-container .chosen-container-single .chosen-single {
    height: 40px;
    line-height: 40px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #fff;
    box-shadow: none;
    padding-right: 35px; /* Space for custom arrow */
}

/* Checkbox Items */
.k-check-item {
    display: flex !important;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    margin: 0 !important;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: background 0.2s;
}

.k-check-item:hover {
    background: #f7f7f7;
}

.k-check-item input[type="checkbox"] {
    margin: 0;
    margin-right: 10px !important;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Disabled/Empty State for Checkboxes - Ocultar completamente */
.k-check-item.is-disabled {
    display: none !important;
}

.k-check-item.is-disabled input[type="checkbox"] {
    cursor: not-allowed;
    opacity: 0.5;
}

.k-topbar-filters-container .chosen-container-multi .chosen-choices {
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #fff;
    padding: 5px;
    padding-right: 35px !important;
    min-height: 40px;
}

/* Add custom SVG arrow to Chosen containers via pseudo-element */
.k-topbar-filters-container .chosen-container::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' fill='none' stroke='%23333' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9'></path></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    transition: transform 0.3s ease;
}

/* Rotate arrow 180 degrees when dropdown is open */
.k-topbar-filters-container .chosen-container.chosen-with-drop::after,
.k-topbar-filters-container .chosen-container.chosen-container-active::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Hide native chosen arrow */
.k-topbar-filters-container .chosen-container-single .chosen-single div {
    display: none !important;
}

/* Hide WooCommerce native pagination / result count if it appears outside our topbar */
.shop-sorting-row .woocommerce-result-count,
.shop-sorting-row .woocommerce-ordering {
    display: none; /* In case they duplicate */
}

/* Active Filters Top Panel */
.woof_products_top_panel {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #eaeaea;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
}

.woof_products_top_panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    flex-grow: 1;
}

.woof_products_top_panel ul li {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 8px;
    font-size: 0 !important; /* This hides the raw text node labels completely */
}

/* Hide taxonomy labels like "Recomendaciones:", "Brands:" */
.woof_products_top_panel ul li > span,
.woof_products_top_panel ul li > strong {
    display: none !important;
}

/* Style the selected options as pills */
.woof_products_top_panel ul li > a {
    display: inline-flex;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #eaeaea;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px !important; /* Restore font size inside the a tag */
    color: #444 !important;
    text-decoration: none;
    margin: 0 !important;
    transition: all 0.2s;
}

.woof_products_top_panel ul li > a:hover {
    background: #eaeaea;
    color: #ec4899 !important;
    border-color: #ddd;
}

/* Add 'x' close icon to each pill */
.woof_products_top_panel ul li > a::after {
    content: "\00d7";
    display: inline-block;
    margin-left: 8px;
    font-size: 16px;
    font-weight: bold;
    color: #999;
    line-height: 1;
}

.woof_products_top_panel ul li > a:hover::after {
    color: #ec4899;
}

.woof_products_top_panel ul li.woof_clear_all_container {
    display: none !important; /* Hide native button if it appears inside the list */
}

/* Style the custom global clear filters button */
.woof_products_top_panel .k-global-clear-filters {
    white-space: nowrap;
    background: transparent;
    color: #ec4899;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 15px;
    border: 1px solid #ec4899;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.woof_products_top_panel .k-global-clear-filters:hover {
    background: #ec4899;
    color: #fff;
}

/* Custom Chosen Multiselect appearance when items are selected */
.k-topbar-filters-container .chosen-container-multi.k-has-selections .chosen-choices li.search-choice {
    display: none !important;
}

.k-topbar-filters-container .chosen-container-multi.k-has-selections .chosen-choices::before {
    content: attr(data-count-text);
    display: inline-block;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.k-topbar-filters-container .chosen-container-multi.k-has-selections .chosen-choices li.search-field {
    width: 0 !important;
    overflow: hidden;
    margin: 0 !important;
    padding: 0 !important;
}

/* ==================================================
   MOBILE BOTTOM DRAWER 
   ================================================== */
@media (max-width: 768px) {
    #k-topbar-filters {
        position: fixed !important;
        bottom: -100% !important; /* start hidden */
        left: 0;
        right: 0;
        top: auto !important;
        width: 100% !important;
        max-height: 85vh;
        background: #fff;
        z-index: 100001;
        padding: 20px 20px 40px 20px;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex !important; /* Override inline display:none so we can animate bottom */
        flex-direction: column;
    }
    
    #k-topbar-filters.active {
        bottom: 0 !important;
    }
    
    .k-topbar-mobile-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid #eee;
        width: 100%;
    }
    
    .k-topbar-mobile-header h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #333;
    }
    
    #k-topbar-close {
        background: #f5f5f5;
        border: none;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        color: #666;
        cursor: pointer;
    }
    
    /* Turn off floating for dropdown panels on mobile to create accordion effect */
    .k-topbar-filters-container .woof_container:not(.k-hidden-original-filter),
    .k-topbar-filters-container .k-custom-split-filter {
        display: block !important;
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 10px !important;
    }
    
    .k-check-dropdown-panel {
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        border-top: 1px solid #eee !important;
        margin-top: 0;
        border-radius: 0 !important;
    }
    
    .k-check-dropdown-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: transparent !important;
        border: none !important;
        border-bottom: 1px solid #eee !important;
        border-radius: 0 !important;
        padding: 15px 5px !important;
        font-weight: 500;
    }
    


    .k-topbar-wrapper {
        border-top: none;
        border-bottom: none;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: 15px;
    }

    /* Topbar Controls for Mobile */
    .k-topbar-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }
    
    .k-topbar-right {
        display: none !important; /* Hide result count and desktop ordering container */
    }
    
    .k-topbar-left {
        width: 100%;
    }
    
    .btn-topbar-toggle {
        width: 100%;
        justify-content: flex-start;
        border: none;
        padding: 10px 0;
        background: transparent;
        font-weight: 500;
        font-size: 14px;
        color: #333;
        border-radius: 0;
    }
    
    .btn-topbar-toggle svg {
        margin-right: 8px;
    }
    
    /* Active filters panel on mobile should display outside below the button */
    .woof_products_top_panel {
        margin-top: 0;
        padding-top: 15px;
        border-top: none;
    }
    
    .woof_products_top_panel ul {
        flex-wrap: wrap;
    }
    
    .woof_products_top_panel .k-global-clear-filters {
        margin-top: 5px;
    }
    
    /* Order by select styling at the bottom of the drawer */
    #k-topbar-filters .woocommerce-ordering {
        display: block !important;
        width: 100%;
        margin-top: auto; /* Push to bottom if there's space */
        padding-top: 20px;
        border-top: 1px solid #eee;
    }
    
    #k-topbar-filters .woocommerce-ordering select {
        width: 100%;
        padding: 12px;
        padding-right: 40px;
        border-radius: 8px;
        border: 1px solid #ddd;
        background-color: #f9f9f9;
        font-size: 14px;
        color: #333;
        appearance: none;
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' fill='none' stroke='%23333' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9'></path></svg>");
        background-repeat: no-repeat;
        background-position: right 15px center;
        background-size: 16px;
    }
    /* Final shop mobile tweaks */
    h1.page-title {
        text-align: center !important;
        font-size: 35px !important;
        margin-top: 20px !important;
    }

    .woof_autohide_wrapper {
        display: none !important;
    }

    .woocommerce ul.products {
        padding-bottom: 80px !important;
    }
}

/* Hide mobile header on desktop */
.k-topbar-mobile-header {
    display: none;
}
