.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    background-color: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    width: auto;
    float: none;
}

.woocommerce ul.products,
.woocommerce-page ul.products {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-top: 1px solid #e9e9e9;
    border-left: 1px solid #e9e9e9;
    margin: 0 0 40px 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.woocommerce ul.products::before,
.woocommerce ul.products::after {
    display: none;
    content: none;
}

@media (max-width: 1200px) {

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .woocommerce ul.products,
    .woocommerce-page ul.products {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
        margin: 0;
        padding: 0;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
        border: none;
    }

    .woocommerce ul.products li.product,
    .woocommerce-page ul.products li.product {
        width: auto;
        min-width: 0;
        margin: 0;
    }
}

/* Novateplica Product Card */
.novateplica-product-card {
    background: #fff;
    /* Borders: Right and Bottom only. Container has Top and Left. */
    border-right: 1px solid #e9e9e9;
    border-bottom: 1px solid #e9e9e9;
    border-radius: 0;
    /* Flat grid style */
    padding: 16px;
    /* Spacious padding */
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: box-shadow 0.2s ease, z-index 0s;
}

.novateplica-product-card:hover {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    z-index: 10;
    border-color: transparent;
}

/* Wishlist Button - Revert to Gray/Simple style */
.novateplica-wishlist-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    /* Above slider */
    color: #9ca3af;
    transition: all 0.2s;
    opacity: 0;
}

.novateplica-product-card:hover .novateplica-wishlist-btn,
.novateplica-wishlist-btn.in-wishlist {
    opacity: 1;
}

@media (max-width: 768px) {
    .novateplica-wishlist-btn {
        opacity: 1;
    }
}

.novateplica-wishlist-btn:hover {
    color: #ef4444;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.novateplica-wishlist-btn.in-wishlist {
    color: #ef4444;
}

/* Badge */
.novateplica-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    z-index: 20;
}

.novateplica-badge.new {
    background: #3b82f6;
}

/* SALE ICON CUSTOM STYLE */
.novateplica-sale-icon-wrapper {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 25;
    /* Higher than badges */
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.novateplica-sale-icon-wrapper:hover,
.novateplica-sale-icon-wrapper:focus,
.novateplica-sale-icon-wrapper:active {
    opacity: 1;
    transform: scale(1.1);
    outline: none;
    /* remove focus outline */
}

/* The Tag Icon */
.novateplica-sale-icon-wrapper i {
    font-size: 24px;
    color: #ef4444;
    /* Red */
    transform: rotate(90deg);
    /* Make it look like hanging tag if needed, or stick to normal */
    /* Let's keep it upright or slight tilt */
    transform: rotate(-15deg);
}

/* The % inside */
.inner-icon {
    position: absolute;
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    top: 50%;
    left: 50%;
    transform: translate(-45%, -50%) rotate(-15deg);
    /* Match rotation */
}

/* Tooltip */
.sale-tooltip {
    position: absolute;
    left: 35px;
    /* To the right of icon */
    top: 50%;
    transform: translateY(-50%);
    background: rgba(30, 30, 30, 0.9);
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;

    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

/* Tooltip Arrow */
.sale-tooltip::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 4px solid rgba(30, 30, 30, 0.9);
}

/* Show Tooltip states */
.novateplica-sale-icon-wrapper:hover .sale-tooltip,
.novateplica-sale-icon-wrapper:focus .sale-tooltip,
.novateplica-sale-icon-wrapper:active .sale-tooltip {
    opacity: 1;
    visibility: visible;
    left: 40px;
    /* Slide out effect */
}

/* NEW ICON CUSTOM STYLE */
.novateplica-new-icon-wrapper {
    position: absolute;
    /* Top set inline by PHP */
    left: 15px;
    z-index: 25;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.novateplica-new-icon-wrapper:hover,
.novateplica-new-icon-wrapper:focus,
.novateplica-new-icon-wrapper:active {
    opacity: 1;
    transform: scale(1.1);
    outline: none;
}

.novateplica-new-icon-wrapper i {
    font-size: 20px;
    color: #ff5722;
    /* Deep Orange "Hot" color */
}

/* Share tooltip show logic */
.novateplica-new-icon-wrapper:hover .sale-tooltip,
.novateplica-new-icon-wrapper:focus .sale-tooltip,
.novateplica-new-icon-wrapper:active .sale-tooltip {
    opacity: 1;
    visibility: visible;
    left: 40px;
}

/* Product Image */
.product-image-link {
    display: block;
    position: relative;
    padding-bottom: 100%;
    margin-bottom: 0;
    overflow: hidden;
    border-radius: 8px;
    cursor: default;
    touch-action: auto;
    background: #fff;
}

.product-image-link > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Transitions */
.secondary-image {
    /* ... existing pos ... */
    transition: opacity 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* Smoother */
}

/* Content */
.product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Product Title - Default (2 lines truncated) */
.woocommerce-loop-product__title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    /* ~20px per line */
    height: 52px;
    /* Force exactly 2 lines height (2 * 20px) */
    padding: 0;
    overflow: hidden;
    position: relative;
    z-index: 1;
    margin-top: 8px;
}

/* Link inside title - clamped to 2 lines by default */
.woocommerce-loop-product__title a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-decoration: none;
    color: #1f2937;
    transition: color 0.2s;
    word-break: break-word;
    hyphens: auto;
}

/* Product Rating Styling — unicode stars (no font dependency) */
.product-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    line-height: 1;
}

/* Override WooCommerce star font with unicode stars everywhere */
.woocommerce .star-rating,
.woocommerce-page .star-rating,
.star-rating {
    overflow: hidden;
    position: relative;
    height: 1.2em;
    line-height: 1.2;
    font-size: 14px;
    width: 5.4em;
    font-family: Arial, sans-serif !important;
    color: #ffb400;
}

.woocommerce .star-rating::before,
.woocommerce-page .star-rating::before,
.star-rating::before {
    content: '\2605\2605\2605\2605\2605' !important;
    color: #e2e8f0;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
    letter-spacing: 0.08em;
}

.woocommerce .star-rating span,
.woocommerce-page .star-rating span,
.star-rating span {
    overflow: hidden;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
    padding-top: 1.2em;
}

.woocommerce .star-rating span::before,
.woocommerce-page .star-rating span::before,
.star-rating span::before {
    content: '\2605\2605\2605\2605\2605' !important;
    top: 0;
    position: absolute;
    left: 0;
    letter-spacing: 0.08em;
    color: #ffb400 !important;
}

.rating-count {
    font-size: 12px;
    color: #475569;
    font-weight: 500;
}

.no-rating-text {
    font-size: 12px;
    color: #64748b;
    font-weight: 400;
    font-style: italic;
}

/* #15 — Rating display on product catalog cards */
.product-card-rating {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    margin: 3px 0 2px;
    line-height: 1;
}

.product-card-rating .star-rating {
    font-size: 12px;
    width: 5.4em;
    flex-shrink: 0;
}

.product-card-rating .rating-count {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
    display: inline-block !important;
    white-space: nowrap;
}

/* Product Stock Status Styling */
.product-stock-status {
    margin-bottom: 12px;
}

.product-stock-status .stock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.product-stock-status .stock.in-stock {
    color: #10b981;
    /* Premium Green */
}

.product-stock-status .stock.out-of-stock {
    color: #ef4444;
    /* Premium Red */
}

.product-stock-status .stock i {
    color: #ef4444;
    /* Premium Red */
}

.product-stock-status .stock i {
    font-size: 14px;
}


/* Hover state: show full title expanding DOWNWARD like Prom.ua */
/* ONLY if title is actually truncated (has .is-truncated class) */
.novateplica-product-card:hover .woocommerce-loop-product__title.is-truncated {
    overflow: visible;
    z-index: 100;
    /* Bring title to front so it overlays price */
}



/* Full title overlay - slides UP from bottom like a sheet of paper */
/* ONLY shown when title is truncated */
.novateplica-product-card:hover .woocommerce-loop-product__title.is-truncated a::after {
    content: attr(title);
    position: absolute;
    bottom: 0;
    /* Anchor to bottom so it slides UP from price */
    left: -10px;
    right: -10px;
    background: #fff;
    color: #1f2937;
    padding: 10px;

    z-index: 101;

    /* Text styling */
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    hyphens: auto;

    /* Animation - slide up from below */
    animation: slideUpFromBottom 0.2s ease-out;
    pointer-events: auto;
    cursor: pointer;
}

/* Slide UP animation - emerges from bottom like a paper sheet */
@keyframes slideUpFromBottom {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Price - Reverted to Simple Row */
.product-price-row {
    margin-top: 0;
    margin-bottom: 8px;
    font-family: var(--font-main);
}

.product-price-row .price {
    display: inline-flex !important;
    flex-direction: row-reverse !important;
    /* Force New Price first */
    justify-content: flex-end;
    align-items: baseline;
    gap: 8px;
    font-size: 18px !important;
    /* Explicitly bigger */
    font-weight: 700;
    color: #111;
}

.product-price-row del {
    font-size: 14px !important;
    color: #555555 !important;
    /* Darker gray for better contrast */
    font-weight: 400 !important;
    text-decoration: line-through !important;
    opacity: 1;
    /* Remove transparency */
}

.product-price-row ins {
    text-decoration: none !important;
    color: #ef4444 !important;
}

/* Actions logic */
.product-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;

    /* Ensure above title overlay */
}

/* Restore the "Buy" button style user liked */
.product-actions .button {
    width: 100%;
    background-color: #f3f4f6 !important;
    color: #1f2937 !important;
    font-weight: 600 !important;
    padding: 10px 15px !important;
    border-radius: 8px !important;
    border: none !important;
    text-align: center;
    transition: background-color 0.2s, transform 0.2s, color 0.2s;
    /* ptimized transition */
    font-size: 14px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.product-actions .button::before {
    content: '\f07a';
    /* fa-shopping-cart */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 14px;
    color: inherit;
    /* Inherit button text color */
}

.product-actions .button:hover {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

.product-actions .added_to_cart {
    display: none !important;
}

/* Mobile Optimizations */
@media (max-width: 576px) {
    .novateplica-product-card {
        padding: 8px;
    }

    .product-price-row .price {
        font-size: 16px;
    }

    .woocommerce-loop-product__title {
        font-size: 13px;
    }

    .product-actions .button {
        padding: 8px 10px !important;
        font-size: 13px !important;
    }
}

/* Variations Toggle */
.product-card-variations {
    display: none;
    /* Hidden by default */
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    padding: 0 16px 16px;
    z-index: 100;
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.15);
    border-radius: 0 0 4px 4px;
    margin-top: -2px;
}

.product-card-variations.active {
    display: block;
    animation: fadeInVars 0.2s ease-out;
}

@keyframes fadeInVars {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.var-trigger-wrapper {
    margin-top: 12px;
    text-align: center;
    width: 100%;
    position: relative;
    /* Higher than actions */
}

.var-trigger {
    color: #00a046;
    /* font-size: 13px; */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    transition: color 0.2s;
}

.var-trigger:hover {
    color: #008a3c;
    text-decoration: underline;
}

.var-group {
    margin-top: 10px;
    margin-bottom: 8px;
}

.var-label {
    display: block;
    font-size: 13px;
    color: #222;
    /* Darker */
    margin-bottom: 5px;
    line-height: 1.2;
}

.var-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.var-item {
    display: inline-block;
    font-size: 13px;
    color: #222;
    background: #fff;
    padding: 3px 10px;
    border: 1px solid #d2d2d2;
    border-radius: 4px;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    min-width: 30px;
    text-align: center;
}

.var-item:hover {
    border-color: #00a046;
    color: #00a046;
    text-decoration: none;
}

.var-show-all-wrapper {
    margin: 8px 0;
    text-align: center;
}

.var-show-all {
    color: #2196F3 !important;
    /* Blue */
}

.var-show-all:hover {
    color: #1976D2 !important;
}

/* Mobile Bottom Sheet Overrides */
@media (max-width: 768px) {
    .product-card-variations {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto;
        max-height: 80vh;
        overflow-y: auto;
        padding: 24px;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
        z-index: 9999;
        margin-top: 0 !important;

        /* Animation Base State: Visible DOM but off-screen */
        display: block !important;
        transform: translateY(100%);
        visibility: hidden;
        transition: transform 0.3s ease-in-out, visibility 0s 0.3s;
    }

    .product-card-variations.active {
        animation: none !important;
        transform: translateY(0);
        visibility: visible;
        transition: transform 0.3s ease-in-out, visibility 0s;
    }

    /* Mobile: Show all attributes immediately */
    .var-show-all-wrapper {
        display: none !important;
    }

    .extra-vars {
        display: block !important;
    }
}

@keyframes slideUpVars {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Backdrop */
.novateplica-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9990;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.novateplica-backdrop.active {
    display: block;
    opacity: 1;
}

/* Mobile Actions Styling */
.mobile-vars-actions {
    display: none;
    /* Hide on desktop */
}

@media (max-width: 768px) {
    .mobile-vars-actions {
        display: flex;
        gap: 10px;
        margin-top: 20px;
        padding-top: 15px;
        border-top: 1px solid #eee;
    }

    .m-var-btn {
        flex: 1;
        text-align: center;
        padding: 12px;
        border-radius: 4px;
        font-weight: 600;
        font-size: 14px;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .btn-view {
        background: #fff;
        border: 1px solid #ddd;
        color: #555;
    }

    .btn-apply {
        background: #00a046;
        color: #fff;
        border: 1px solid #00a046;
    }

    /* Remove dark background as requested */
    .novateplica-backdrop {
        background: transparent !important;
    }
}

.var-item.selected {
    background-color: #00a046 !important;
    color: #fff !important;
    border-color: #00a046 !important;
}

/* Fix Z-Index Stacking Context */
.product.variation-open {
    z-index: 99999 !important;
    position: relative;
    transform: none !important;
}

.product.variation-open .novateplica-product-card {
    z-index: 99999;
}

/* Mobile Close Button */
.var-close-btn {
    display: none;
}

@media (max-width: 768px) {
    .var-close-btn {
        display: flex;
        position: absolute;
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        align-items: center;
        justify-content: center;
        background: #f5f5f5;
        border-radius: 50%;
        cursor: pointer;
        font-size: 16px;
        color: #555;
        z-index: 20;
    }
}

/* Variable Product Actions Layout */
.product-actions.variable-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Keep them together */
    gap: 12px;
    /* Link sits nicely next to button */
}

/* Make Buy Button Smaller in Variable Context */
.product-actions.variable-actions .btn-small {
    width: auto !important;
    /* Allow it to shrink */
    flex: 0 0 auto;
    /* Don't grow aggressively */
    min-width: 42px;
    /* Ensure click target size */
}


.var-trigger-wrapper.inline-trigger .var-trigger i {
    margin-top: 1px;
    /* Optical adjustment */
}

/* Adjust mobile sizing */
@media (max-width: 576px) {
    .product-actions.variable-actions {
        gap: 6px;
    }

    .product-actions.variable-actions .btn-small {
        padding: 8px 12px !important;
    }
}

/* Dark Mode Overrides for Product Cards */
[data-theme="dark"] .novateplica-product-card {
    background: var(--card-bg);
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .woocommerce ul.products,
[data-theme="dark"] .woocommerce-page ul.products {
    border-top-color: var(--border-color) !important;
    border-left-color: var(--border-color) !important;
}

[data-theme="dark"] .novateplica-product-card:hover {
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .woocommerce-loop-product__title a,
[data-theme="dark"] .novateplica-product-card:hover .woocommerce-loop-product__title.is-truncated a::after {
    color: var(--text-color) !important;
    background-color: var(--card-bg) !important;
}

[data-theme="dark"] .product-price-row .price,
[data-theme="dark"] .product-price-row ins {
    color: var(--text-color) !important;
}

[data-theme="dark"] .product-price-row del {
    color: var(--text-light) !important;
}

[data-theme="dark"] .product-actions .button {
    background-color: var(--input-bg) !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] .product-actions .button:hover {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

[data-theme="dark"] .novateplica-wishlist-btn {
    background: rgba(17, 24, 39, 0.8);
    color: var(--text-light);
}

[data-theme="dark"] .product-image-link {
    background: transparent !important;
}

[data-theme="dark"] .product-card-variations {
    background: var(--card-bg);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .var-item {
    background: var(--input-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .var-label {
    color: var(--text-color);
}

[data-theme="dark"] .var-close-btn {
    background: var(--input-bg);
    color: var(--text-color);
}

[data-theme="dark"] .slider-dot {
    background: var(--border-color);
}

[data-theme="dark"] .slider-dot.active {
    background: var(--primary-color);
}

/* Responsive adjustments for Parameters button */
@media (max-width: 415px) {
    .var-trigger {
        font-size: 12px;
    }
}

@media (max-width: 412px) {
    .var-trigger .trigger-text {
        display: none;
    }

    .var-trigger i {
        font-size: 16px;
        /* Restore comfortable icon size */
        margin: 0;
    }
}
