/**
 * Universal E-commerce PWA — Product Browsing CSS
 * Styles for product comparison, compare bar, compare page, and compare buttons.
 *
 * @package UniversalEcommercePWA
 */

/* =========================================================================
   Filter Bar Sticky Wrapper
   ========================================================================= */
.uepwa-filter-bar-sticky-wrap {
    position: sticky;
    top: 60px; /* Right below the 60px site header */
    z-index: 800; /* Just below header's 900 */
    background-color: #ffffff;
    /* Optional: add a tiny box-shadow when scrolling */
}

/* Fix for themes that wrap the before_shop_loop hook in a small container.
   This makes the wrapper invisible to the layout so sticky works relative to the main container. */
.storefront-sorting,
.woocommerce-products-header + .storefront-sorting,
.woocommerce-before-shop-loop {
    display: contents;
}

/* Account for WordPress Admin Bar */
body.admin-bar .uepwa-filter-bar-sticky-wrap {
    top: 92px; /* 60 + 32 */
}

@media screen and (max-width: 782px) {
    body.admin-bar .uepwa-filter-bar-sticky-wrap {
        top: 106px; /* 60 + 46 */
    }
}


/* =========================================================================
   Compare Button — on product cards and detail pages
   ========================================================================= */
.uepwa-compare-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.uepwa-compare-btn:hover {
    background-color: var(--color-surface);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.uepwa-compare-btn.added {
    background-color: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
}

.uepwa-compare-btn.added:hover {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* Card variant — full width below add-to-cart */
.uepwa-compare-btn--card {
    width: 100%;
    margin-top: 4px;
    height: 36px;
}

/* Detail variant — inline with other actions */
.uepwa-compare-btn--detail {
    height: 44px;
    padding: 0 20px;
    font-size: 14px;
}

/* =========================================================================
   Floating Comparison Bar
   ========================================================================= */
.uepwa-compare-bar {
    position: fixed;
    bottom: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    width: 100%;
    background-color: #ffffff;
    border-top: 2px solid var(--color-primary);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    z-index: 1100;
    padding: 10px 16px;
    transition: transform var(--transition-base);
}

/* Push bar above bottom nav on mobile */
@media (max-width: 767px) {
    .uepwa-compare-bar {
        bottom: 60px;
    }
}

.uepwa-compare-bar[hidden],
body.uepwa-compare-page .uepwa-compare-bar {
    display: none !important;
}

.uepwa-compare-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 1440px;
    margin-inline: auto;
    flex-wrap: wrap;
}

/* Product thumbnails in bar */
.uepwa-compare-bar-products {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.uepwa-bar-thumb {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    overflow: visible;
    flex-shrink: 0;
}

.uepwa-bar-thumb img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--color-border);
    display: block;
}

.uepwa-bar-remove {
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    width: 18px;
    height: 18px;
    background-color: var(--color-error);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 1;
    transition: background-color var(--transition-fast);
}

.uepwa-bar-remove:hover {
    background-color: #c53030;
}

/* Bar actions */
.uepwa-compare-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.uepwa-compare-bar-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

/* Reuse .uepwa-btn styles for bar buttons */
.uepwa-btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.uepwa-btn-primary:hover {
    background-color: var(--color-primary-dark);
}

.uepwa-btn-secondary {
    background-color: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.uepwa-btn-secondary:hover {
    background-color: var(--color-primary);
    color: #ffffff;
}

/* =========================================================================
   Max-Reached Modal
   ========================================================================= */
.uepwa-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.uepwa-modal[hidden] {
    display: none;
}

.uepwa-modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.uepwa-modal-content {
    position: relative;
    background-color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    z-index: 1;
    direction: rtl;
}

.uepwa-modal-content h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.uepwa-modal-content p {
    font-size: 14px;
    color: #666666;
    margin-bottom: 16px;
}

.uepwa-modal-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.uepwa-modal-product {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
}

.uepwa-modal-product img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.uepwa-modal-product span {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uepwa-modal-remove {
    background-color: var(--color-error);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color var(--transition-fast);
}

.uepwa-modal-remove:hover {
    background-color: #c53030;
}

.uepwa-modal-close {
    width: 100%;
}

/* =========================================================================
   Comparison Page
   ========================================================================= */
.uepwa-compare-page-wrap {
    max-width: 1440px;
    margin-inline: auto;
    padding: 16px;
    direction: rtl;
}

.uepwa-compare-page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.uepwa-compare-page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
}

.uepwa-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.uepwa-back-link:hover {
    color: var(--color-primary-dark);
}

/* Empty state */
.uepwa-compare-empty {
    text-align: center;
    padding: 60px 24px;
}

.uepwa-compare-empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    line-height: 1;
}

.uepwa-compare-empty h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.uepwa-compare-empty p {
    font-size: 14px;
    color: #666666;
    margin-bottom: 24px;
}

/* =========================================================================
   Comparison Table
   ========================================================================= */
.uepwa-compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.uepwa-compare-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
    background-color: #ffffff;
    direction: rtl;
}

/* Label column (first column) */
.uepwa-compare-label-col {
    width: 140px;
    min-width: 120px;
    background-color: var(--color-surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    padding: 14px 16px;
    text-align: start;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    position: sticky;
    inset-inline-start: 0;
    z-index: 2;
}

/* Product columns */
.uepwa-compare-product-col {
    min-width: 180px;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    text-align: center;
}

/* Product header cell */
.uepwa-compare-product-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
}

.uepwa-compare-remove {
    position: absolute;
    top: 0;
    inset-inline-end: 0;
    background-color: transparent;
    color: #999999;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color var(--transition-fast), color var(--transition-fast);
    line-height: 1;
}

.uepwa-compare-remove:hover {
    background-color: var(--color-error);
    color: #ffffff;
    border-color: var(--color-error);
}

.uepwa-compare-product-img {
    width: 120px;
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.uepwa-compare-product-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
}

.uepwa-compare-product-name a {
    color: var(--color-text);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.uepwa-compare-product-name a:hover {
    color: var(--color-primary);
}

/* Table rows */
.uepwa-compare-row th {
    background-color: var(--color-surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    padding: 12px 16px;
    text-align: start;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    position: sticky;
    inset-inline-start: 0;
    z-index: 2;
}

.uepwa-compare-row td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    text-align: center;
    vertical-align: middle;
}

/* Alternating row background */
.uepwa-compare-row:nth-child(even) td {
    background-color: #fafafa;
}

/* Difference highlight — visual indicator for differing values */
.uepwa-compare-row td.uepwa-diff {
    background-color: rgba(34, 197, 94, 0.08);
    color: #166534;
    font-weight: 600;
    position: relative;
}

.uepwa-compare-row td.uepwa-diff::after {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--color-success);
    border-radius: 0 2px 2px 0;
}

/* Row with any difference — subtle row highlight */
.uepwa-row-diff th {
    background-color: #f1f5f9;
}

/* Actions row */
.uepwa-compare-row-actions td {
    padding: 16px;
}

/* =========================================================================
   Rating Stars
   ========================================================================= */
.uepwa-compare-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

.uepwa-stars-filled {
    display: inline-block;
    font-size: 16px;
    color: #d1d5db;
    position: relative;
    letter-spacing: 1px;
}

.uepwa-stars-filled::before {
    content: '★★★★★';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    color: var(--color-accent);
    overflow: hidden;
    width: calc(var(--rating, 0) / 5 * 100%);
    white-space: nowrap;
}

.uepwa-rating-num {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
}

.uepwa-review-count {
    font-size: 12px;
    color: #888888;
}

/* Filter bar stars styling */
.uepwa-filter-check .uepwa-stars {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    font-size: 14px;
    line-height: 1;
    letter-spacing: 0;
    color: #fbbf24;
    flex-shrink: 0;
}

.uepwa-filter-check .uepwa-stars::before {
    content: attr(data-rating);
    position: absolute;
    left: -9999px;
}

/* Mobile: smaller stars and better layout to prevent horizontal scroll */
@media (max-width: 767px) {
    .uepwa-filter-check .uepwa-stars {
        font-size: 12px;
        gap: 0;
    }

    .uepwa-filter-check {
        font-size: 13px;
        gap: 6px;
    }
}

/* =========================================================================
   Stock Badge
   ========================================================================= */
.uepwa-stock-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

.uepwa-stock-instock {
    background-color: rgba(34, 197, 94, 0.12);
    color: #166534;
}

.uepwa-stock-outofstock {
    background-color: rgba(239, 68, 68, 0.1);
    color: #991b1b;
}

.uepwa-stock-onbackorder {
    background-color: rgba(245, 158, 11, 0.12);
    color: #92400e;
}

/* =========================================================================
   Out of stock text in compare table
   ========================================================================= */
.uepwa-out-of-stock {
    font-size: 13px;
    color: #999999;
    font-style: italic;
}

/* =========================================================================
   Add to Cart button in compare table
   ========================================================================= */
.uepwa-compare-add-to-cart {
    width: 100%;
    height: 36px;
    background-color: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.uepwa-compare-add-to-cart:hover {
    background-color: rgba(30, 58, 95, 0.05);
}

.uepwa-compare-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =========================================================================
   Responsive — Mobile adjustments
   ========================================================================= */
@media (max-width: 767px) {
    .uepwa-compare-page-wrap {
        padding: 12px;
    }

    .uepwa-compare-page-header h1 {
        font-size: 18px;
    }

    .uepwa-compare-product-img {
        width: 90px;
        height: 120px;
    }

    .uepwa-compare-table {
        min-width: 100%;
        width: max-content;
    }

    .uepwa-compare-label-col,
    .uepwa-compare-row th {
        width: 90px;
        min-width: 90px;
        font-size: 11px;
        padding: 8px 6px;
    }

    .uepwa-compare-product-col,
    .uepwa-compare-row td {
        width: 135px;
        min-width: 135px;
        padding: 8px 6px;
        font-size: 13px;
    }

    .uepwa-compare-bar-inner {
        gap: 8px;
    }

    .uepwa-compare-bar-count {
        display: none;
    }

    .uepwa-btn-primary,
    .uepwa-btn-secondary {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .uepwa-compare-product-img {
        width: 72px;
        height: 96px;
    }

    .uepwa-compare-product-name {
        font-size: 12px;
    }
}

/* =========================================================================
   Single Product - Gallery & Lightbox
   ========================================================================= */
.uepwa-gallery-wrapper {
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
}

.woocommerce-product-gallery {
    margin-bottom: 24px;
}

.woocommerce-product-gallery__image img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.uepwa-gallery-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.uepwa-gallery-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--color-border);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.uepwa-gallery-dot.active {
    background-color: var(--color-primary);
    transform: scale(1.2);
}

.uepwa-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uepwa-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

.uepwa-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
}

.uepwa-lightbox-img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.uepwa-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
}

/* =========================================================================
   Single Product - Variation Swatches
   ========================================================================= */
.uepwa-hidden-select {
    display: none !important;
}

.uepwa-swatch-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
    margin-bottom: 16px;
}

.uepwa-color-swatch {
    border: 2px solid transparent;
    padding: 6px;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.uepwa-color-swatch .uepwa-color-dot {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(0,0,0,0.12);
}

.uepwa-color-swatch.selected {
    border-color: var(--color-primary);
    background-color: var(--color-surface);
    transform: translateY(-2px);
}

.uepwa-swatch-name {
    font-size: 11px;
    color: var(--color-text);
    font-weight: 500;
    text-align: center;
}

.uepwa-size-pill {
    padding: 8px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.uepwa-size-pill:hover {
    background: #f5f5f5;
}

.uepwa-size-pill.selected {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* =========================================================================
   Single Product - Widgets
   ========================================================================= */
.uepwa-sale-countdown {
    background: #fff8f8;
    border: 1px solid #ffebeb;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.uepwa-countdown-label {
    color: var(--color-error);
    font-weight: 700;
    font-size: 14px;
}

.uepwa-countdown-timer {
    display: flex;
    align-items: center;
    gap: 6px;
}

.uepwa-countdown-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--color-error);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    min-width: 48px;
}

.uepwa-countdown-value {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.uepwa-countdown-name {
    font-size: 10px;
    opacity: 0.9;
    margin-top: 2px;
}

.uepwa-countdown-sep {
    color: var(--color-error);
    font-weight: 700;
}

.uepwa-delivery-estimate {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 24px;
    margin-bottom: 24px;
}

.uepwa-delivery-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-text);
}

.uepwa-gov-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-size: 14px;
    background: #fff;
    margin-bottom: 12px;
}

.uepwa-delivery-msg {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-success);
    font-size: 14px;
    font-weight: 500;
    background: #f0fdf4;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    width: 100%;
}

.uepwa-specs-table-wrap {
    margin-top: 32px;
}

.uepwa-specs-table {
    width: 100%;
    border-collapse: collapse;
}

.uepwa-specs-table th,
.uepwa-specs-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    text-align: right;
}

.uepwa-specs-table th {
    width: 40%;
    color: var(--color-text-light);
    font-weight: 500;
    background: var(--color-surface);
}

.uepwa-sticky-cart {
    position: fixed;
    bottom: -100px;
    left: 0;
    right: 0;
    background: #fff;
    padding: 12px 16px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: bottom var(--transition-base);
}

.uepwa-sticky-cart.visible {
    bottom: 0;
}

@media (max-width: 767px) {
    .uepwa-sticky-cart.visible {
        bottom: 60px;
        /* Above bottom nav */
    }
}

.uepwa-sticky-cart-btn {
    width: 100%;
    height: 44px;
}

.woocommerce-product-gallery__image--placeholder img {
    width: auto !important;
    max-width: 200px;
    margin: 0 auto;
    display: block;
}

/* =========================================================================
   Storefront Product Grid Overrides
   ========================================================================= */
.uepwa-catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 0 4px;
}

/* Premium Filter Button */
.uepwa-catalog-header .uepwa-filter-trigger {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #0f172a !important;
    border-radius: 24px !important;
    padding: 8px 16px !important;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) !important;
    transition: all 0.2s ease;
    height: 40px !important;
}
.uepwa-catalog-header .uepwa-filter-trigger:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.04) !important;
}
.uepwa-catalog-header .uepwa-filter-trigger svg {
    color: var(--color-primary) !important;
}

/* Premium Sort Dropdown */
.woocommerce-ordering {
    margin: 0 !important;
}
.woocommerce-ordering select {
    appearance: none !important;
    -webkit-appearance: none !important;
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #0f172a !important;
    border-radius: 24px !important;
    padding: 8px 16px 8px 36px !important; /* RTL: More padding on left for arrow */
    font-weight: 600 !important;
    font-size: 13px !important;
    font-family: inherit !important;
    cursor: pointer !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: left 12px center !important;
    background-size: 16px !important;
    transition: all 0.2s ease !important;
    height: 40px !important;
    min-width: 140px !important;
}
.woocommerce-ordering select:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.04) !important;
}
.woocommerce-ordering select:focus {
    outline: none !important;
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(10, 100, 255, 0.15) !important; /* generic primary fallback shadow */
}

.uepwa-product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

@media (min-width: 768px) {
    .uepwa-product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .uepwa-product-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

/* 
 * FIX: Make all product cards equal height and push buttons to bottom.
 * تم التعديل لجعل جميع الكروت بنفس الارتفاع ودفع زر السلة للأسفل 
 */
.uepwa-product-grid li.product {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

.uepwa-product-grid .uepwa-product-card-inner {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start;
    height: 100% !important; /* Stretch to fill li */
    flex-grow: 1 !important;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--color-border);
}

.uepwa-product-grid .uepwa-product-card-link {
    display: flex !important; 
    flex-direction: column !important;
    flex-grow: 1 !important; /* Pushes the bottom price section down */
    text-decoration: none;
    color: inherit;
}

/* 
 * ADDED: Styling for the short description.
 * تنسيق الوصف البسيط بحيث لا يتجاوز سطرين
 */
.uepwa-product-grid .uepwa-product-card-short-desc {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.uepwa-product-grid .uepwa-product-card-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    /* 1:1 aspect ratio instead of 3:4 to better fit varied product images */
    background: #ffffff;
}

.uepwa-product-grid .uepwa-product-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Prevents the image from being "eaten" (cropped) */
    padding: 12px; /* Adds breathing room around the image */
}

.uepwa-badge-sale {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--color-error);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    z-index: 2;
}

.uepwa-product-grid .uepwa-product-card-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
}

/* Make sure the info blocks do NOT stretch, so the Name and Price stay grouped tightly together */
.uepwa-product-grid .uepwa-product-card-link > .uepwa-product-card-info,
.uepwa-product-grid .uepwa-product-card-inner > .uepwa-product-card-info {
    flex: none;
}

.uepwa-product-grid .uepwa-product-card-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 6px;
    color: var(--color-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.uepwa-product-grid .uepwa-product-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}

.uepwa-product-grid .uepwa-rating-count {
    font-size: 11px;
    color: #888;
}

.uepwa-product-grid .uepwa-product-card-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-primary);
}

.uepwa-product-grid .uepwa-product-card-price del {
    color: #999;
    font-size: 12px;
    font-weight: 400;
    margin-inline-end: 4px;
}

.uepwa-product-grid .uepwa-product-card-swatches {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    align-items: center;
}

.uepwa-swatch-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    display: inline-block;
}

.uepwa-swatch-text {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.uepwa-swatch-more {
    font-size: 10px;
    color: #888;
}

.uepwa-product-grid .uepwa-add-to-cart-btn {
    margin: 12px;
    width: calc(100% - 24px);
    font-size: 13px;
    padding: 8px;
}

/* =========================================================================
   Filter Bar & Bottom Sheet Styles
   ========================================================================= */
.uepwa-filter-sheet {
    position: fixed;
    inset: 0;
    z-index: 999999 !important; /* Ensure it covers all headers, chips, and footers */
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.uepwa-filter-sheet--open {
    pointer-events: auto;
    opacity: 1;
}

.uepwa-filter-sheet__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.uepwa-filter-panel {
    position: relative;
    background: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px;
    padding-bottom: 80px; /* Extra space so content isn't hidden behind bottom nav bar */
    max-height: calc(100vh - 60px);
    margin-top: auto;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    transform: translateY(100%);
    transition: transform var(--transition-base);
    width: 100%;
    box-sizing: border-box;
}

.uepwa-filter-sheet--open .uepwa-filter-panel {
    transform: translateY(0);
}

.uepwa-filter-section {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 20px;
}

.uepwa-filter-section:last-child {
    border-bottom: none;
}

.uepwa-filter-heading,
.uepwa-filter-label {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    display: block;
    color: var(--color-primary);
}

.uepwa-filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.uepwa-filter-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
    margin-bottom: 12px;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    max-width: 100%;
    overflow: hidden;
}

.uepwa-filter-count {
    color: #888;
    font-size: 12px;
}

.uepwa-search-input-wrap input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 14px;
}

.uepwa-price-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
}

.uepwa-price-inputs input {
    flex: 1;
    max-width: calc(50% - 20px);
    /* Equal width for both inputs */
    padding: 12px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
    font-family: var(--font-primary);
    font-size: 14px;
    box-sizing: border-box;
}

.uepwa-price-inputs span {
    color: var(--color-text);
    font-weight: 600;
    flex-shrink: 0;
}

.uepwa-price-range {
    width: 100%;
}

.uepwa-price-range input[type=range] {
    width: 100%;
}

.uepwa-toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.uepwa-toggle-label input {
    display: none;
}

.uepwa-toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--color-border);
    border-radius: 12px;
    position: relative;
    transition: background var(--transition-fast);
}

.uepwa-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.uepwa-toggle-label input:checked+.uepwa-toggle-switch {
    background: var(--color-success);
}

.uepwa-toggle-label input:checked+.uepwa-toggle-switch::after {
    transform: translateX(20px);
}

.uepwa-filter-actions {
    display: flex;
    gap: 12px;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 16px;
}

.uepwa-filter-actions .uepwa-btn {
    flex: 1;
}

/* Premium Filter Toggle Button */
button#uepwa-filter-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    background: #fff !important;
    background-image: none !important;
    color: #1e293b !important;
    border: 1.5px solid #e0e0e0 !important;
    border-radius: 24px !important;
    padding: 9px 18px !important;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    white-space: nowrap;
    line-height: 1.3;
}

button#uepwa-filter-toggle:hover {
    background-color: #f8fafc !important;
    border-color: #94a3b8 !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Premium Sort Bar */
.uepwa-sort-bar {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 0 !important;
}

.uepwa-sort-bar .uepwa-sort-label {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #64748b !important;
    white-space: nowrap !important;
    margin: 0 !important;
}

.uepwa-sort-bar .uepwa-sort-select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background: #fff !important;
    border: 1.5px solid #e0e0e0 !important;
    color: #1e293b !important;
    border-radius: 24px !important;
    padding: 9px 16px 9px 32px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    font-family: inherit !important;
    cursor: pointer !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: left 10px center !important;
    background-size: 14px !important;
    line-height: 1.3 !important;
    outline: none !important;
    transition: all 0.2s ease !important;
}

.uepwa-sort-bar .uepwa-sort-select:hover,
.uepwa-sort-bar .uepwa-sort-select:focus {
    background-color: #f8fafc !important;
    border-color: #94a3b8 !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important;
}

/* Filter + Sort in one row */
.uepwa-filter-bar {
    display: flex !important;
    align-items: center !important;
    margin-bottom: 8px !important;
}
.uepwa-filter-bar + .uepwa-sort-bar {
    margin-bottom: 20px !important;
}

/* Keep filter sheet hidden by default on all screen sizes */
@media (min-width: 1024px) {
    .uepwa-filter-sheet {
        /* Keep it as overlay even on desktop */
        position: fixed;
        opacity: 0;
        pointer-events: none;
    }

    .uepwa-filter-sheet--open {
        opacity: 1;
        pointer-events: auto;
    }

    .uepwa-filter-panel {
        max-width: 480px;
        margin: auto;
        border-radius: var(--radius-lg);
        max-height: 90vh;
        margin-top: 5vh;
    }
}

/* =========================================================================
   UI Decluttering: Hide floating widgets on mobile since they are in bottom nav
   ========================================================================= */
@media (max-width: 767px) {

    .uepwa-whatsapp-floating,
    .uepwa-chat-widget-launcher,
    #uepwa-live-chat-launcher {
        display: none !important;
    }
}

/* =========================================================================
 * Card Actions (70/30 Unified Split Button)
 * ========================================================================= */
.uepwa-card-actions {
    display: flex;
    gap: 0; /* Connected look */
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden; /* Keep buttons inside the border radius */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

.uepwa-card-actions .uepwa-btn {
    padding: 10px 4px; /* Taller for premium feel */
    font-size: 13px;
    border-radius: 0; /* Reset individual radius */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.uepwa-card-actions .uepwa-add-to-cart-btn,
.uepwa-card-actions .ajax_add_to_cart,
.uepwa-card-actions .uepwa-quick-view-btn {
    flex: 7; /* 70% */
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
}

.uepwa-card-actions .uepwa-add-to-cart-btn:hover,
.uepwa-card-actions .ajax_add_to_cart:hover,
.uepwa-card-actions .uepwa-quick-view-btn:hover {
    background: var(--color-primary-dark);
}

.uepwa-card-actions .uepwa-compare-btn-split {
    flex: 3; /* 30% */
    background: #f8fafc; /* Lighter background */
    color: #475569;
    border-right: 1px solid #e2e8f0; /* Separator line between buttons (RTL) */
}

.uepwa-card-actions .uepwa-compare-btn-split:hover {
    background: #f1f5f9;
    color: var(--color-primary);
}

.uepwa-card-actions .uepwa-compare-btn-split svg {
    width: 14px;
    height: 14px;
}

/* =========================================================================
 * Quick View Modal (Bottom Sheet on Mobile)
 * ========================================================================= */
.uepwa-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99999;
    display: flex;
    align-items: flex-end; /* Bottom sheet default */
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.uepwa-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.uepwa-modal-content {
    background: #fff;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    position: relative;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.uepwa-modal-overlay.active .uepwa-modal-content {
    transform: translateY(0);
}

@media (min-width: 768px) {
    .uepwa-modal-overlay {
        align-items: center; /* Center on desktop */
    }
    .uepwa-modal-content {
        max-width: 500px;
        border-radius: 12px;
        transform: scale(0.9);
    }
    .uepwa-modal-overlay.active .uepwa-modal-content {
        transform: scale(1);
    }
}

.uepwa-modal-close {
    position: absolute;
    top: 16px;
    left: 16px; /* RTL */
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uepwa-qv-header {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    align-items: center;
}

.uepwa-qv-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.uepwa-qv-title {
    font-size: 16px;
    margin: 0 0 8px 0;
    color: #1e293b;
}

.uepwa-qv-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary);
}

/* Variations Form adjustments for Modal */
.uepwa-qv-form-wrapper .variations {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}
.uepwa-qv-form-wrapper .variations tr {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}
.uepwa-qv-form-wrapper .variations td.label {
    padding: 0 0 8px 0;
    text-align: right;
    font-weight: 600;
    color: #1e293b;
    font-size: 14px;
}
.uepwa-qv-form-wrapper .variations td.label label {
    margin: 0;
}
.uepwa-qv-form-wrapper .variations td.value {
    width: 100%;
    position: relative;
}
.uepwa-qv-form-wrapper .variations select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px 16px 12px 35px; /* space for arrow on the left */
    font-size: 14px;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    outline: none;
    font-family: inherit;
    font-weight: 500;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px center; /* left side for RTL */
    background-size: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.uepwa-qv-form-wrapper .variations select:focus,
.uepwa-qv-form-wrapper .variations select:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
    background-color: #ffffff;
}

/* Clear Selection link */
.uepwa-qv-form-wrapper .reset_variations {
    display: inline-block;
    font-size: 12px;
    color: #ef4444;
    margin-top: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}
.uepwa-qv-form-wrapper .reset_variations:hover {
    color: #b91c1c;
    text-decoration: underline;
}

/* Price & Availability */
.uepwa-qv-form-wrapper .single_variation_wrap {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed #cbd5e1;
}
.uepwa-qv-form-wrapper .woocommerce-variation {
    margin-bottom: 16px;
    text-align: right;
}
.uepwa-qv-form-wrapper .woocommerce-variation-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 8px;
}
.uepwa-qv-form-wrapper .woocommerce-variation-availability {
    font-size: 13px;
    color: #10b981;
    font-weight: 600;
    margin-bottom: 12px;
    display: block;
}

/* Add to cart wrapper inside quick view */
.uepwa-qv-form-wrapper .woocommerce-variation-add-to-cart {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
}

.uepwa-qv-form-wrapper .quantity {
    flex: 0 0 80px;
}
.uepwa-qv-form-wrapper .quantity .qty {
    width: 100%;
    height: 48px;
    padding: 0 10px;
    text-align: center;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    background: #f8fafc;
    transition: all 0.2s;
}
.uepwa-qv-form-wrapper .quantity .qty:focus {
    border-color: var(--color-primary);
    outline: none;
    background: #fff;
}

.uepwa-qv-form-wrapper .single_add_to_cart_button {
    flex: 1;
    height: 48px;
    background-color: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(30, 58, 95, 0.1);
}
.uepwa-qv-form-wrapper .single_add_to_cart_button:hover:not(.disabled) {
    background-color: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(30, 58, 95, 0.15);
}
.uepwa-qv-form-wrapper .single_add_to_cart_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #94a3b8;
    box-shadow: none;
}

.uepwa-loader {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
/* Force PhotoSwipe Close Button Visibility */
.pswp { z-index: 9999999 !important; }
.pswp__button--close { display: block !important; opacity: 1 !important; visibility: visible !important; z-index: 9999999 !important; background-color: rgba(0,0,0,0.5) !important; border-radius: 50% !important; }
