/* 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: 20px;
    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 Styles (Updated from Carousel) */
.product-carousel-item {
    background: #fff;
    border-radius: 8px;
    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;
}

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

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

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

.product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.product-title a:hover {
    color: #720015;
}

.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 img {
    width: 16px;
    height: auto;
}

.add-to-cart-btn {
    background-color: #720015;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: 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;
}

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

.apg-filter-btn {
    background: #6e0218;
    /* border: 1px solid #ddd; */
    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;
}

.apg-filter-btn:hover {
    /* border-color: #720015; */
    background: #000;
    color: #fff;
}

.apg-filter-btn img {
    filter: brightness(0) invert(1);
}

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

/* Native Sorting Select */
.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: #720015;
    outline: none;
}

/* Accordion Styles */
.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 #333;
    border-bottom: 2px solid #333;
    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;
}

.apg-column-btn img {
    /* width: 20px; */
    /* height: 20px; */
    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 {
    opacity: 0;
}

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

.apg-column-btn.active {
    /* No active style needed for image-only buttons as per request */
}

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

.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 (Left Side) */
.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: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.apg-filter-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.apg-filter-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

.apg-filter-group {
    /* margin-bottom: 30px; */
}

.apg-filter-group h4 {
    /* Removed default margin as it's handled in accordion-header */
    /* display: none; */
}

.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;
}

.apg-filter-checkbox:hover .checkmark {
    border-color: #720015;
}

.apg-filter-checkbox input:checked~.checkmark {
    background-color: #720015;
    border-color: #720015;
}

.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;
}

/* Price Range Slider */
.apg-price-range {
    margin-top: 15px;
}

.price-range-container {
    position: relative;
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
}

.price-slider-track {
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    position: absolute;
    top: 10px;
}

.price-slider-progress {
    height: 6px;
    background: #720015;
    border-radius: 3px;
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
}

.price-slider-input {
    position: absolute;
    top: 10px;
    width: 100%;
    height: 6px;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    z-index: 10;
}

.price-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #720015;
    cursor: pointer;
    pointer-events: auto;
    margin-top: -7px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.price-slider-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #720015;
    cursor: pointer;
    pointer-events: auto;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.price-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    margin-top: 15px;
}

.current-price {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #720015;
    margin-top: 10px;
}

/* 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 {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.apg-apply-filters {
    background: #720015;
    color: white;
}

.apg-apply-filters:hover {
    background: #5a0011;
}

.apg-clear-filters {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}

.apg-clear-filters:hover {
    background: #e9ecef;
}

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

.apg-load-more {
    background: #720015;
    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 Design */
@media (max-width: 1024px) {
    .apg-columns-5 {
        grid-template-columns: repeat(4, 1fr);
    }

    .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-custom-select {
        min-width: 150px;
    }

    .apg-column-controls {
        gap: 4px;
    }

    .apg-column-btn {
        width: 36px;
        height: 36px;
    }

    .apg-column-btn img {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .apg-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    .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;
    }
}

/* Desktop-only styles */
@media (min-width: 769px) {
    .apg-filter-content .apg-filter-checkbox:hover {
        background-color: #f8f9fa;
        /* Removed negative margin to prevent layout shift */
        border-radius: 4px;
    }

    /* Auto-close filter on desktop after selection */
    .apg-filter-overlay.desktop-auto-close {
        transition: all 0.3s ease 0.5s;
    }
}

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

.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 #720015;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Notification Styles */
.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);
}

/* Additional responsive fixes */
@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);
    }
}