:root {
  --primary-color: #378362;
}

/* Base Styles */
.apg-container,
.apg-grid-container,
.apg-filter-wrapper,
.apg-sorting-wrapper,
.apg-column-controls,
.apg-results-info {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Grid Layout */
.apg-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 30px;
}

.apg-columns-1 { grid-template-columns: 1fr; }
.apg-columns-2 { grid-template-columns: repeat(2, 1fr); }
.apg-columns-3 { grid-template-columns: repeat(3, 1fr); }
.apg-columns-4 { grid-template-columns: repeat(4, 1fr); }
.apg-columns-5 { grid-template-columns: repeat(5, 1fr); }
.apg-columns-6 { grid-template-columns: repeat(6, 1fr); }

/* Product Card */
.product-carousel-item {
    background: none;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.product-image-container {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1281 / 1920;
}

.product-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: opacity 0.3s ease;
}

.product-image-container .hover-image {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

.product-carousel-item:hover .hover-image { opacity: 1; }
.product-carousel-item:hover .main-image  { opacity: 0; }

/* Third-party plugin content that hooks via woocommerce_before_shop_loop_item
   (e.g. wishlist hearts, sale badges, discount labels) */
.product-carousel-item .woocommerce-loop-product__link,
.product-carousel-item .button,
.product-carousel-item .yith-wcwl-add-to-wishlist,
.product-carousel-item .tinvwl_add_to_wishlist_button,
.product-carousel-item .wooscp-btn,
.product-carousel-item .woocommerce-LoopProduct-link {
    position: relative;
    z-index: 5;
}

/* Sale badge from WooCommerce itself */
.product-carousel-item .onsale {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 6;
    background: #bd3229;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 3px;
}

.product-info {
    padding: 12px 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.product-price {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.product-title {
    font-size: 16px;
    font-weight: 400;
    margin: 0;
}

.product-title a {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

@media screen and (max-width: 767px) {
  .product-title a {
    font-size: 0.813rem !important;
  }
}
.product-title a:hover { color: #bd3229; }

.add-to-cart-container {
    position: absolute;
    top: 85%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
}

.product-carousel-item:hover .add-to-cart-container {
    opacity: 1;
    transform: translateX(-50%) translateY(-20px);
}

.add-to-cart-btn svg {
    width: 25px;
    height: auto;
}

.add-to-cart-btn svg path { stroke: white; }

.add-to-cart-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.add-to-cart-btn:hover         { background-color: #000; }
.add-to-cart-btn.loading       { filter: grayscale(1); opacity: 0.7; pointer-events: none; }
.add-to-cart-btn.added         { background-color: #28a745; }

/* Variable product — Select Options link styled same as add-to-cart button */
a.add-to-cart-btn.apg-select-options {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    color: white;
}

a.add-to-cart-btn.apg-select-options:hover { background-color: #000; color: white; }
a.add-to-cart-btn.apg-select-options svg          { width: 25px; height: auto; }
a.add-to-cart-btn.apg-select-options svg path     { stroke: white; }

/* ── Inline SVG icon base styles ─────────────────────────────────────────── */
.apg-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Filter & close icons inherit color from their parent button */
.apg-icon-filter,
.apg-icon-close {
    width: 20px;
    height: 20px;
}



/* Filter Button */
.apg-filter-wrapper { display: inline-block; }

.apg-filter-btn {
    background: var(--primary-color);
    padding: 8px 25px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #fff;
    text-transform: uppercase;
    border: none;
}

.apg-filter-btn:hover         { background: #000; color: #fff; }
.apg-filter-btn svg           { stroke: white; }
.apg-filter-header h3 svg     { stroke: var(--primary-color); }
.apg-filter-close svg         { stroke: currentColor; }

/* Sorting Dropdown */
.apg-sorting-wrapper {
    position: relative;
    display: flex;
    justify-content: flex-end;
    margin-left: auto;
    width: 100%;
}

.apg-sorting-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff !important;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px 36px 12px 16px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23333' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    min-width: 200px;
    transition: all 0.3s ease;
}

.apg-sorting-select:hover,
.apg-sorting-select:focus { border-color: var(--primary-color); outline: none; }

/* Accordion */
.apg-filter-group {
    margin-bottom: 0;
    border-bottom: 1px solid #eee;
}

.apg-filter-group:last-child { border-bottom: none; }

.accordion-header {
    padding: 20px 0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.accordion-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: left;
}

.accordion-icon {
    width: 12px;
    height: 12px;
    border-right: 2px solid var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    margin-right: 5px;
    margin-left: auto;
}

.accordion-item.active .accordion-icon { transform: rotate(-135deg); }

.accordion-content { padding: 20px; display: none; }
.accordion-item.active .accordion-content { display: block; padding: 20px; }

/* Column Controls */
.apg-column-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.apg-column-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    width: auto;
    height: auto;
}

/* Images display at natural size — no forced dimensions */
.apg-column-btn img {
    display: block;
    transition: opacity 0.3s ease;
}

.apg-column-btn .column-icon-hover {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.apg-column-btn:hover .column-icon-normal,
.apg-column-btn.active .column-icon-normal {
    opacity: 0;
}

.apg-column-btn:hover .column-icon-hover,
.apg-column-btn.active .column-icon-hover {
    opacity: 1;
}

/* Results Count */
.apg-results-info    { display: inline-block; }
.apg-showing-count   { font-size: 14px; color: #666; font-weight: 500; }

/* Filter Sidebar */
.apg-filter-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.apg-filter-overlay.show { opacity: 1; visibility: visible; }

.apg-filter-sidebar {
    position: absolute;
    top: 0; left: 0;
    width: 350px; height: 100%;
    background: #fff;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.apg-filter-overlay.show .apg-filter-sidebar { transform: translateX(0); }

.apg-filter-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.apg-filter-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

/* Right-side group: Clear All button + close X */
.apg-filter-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Clear All in header — visible on all screen sizes */
.apg-clear-header {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #000 !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

@media screen and (max-width: 767px) {
  .apg-clear-header {
    display: none !important;
  }
}

.apg-clear-header:hover     { border-color: none; color: none; }
.apg-clear-header svg       { stroke: currentColor; }

.apg-filter-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    border-radius: 3px;
}

.apg-filter-close:hover { color: #333; }

.apg-filter-content { flex: 1; overflow-y: auto; padding: 20px; }

.apg-filter-checkbox {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 14px;
    position: relative;
}

.apg-filter-checkbox input { position: absolute; opacity: 0; cursor: pointer; }

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 3px;
    margin-right: 10px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.apg-filter-checkbox:hover .checkmark { border-color: var(--primary-color); }

.apg-filter-checkbox input:checked ~ .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5px; top: 2px;
    width: 4px; height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.apg-filter-checkbox input:checked ~ .checkmark:after { display: block; }

/* ── Ion Range Slider — custom theme to match plugin brand colour ─────────── */
.apg-price-range         { margin-top: 8px; }

/* The hidden text input that IRS replaces — keep it truly hidden */
.apg-irs-range           { position: absolute; visibility: hidden; }

/* Bar colour */
.irs--round .irs-bar     { background-color: var(--primary-color); }

/* Handles */
.irs--round .irs-handle  {
    background-color: var(--primary-color);
    border-color:     var(--primary-color);
    box-shadow:       0 0 0 4px rgba(from var(--primary-color) r g b / 0.18);
    width:  18px;
    height: 18px;
    top:    27px;
}
.irs--round .irs-handle.state_hover,
.irs--round .irs-handle:hover {
    background-color: #9a1f18;
    border-color:     #9a1f18;
}

/* Value labels above handles — show currency-prefixed values */
.irs--round .irs-from,
.irs--round .irs-to,
.irs--round .irs-single  {
    background-color: transparent;
    color:            #000;
    font-weight:      600;
    font-size:        13px;
}

/* Hide the little triangle under the label bubbles */
.irs--round .irs-from::before,
.irs--round .irs-to::before,
.irs--round .irs-single::before { display: none; }

/* Hide min/max end labels — we don't need them, IRS shows them above handles */
.irs--round .irs-min,
.irs--round .irs-max     { display: none; }

/* ── Reset button ─────────────────────────────────────────────────────────── */
.apg-price-reset-wrap {
    text-align: right;
    margin-top:  6px;
}

.apg-price-reset {
    background:    none;
    border:        none;
    padding:       0;
    cursor:        pointer;
    font-size:     13px;
    color:         #999;
    display:       inline-flex;
    align-items:   center;
    gap:           4px;
    transition:    color 0.2s ease;
}

.apg-price-reset:hover     { color: var(--primary-color); }
.apg-price-reset svg       { stroke: currentColor; }

/* Mobile Filter Footer */
.apg-filter-footer { padding: 20px; border-top: 1px solid #eee; display: none; gap: 10px; }
.apg-mobile-only   { display: none; }

.apg-apply-filters,
.apg-clear-filters {
    color:#000;
    flex: 1;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.apg-apply-filters {
    background: var(--primary-color);
    color: white;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.apg-apply-filters:hover { background: #5a0011; }
.apg-apply-filters svg   { stroke: #fff !important; }

.apg-clear-filters {
    color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.apg-clear-filters:hover { background: none; }
.apg-clear-filters svg   { stroke: #fff; }

/* Load More */
.apg-pagination-wrapper { text-align: center; margin-top: 40px; }

.apg-load-more {
    background: #bd3229;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.apg-load-more:hover    { background: #5a0011; transform: translateY(-2px); }
.apg-load-more:disabled { background: #ccc; cursor: not-allowed; transform: none; }

/* Responsive */
@media (max-width: 1024px) {
    .apg-columns-5,
    .apg-columns-6 { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
    .apg-columns-3,
    .apg-columns-4,
    .apg-columns-5,
    .apg-columns-6 { grid-template-columns: repeat(2, 1fr); }

    .apg-filter-sidebar  { width: 280px; }
    .apg-mobile-only     { display: flex !important; }
    .apg-column-controls { gap: 15px; }
}

@media (max-width: 480px) {
    .apg-filter-sidebar  { width: 100%; }

    .add-to-cart-container {
        position: static;
        opacity: 1;
        transform: none;
        margin-top: 10px;
    }

    .product-carousel-item:hover .add-to-cart-container { transform: none; }
    .add-to-cart-btn { width: 100%; justify-content: center; }
}

@media (min-width: 769px) {
    .apg-filter-content .apg-filter-checkbox:hover {
        background-color: #f8f9fa;
        border-radius: 4px;
    }
}

/* Loading states */
.apg-grid.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.apg-grid.loading::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #bd3229;
    border-radius: 50%;
    animation: apg-spin 1s linear infinite;
}

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

/* Notification */
.apg-notification {
    position: fixed;
    top: 20px; right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    z-index: 10000;
    transform: translateX(400px);
    transition: all 0.3s ease;
    max-width: 300px;
}

.apg-notification.success { background: #28a745; }
.apg-notification.error   { background: #dc3545; }
.apg-notification.show    { transform: translateX(0); }

/* Search grid */
.apg-search-grid-wrapper { width: 100%; }

.apg-search-box-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.apg-search-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 240px;
    max-width: 600px;
}

.apg-search-icon {
    position: absolute;
    left: 14px;
    color: #999;
    pointer-events: none;
}

.apg-search-input {
    width: 100%;
    padding: 12px 44px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    outline: none;
    transition: border-color 0.3s ease;
    background: #fff;
}

.apg-search-input:focus   { border-color: #bd3229; }

.apg-search-clear {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 0;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.apg-search-clear:hover { color: #bd3229; }

.apg-search-results-label { font-size: 14px; color: #666; white-space: nowrap; }

.apg-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 15px;
}

@media (max-width: 768px) {
    .apg-search-box-wrapper { flex-direction: column; align-items: stretch; }
    .apg-search-box         { max-width: 100%; }
    .apg-search-results-label { text-align: center; }
}

@media (max-width: 320px) {
    .apg-filter-sidebar { width: 100%; }
    .apg-notification   { right: 10px; left: 10px; max-width: none; transform: translateY(-100px); }
    .apg-notification.show { transform: translateY(0); }
}