/**
 * PinkAngel Product Filters - Compact Horizontal Design
 */

/* Main Wrapper */
.papf-filters-wrapper {
    margin-bottom: 20px;
}

/* Mobile Filter Button (FAB) */
.papf-mobile-filter-btn {
    display: none; /* Hidden on desktop */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000; /* Higher than sticky cart (9999) to ensure visibility */
    background: linear-gradient(135deg, #e91e63 0%, #d81b60 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 6px 24px rgba(233, 30, 99, 0.4);
    cursor: pointer;
    transition: all 0.3s;
    align-items: center;
    gap: 8px;
}

.papf-mobile-filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(233, 30, 99, 0.5);
}

.papf-mobile-badge {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
}

/* Horizontal Filter Bar */
.papf-filters-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-radius: 12px;
    flex-wrap: wrap;
}

/* Drawer Header (hidden on desktop, shown on mobile) */
.papf-drawer-header {
    display: none;
}

.papf-drawer-body {
    display: contents;
}

html.papf-drawer-open,
body.papf-drawer-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.papf-filter-groups {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

.papf-active-pills-slot--drawer,
.papf-mobile-panel-header,
.papf-panel-search {
    display: none;
}

.papf-active-pills-slot--desktop {
    margin-top: 12px;
}

.papf-filter-summary {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    color: #8d5a74;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

/* Filter Dropdown */
.papf-filter-dropdown {
    position: relative;
}

.papf-filter-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 14px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.papf-trigger-end {
    display: flex;
    align-items: center;
    gap: 6px;
}

.papf-filter-trigger:hover {
    background: #f5f5f5;
    border-color: #e91e63;
}

.papf-filter-trigger i:first-child {
    color: #e91e63;
    font-size: 14px;
}

.papf-chevron {
    font-size: 10px !important;
    color: #999 !important;
    transition: transform 0.2s;
}

.papf-filter-dropdown.open .papf-chevron {
    transform: rotate(180deg);
}

.papf-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(135deg, #e91e63 0%, #d81b60 100%);
    color: #fff;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
}

/* Filter Panel (Dropdown Content) */
.papf-filter-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border: 1px solid #e8e8e8;
    padding: 12px;
    z-index: 2700;
    display: none;
    animation: slideDown 0.2s ease-out;
}

.papf-filter-panel-content {
    display: flex;
    flex-direction: column;
}

.papf-filter-dropdown.open .papf-filter-panel {
    display: block;
}

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

/* Price Inputs */
.papf-price-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.papf-price-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    width: 80px;
}

.papf-price-input:focus {
    outline: none;
    border-color: #e91e63;
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.1);
}

.papf-price-sep {
    color: #ccc;
    font-weight: 700;
}

.papf-price-range {
    text-align: center;
    color: #999;
    font-size: 11px;
}

/* Radio Options */
.papf-radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.papf-radio-option:last-child {
    margin-bottom: 0;
}

.papf-radio-option:hover {
    background: #f8f8f8;
}

.papf-radio-option.active {
    background: linear-gradient(135deg, #fff5f8 0%, #ffe8f0 100%);
    color: #e91e63;
    font-weight: 600;
}

.papf-radio-option input {
    display: none;
}

.papf-radio-option span {
    font-size: 13px;
}

/* Checkbox Options */
.papf-checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.papf-checkbox-option:last-child {
    margin-bottom: 0;
}

.papf-checkbox-option:hover {
    background: #f8f8f8;
}

.papf-checkbox-option.active {
    background: linear-gradient(135deg, #fff5f8 0%, #ffe8f0 100%);
}

.papf-checkbox-option input {
    display: none;
}

.papf-check {
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.papf-checkbox-option:hover .papf-check {
    border-color: #e91e63;
}

.papf-checkbox-option.active .papf-check {
    background: linear-gradient(135deg, #e91e63 0%, #d81b60 100%);
    border-color: #e91e63;
}

.papf-checkbox-option.active .papf-check::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #fff;
    font-size: 9px;
}

.papf-label {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}

.papf-count {
    font-size: 10px;
    color: #999;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
}

.papf-checkbox-option.active .papf-count {
    background: #e91e63;
    color: #fff;
}

/* Sale Toggle Wrapper */
.papf-filter-toggle-wrapper {
    display: inline-block;
}

/* Sale Toggle */
.papf-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 7px 14px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.2;
    box-sizing: border-box;
}

.papf-filter-toggle:hover {
    background: #f5f5f5;
    border-color: #e91e63;
}

.papf-filter-toggle.active {
    background: linear-gradient(135deg, #e91e63 0%, #d81b60 100%);
    border-color: #e91e63;
    color: #fff;
}

/* Remove filters text button (hidden on desktop) */
.papf-remove-filters-text {
    display: none;
}

.papf-filter-toggle input {
    display: none;
}

.papf-filter-toggle i {
    font-size: 14px;
}

/* Action Buttons */
.papf-filter-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.papf-apply-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #e91e63 0%, #d81b60 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(233, 30, 99, 0.3);
}

.papf-apply-filters-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.papf-apply-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Hide invisible balancing element on desktop */
.papf-apply-filters i[style*="opacity: 0"] {
    display: none;
}

.papf-apply-filters:hover {
    background: linear-gradient(135deg, #d81b60 0%, #c2185b 100%);
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.4);
    transform: translateY(-1px);
}

.papf-clear-filters {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f5f5f5;
    color: #666;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.papf-clear-filters:hover {
    background: #e8e8e8;
    color: #e91e63;
}

/* Active Filter Pills */
.papf-active-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding: 0 4px;
}

.papf-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #fff5f8 0%, #ffe8f0 100%);
    border: 1px solid #e91e63;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #e91e63;
    animation: pillSlideIn 0.2s ease-out;
}

@keyframes pillSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.papf-pill i {
    font-size: 11px;
}

.papf-pill-remove {
    background: none;
    border: none;
    color: #e91e63;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.papf-pill-remove:hover {
    background: rgba(233, 30, 99, 0.2);
}

.papf-pill-remove i {
    font-size: 10px;
}

.papf-clear-all-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.papf-clear-all-pills:hover {
    background: #e8e8e8;
    color: #333;
}

/* Loading State */
.papf-filters-wrapper.loading {
    position: relative;
}

.papf-filters-wrapper.loading .papf-filters-bar {
    pointer-events: none;
    opacity: 0.6;
}

.papf-filters-wrapper.loading::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: #fff;
    border: 4px solid #f0f0f0;
    border-top-color: #e91e63;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .papf-mobile-filter-btn {
        display: flex;
        /* Default position when sticky cart is hidden */
        bottom: 20px;
        /* Smooth transition when position changes */
        transition: bottom 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    }

    /* Adjust position when sticky cart is visible */
    body.pa-sticky-cart-visible .papf-mobile-filter-btn {
        /* Position above sticky cart - sticky cart height is ~72px (48px button + 24px padding) */
        bottom: 80px;
    }

    /* Hide filter button when drawer is open */
    body.papf-drawer-open .papf-mobile-filter-btn {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.8);
    }

    .papf-filters-bar {
        position: fixed;
        top: 0;
        left: -100%;
        width: min(88vw, 380px);
        max-width: 380px;
        height: 100vh;
        height: 100dvh;
        padding: 0;
        border-radius: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.2);
        z-index: 5500;
        transition: left 0.3s;
        overflow: hidden;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        align-items: stretch;
        align-content: stretch;
        gap: 0;
    }

    .papf-filters-bar.open {
        left: 0;
    }

    /* Drawer Header */
    .papf-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background: linear-gradient(135deg, #e91e63 0%, #d81b60 100%);
        color: #fff;
        position: sticky;
        top: 0;
        z-index: 10;
        border-bottom: 1px solid rgba(255,255,255,0.2);
    }

    .papf-drawer-header h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #fff;
    }

    .papf-drawer-close {
        background: transparent;
        border: none;
        color: #fff;
        font-size: 24px;
        cursor: pointer;
        padding: 0;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background 0.2s;
    }

    .papf-drawer-close:hover {
        background: rgba(255,255,255,0.2);
    }

    .papf-drawer-body {
        display: block;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        position: relative;
        padding: 0 20px 24px;
        -webkit-overflow-scrolling: touch;
        background: #fff;
    }

    .papf-filter-groups {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px 0 24px;
    }

    .papf-filter-dropdown,
    .papf-filter-toggle-wrapper,
    .papf-filter-actions {
        width: 100%;
        box-sizing: border-box;
    }

    .papf-filter-dropdown {
        position: static;
    }

    .papf-filter-trigger {
        width: 100%;
        justify-content: space-between;
        height: 52px;
        padding: 10px 16px;
        box-sizing: border-box;
        border-radius: 14px;
        background: #fff7fa;
        border-color: #f4d6e4;
    }

    .papf-filter-toggle {
        width: 100%;
        height: 52px;
        padding: 10px 16px;
        box-sizing: border-box;
        border-radius: 14px;
    }

    .papf-filter-panel {
        position: absolute;
        inset: 0;
        z-index: 20;
        display: none;
        box-shadow: none;
        border: none;
        padding: 0 20px;
        margin: 0;
        min-width: 0;
        border-radius: 0;
        animation: none;
        background: #fff;
        box-sizing: border-box;
    }

    .papf-filter-dropdown.open .papf-filter-panel {
        display: flex;
        flex-direction: column;
    }

    .papf-mobile-panel-header {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 10px;
        padding: 10px 0 10px;
        background: #fff;
        position: sticky;
        top: 0;
        z-index: 2;
        border-bottom: 1px solid #f0f0f0;
    }

    .papf-panel-back {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: none;
        border: none;
        color: #666;
        padding: 0;
        font-size: 13px;
        font-weight: 600;
    }

    .papf-mobile-panel-title {
        font-size: 16px;
        font-weight: 700;
        color: #222;
        text-align: center;
    }

    .papf-mobile-panel-meta {
        min-width: 72px;
        text-align: right;
        color: #a55f86;
        font-size: 12px;
        font-weight: 600;
    }

    .papf-panel-search {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 14px 0 12px;
        border-bottom: 1px solid #f0f0f0;
        background: #fff;
        position: sticky;
        top: 53px;
        z-index: 2;
    }

    .papf-panel-search i {
        color: #999;
    }

    .papf-panel-search-input {
        width: 100%;
        border: none;
        background: #f6f6f6;
        border-radius: 999px;
        padding: 12px 16px;
        font-size: 14px;
        font-weight: 500;
    }

    .papf-panel-search-input:focus {
        outline: none;
        box-shadow: 0 0 0 2px rgba(233, 30, 99, 0.15);
        background: #fff;
    }

    .papf-filter-panel-content {
        overflow-y: auto;
        overflow-x: hidden;
        padding: 16px 0 32px;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }

    .papf-filter-panel--searchable .papf-filter-panel-content {
        padding-top: 12px;
    }

    .papf-filter-actions {
        margin-left: 0;
        margin-top: 0;
        padding: 16px 20px !important;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        border-top: 1px solid #f0f0f0;
        background: #fff;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .papf-remove-filters-text {
        display: block;
        background: none;
        border: none;
        color: #666;
        font-size: 13px;
        font-weight: 500;
        text-align: center;
        cursor: pointer;
        padding: 0;
        text-decoration: underline;
        transition: color 0.2s;
    }

    .papf-remove-filters-text:hover {
        color: #e91e63;
    }

    .papf-apply-filters {
        flex: 0 0 auto;
        border-radius: 999px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 18px;
        box-shadow: 0 6px 18px rgba(233, 30, 99, 0.2);
    }

    .papf-apply-filters-copy {
        display: inline-flex;
        align-items: center;
    }

    .papf-apply-label {
        font-size: 14px;
        font-weight: 700;
        line-height: 1;
        opacity: 1;
    }

    .papf-active-pills-slot--drawer {
        display: block;
        padding-top: 16px;
    }

    .papf-active-pills-slot--desktop {
        display: none;
    }

    .papf-active-pills {
        padding: 0;
        margin-bottom: 12px;
    }

    .papf-count {
        min-width: 25px;
        text-align: center;
        padding: 0px 2px;
    }

    .papf-filter-summary {
        max-width: 96px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Toolbar wrapper - 50/50 split on mobile */
    .woocommerce-toolbar-wrapper {
        gap: 8px;
    }

    .woocommerce-toolbar-wrapper > * {
        flex: 1;
        min-width: 0;
    }

    .woocommerce-result-count {
        font-size: 12px;
    }

    .woocommerce-ordering select.orderby {
        width: 100%;
        font-size: 12px;
    }
}

/* Backdrop for mobile */
.papf-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5450;
}

.papf-backdrop.show {
    display: block;
}

/* WooCommerce Toolbar Wrapper */
.woocommerce-toolbar-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

/* WooCommerce Result Count */
.woocommerce-result-count {
    line-height: 16px;
}

/* Touch devices can consume the first tap on paginated links when hover styles
   are present globally. Keep pagination links visually stable and explicitly
   tappable on touch-only devices. */
@media (hover: none) and (pointer: coarse) {
    .woocommerce-pagination a.page-numbers,
    .woocommerce-pagination .next.page-numbers,
    .woocommerce-pagination .prev.page-numbers {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.12);
        touch-action: manipulation;
    }

    .woocommerce-pagination a.page-numbers:hover,
    .woocommerce-pagination .next.page-numbers:hover,
    .woocommerce-pagination .prev.page-numbers:hover {
        color: inherit;
        text-decoration: none;
        background: inherit;
    }
}
