/* ==========================================================================
   BOOKSTORE FILTERING SYSTEM (big-filter.php)
   ========================================================================== */

/* 0. Toolbar Wrapper to prevent layout jumps */
.custom-shop-toolbar-wrapper {
    min-height: 65px; /* Reserves space so content doesn't "blip" when toolbar floats */
    margin-bottom: 20px;
}

/* 1. Shop Toolbar (Non-sticky) */
.custom-shop-toolbar {
    position: relative;
    z-index: 999;
    background: #FAF6EF;
    padding: 8px 10px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center; /* Aligns items vertically in the toolbar */
    gap: 12px;
    margin-left: -10px;
    margin-right: -15px;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.3s ease;
}

/* 1.1 Revealing Toolbar (Scroll-up behavior) */
.custom-shop-toolbar.is-revealed {
    position: fixed;
    top: 73px; /* Moved up 2px to allow content bleed-through similar to the header */
    left: 0;
    right: 0;
    z-index: 1090; /* Just below the main header (1100) */
    padding: 8px 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    background: #FAF6EF;
    animation: toolbarReveal 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

@keyframes toolbarReveal {
    from {
        transform: translateY(-100%);
        opacity: 0.8; /* Start mostly opaque for a more solid entrance */
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.custom-shop-toolbar button#mobile-filter-toggle {
    height: 48px;
    padding: 0 20px;
    font-weight: bold;
    border: solid 1.5px #000060;
    border-radius: .5rem;
    background: #000060;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

/* Sorting dropdown in toolbar */
.custom-shop-toolbar .woocommerce-ordering {
    margin-left: auto; /* Pushes sorter to the right */
}

.sorting-group select#custom-orderby {
    height: 48px;
    padding: 0 20px;
    font-weight: bold;
    border: solid 1.5px #000060;
    border-radius: 5px;
    background-color: #E9ECF2;
    color: #000060;
    font-size: 1rem;
}

/* 2. Filter Groups & Checkboxes */
.filters, .tag-box {
    padding: .5rem;
    border: 2px solid #000060;
    border-radius: .3rem;
    margin-bottom: .5rem;
    display: inline-block;
    box-sizing: border-box;
    flex: 1;
}

.filter-group {
    display: flex;
    flex-wrap: nowrap;
    gap: .25rem;
    margin-bottom: 1rem;
}

.filter-group label {
    display: flex;
    align-items: center;
    padding: .3rem .75rem;
    background-color: #E9ECF2;
    border: 1.5px solid #000060;
    border-radius: 1.3rem;
    cursor: pointer;
    font-size: .9rem;
    transition: all 0.2s ease;
    user-select: none;
}

.filter-group label.disabled {
    opacity: 0.4;
    pointer-events: none;
}

input[type="checkbox"]:checked {
    accent-color: #fa0042;
}

.count {
    font-size: 1em;
    font-weight: bold;
    margin-left: 4px;
}

/* 3. Tag & Category Pills */
.tag-button, .category-button {
    background-color: #E9ECF2;
    border: 1.5px solid #000060;
    color: #000060;
    padding: .5rem 1rem;
    margin-bottom: .5rem;
    border-radius: .75rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tag-button:hover, .category-button:hover {
    background-color: #046223;
    color: #fff;
}

.tag-button.selected, .category-button.selected {
    background-color: #fa0042;
    color: #fff;
}

.tag-button.disabled, .category-button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* 4. Birthday Selectors */
.birthday-select {
    background: #fff;
    font-weight: bold;
    border: solid 2px #000060;
    padding: 1rem;
    border-radius: .5rem;
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    max-width: 100%;
    box-sizing: border-box;
    flex-wrap: nowrap;
}

.birthday-select select {
    width: 100%;
    border: 1.5px solid #000060;
    font-size: 1.15rem;
    color: #000060;
    background-color: #E9ECF2;
}

/* 5. Mobile Slide-in Panel */
#mobile-filter-panel {
    position: fixed;
    top: 0;
    left: 0;
    background: white;
    width: 65%;
    height: 100%;
    z-index: 1200;
    padding: 20px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    visibility: hidden;
    opacity: 0;
}

#mobile-filter-panel.active {
    transform: translateX(0);
    visibility: visible;
    opacity: 1;
}

#mobile-filter-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1199;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

#mobile-filter-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* 6. Selected Filter Chips (displayed above filters) */
.selected-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: .5rem;
    margin-bottom: 1rem;
    margin-top: .5rem;
}

/* Individual filter chip styling */
.filter-chip {
    background: #E9ECF2;
    border: 2px solid #000060;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none; /* Prevents text selection on click */
    transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}

/* Visual feedback on click/tap */
.filter-chip:active {
  transform: scale(0.97);
}

/* Hover effect for chips */
.filter-chip:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Animation for when a chip is tapped/removed */
.filter-chip.is-tapped {
    animation: chipFlash 180ms ease;
}

@keyframes chipFlash {
    0% { transform: scale(1); background: rgba(0,0,0,0.06); }
    50% { transform: scale(0.97); background: rgba(0,0,0,0.12); }
    100% { transform: scale(1); background: rgba(0,0,0,0.06); }
}

/* Remove button within a chip */
.filter-chip .remove-chip {
    margin-left: 8px;
    font-size: 24px;
    color: #555;
    line-height: 1;
    pointer-events: none; /* Allows click to pass through to parent chip */
    user-select: none;
}

/* Badge image within a chip */
.filter-chip .ws-attr-badge {
  margin-right: 6px;
  vertical-align: middle;
}

/* Label text within a chip */
.filter-chip .chip-label {
  vertical-align: middle;
}
/* 6. Selected Filter Chips (displayed above filters) */
.selected-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: .5rem;
    margin-bottom: 1rem;
    margin-top: .5rem;
}

/* Individual filter chip styling */
.filter-chip {
    background: #E9ECF2;
    border: 2px solid #000060;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none; /* Prevents text selection on click */
    transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}

/* Visual feedback on click/tap */
.filter-chip:active {
  transform: scale(0.97);
}

/* Hover effect for chips */
.filter-chip:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Animation for when a chip is tapped/removed */
.filter-chip.is-tapped {
    animation: chipFlash 180ms ease;
}

@keyframes chipFlash {
    0% { transform: scale(1); background: rgba(0,0,0,0.06); }
    50% { transform: scale(0.97); background: rgba(0,0,0,0.12); }
    100% { transform: scale(1); background: rgba(0,0,0,0.06); }
}

/* Remove button within a chip */
.filter-chip .remove-chip {
    margin-left: 8px;
    font-size: 24px;
    color: #555;
    line-height: 1;
    pointer-events: none; /* Allows click to pass through to parent chip */
    user-select: none;
}

/* Badge image within a chip */
.filter-chip .ws-attr-badge {
  margin-right: 6px;
  vertical-align: middle;
}

/* Label text within a chip */
.filter-chip .chip-label {
  vertical-align: middle;
}

/* 7. Search Bar & No Results Display (integrated with filters) */
.custom-product-search-form {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Magnifying glass icon */
.custom-product-search-form::before {
    content: "";
    width: 22px;
    height: 22px;
    display: inline-block;
    background: url("https://jemstonepublishing.com/wp-content/uploads/2026/02/magnifying-glass.svg") no-repeat center;
    background-size: contain;
    cursor: pointer;
}

/* Hide default search submit button */
.custom-product-search-form .search-submit {
    display: none;
}

/* Search input field (hidden by default, slides in) */
.custom-product-search-form .search-field {
    position: fixed;
    top: 80px; /* Adjust based on your header height */
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    opacity: 0;
    padding: 0;
    border: none;
    background: #fff;
    z-index: 100;
    transition: all 0.25s ease;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

/* Expanded search field state */
.custom-product-search-form.is-open .search-field {
    width: 90vw !important; /* Full width on mobile */
    opacity: 1 !important;
    padding: 0.5rem 0.7rem !important;
    border: 1px solid #ccc !important;
}

/* No Search Results Layout */
.random-products-grid {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 1.25rem;
}
/* Desktop: 4 per row */
@media (min-width: 922px) {
    .random-product-item {
        flex: 0 1 calc(22% - 1.25rem);
    }
}
/* Mobile: 2 per row */
@media (max-width: 767px) {
    .random-product-item {
        flex: 0 1 calc(48% - 1.25rem);
    }
}
/* Hide default WooCommerce header on search results */
body.search .woocommerce-products-header {
    visibility: hidden;
    height: 0; /* Hide completely */
    margin: 0; /* Remove any default margin */
}
/* Custom titles for no search results */
.search-title {
    text-align: center;
    font-size: 3.14rem;
}

h2.search-subtitle {
    text-align: center;
    margin-top: 2rem;
    font-size: 2.5rem;
}

/*BADGES SWAP ATTRIBUT START*/
/* Title row: name left, badges right */
.ws-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* Badge layout */
.ws-attr-badges {
  display: inline-flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
}

/* Align badges on the same line as the price */
.price {
  display: inline-block !important;
  vertical-align: middle;
}

.ws-badge-wrap {
  display: inline-block !important;
  vertical-align: middle;
  margin-left: 8px;
}

.woocommerce ul.products li.product .ws-price-with-badges {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
}
/* Badge size */
/* Badge size = title height */
.ws-attr-badge {
  width: auto !important;
  height: 1.25em !important;
  max-height: 1.25em !important;
  object-fit: contain;
  display: block;
}

/* Link wrapper for badges */
.ws-badge-link {
  display: inline-flex;
  align-items: center;
}

/*BADGES SWAP ATTRIBUT END*/

.ws-attr-badge-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 8px;
}

.ws-attr-badge {
  height: 1.25em;
  width: auto;
  object-fit: contain;
}



/* 9. User Tier Badge (in header/toolbar) */

/* Mobile specific adjustments */
@media (max-width: 921px) {
    /* Adjust search field width on mobile */
    .search-field {
        width: 66vw;
        margin-left: -20px;
    }
    /* Hide search submit button on mobile */
    .search-submit {
        display: none;
    }
    /* Mobile wide panel for filter */
    #mobile-filter-panel {
        width: 60vw;
    }
    /* Mobile specific chip animation */
    .filter-chip:active {
        background: rgba(0,0,0,0.6);
    }
    @keyframes chipFlash {
        0% { transform: scale(1); background: rgba(0,0,0,0.06); }
        50% { transform: scale(0.97); background: rgba(0,0,0,0.12); }
        100% { transform: scale(1); background: rgba(0,0,0,0.06); }
    }
    /* Birthday select vertical stack */
    .birthday-select {
        flex-direction: column;
    }
    .birthday-select select {
        width: 100%;
        border: 1.5px solid #000060;
        font-size: 1.15rem;
        color: #000060;
        background-color: #E9ECF2;
    }
}
