/**
 * Mobile filters styles
 */

/* Mobile filter button */
.issf-mobile-filter-button {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #0073aa;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.issf-mobile-filter-button svg {
    width: 24px;
    height: 24px;
    stroke: #fff;
    margin-bottom: 3px;
}

.issf-mobile-filter-button span {
    font-size: 12px;
    font-weight: 500;
}

/* Mobile filter sidebar */
.issf-mobile-filter-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: flex;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.issf-mobile-filter-sidebar.issf-mobile-sidebar-active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Mobile filter overlay */
.issf-mobile-filter-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Mobile sidebar content */
.issf-mobile-sidebar-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80%;
    max-width: 350px;
    background-color: #fff;
    z-index: 2;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.issf-mobile-sidebar-active .issf-mobile-sidebar-content {
    transform: translateX(0);
}

/* Mobile sidebar header */
.issf-mobile-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.issf-mobile-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.issf-mobile-filter-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.issf-mobile-filter-close svg {
    width: 20px;
    height: 20px;
    stroke: #333;
}

/* Mobile sidebar body */
.issf-mobile-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Search clear button styling - works for all screen sizes */
.issf-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    cursor: pointer;
    display: none; /* Hidden by default */
    padding: 0;
    color: #999;
    font-size: 20px;
    line-height: 1;
    z-index: 3;
    border-radius: 50%;
    text-align: center;
}

/* Touch-friendly tap area */
.issf-search-clear:before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
}

/* Hover state for clear button */
.issf-search-clear:hover {
    color: #333;
    background-color: rgba(0,0,0,0.05);
}

/* Show clear button when search has text */
.issf-search-wrapper.has-text .issf-search-clear {
    display: block;
}

/* Position the search wrapper as relative for proper clear button positioning */
.issf-search-wrapper {
    position: relative;
    padding: 5px;
}

.issf-mobile-filter-sidebar [data-filter-type="search"] {
    display: none !important; /* Hide search in mobile sidebar */
}

/* Hide desktop filters on mobile */
@media screen and (max-width: 991px) {

    .issf-header-top-row {
        display: flex;
        flex-direction: column !important;
    }
    
    /* Position search wrapper outside the sidebar and above sorting */
    .issf-search-wrapper {
        display: block !important;
        width: 100%;
        margin-bottom: 15px;
        padding: 0;
    }
    
    /* Ensure search doesn't get hidden by generic mobile classes */
    .issf-search-wrapper.issf-hidden-on-mobile {
        display: block !important;
    }
    
    /* Move search above sorting wrapper */
    .issf-header-top-row .issf-search-wrapper {
        order: -1;
    }
    
    /* Make search prominent in mobile view */
    .issf-products-header .issf-search-wrapper {
        margin-bottom: 15px;
        width: 100%;
    }
    
    /* Ensure search input is full width and properly styled */
    .issf-search-input {
        width: 100%;
        padding: 10px 35px 10px 10px;
        height: 42px;
        border-radius: 4px;
        font-size: 16px; /* Better for mobile */
        -webkit-appearance: none; /* Fix for iOS rendering */
    }

    /* Position search outside and above filters */
    .issf-products-header {
        position: relative;
        z-index: 2; /* Ensure visibility */
    }

    /* Make search more prominent on mobile */
    .issf-search-wrapper {
        margin-bottom: 20px !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        border-radius: 4px;
        overflow: hidden;
    }
    
    .issf-mobile-filter-button {
        display: flex;
    }
    
    body.issf-mobile-filters-open {
        overflow: hidden;
    }
    
    /* Hide original filters on mobile when they've been moved to the sidebar */
    .issf-hidden-on-mobile,
    .issf-desktop-active-filters {
        display: none !important;
    }
    
    /* Hide any active filter containers on the main page */
    .issf-active-filters:not(.issf-mobile-active-filters),
    .issf-filter-tags-container:not(.issf-mobile-active-filters) {
        display: none !important;
    }
    
    /* Each filter section */
    .issf-filter-section {
        margin-bottom: 10px;
        border: 1px solid #eee;
        border-radius: 4px;
        overflow: hidden;
    }
    
    /* Filter header (clickable to toggle) */
    .issf-filter-header {
        padding: 12px 15px;
        font-weight: 600;
        background-color: #f9f9f9;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #eee;
    }
    
    /* Filter content */
    .issf-filter-content {
        padding: 15px;
        display: none; /* Hidden by default on mobile */
    }
    
    /* Toggle icon */
    .issf-toggle-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.3s ease;
    }
    
    /* Rotate icon when expanded */
    .issf-expanded .issf-toggle-icon {
        transform: rotate(180deg);
    }
    
    /* Collapsed state - already hidden by default */
    .issf-collapsed .issf-filter-content {
        display: none;
    }
    
    /* Expanded state */
    .issf-expanded .issf-filter-content {
        display: block;
    }
}
