/* Container & Wrapper */
.onos-cps-wrapper {
    position: relative;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

/* Header Section */
.onos-cps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    /* Optional separator */
    padding-bottom: 10px;
}

.onos-cps-section-title {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    text-transform: uppercase;
}

.onos-cps-nav-container {
    display: flex;
    gap: 15px;
}

.onos-cps-nav {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: #95a5a6;
    padding: 0;
    transition: color 0.3s;
    line-height: 1;
    display: flex;
    align-items: center;
}

.onos-cps-nav:hover {
    color: #2c3e50;
}

.onos-cps-nav:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

/* Slider Track */
.onos-cps-slider {
    overflow: hidden;
    width: 100%;
}

.onos-cps-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
    width: 100%;
    align-items: stretch;
    /* Ensure all columns are equal height */
}

/* Columns (The sliding unit) */
.onos-cps-column {
    flex: 0 0 25%;
    /* Desktop: 4 columns */
    max-width: 25%;
    padding: 0 10px;
    /* Horizontal Gap */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Vertical Gap between rows */
    height: 100%;
    /* Fill the track height */
}

/* Cards */
.onos-cps-card {
    width: 100%;
    /* Fill column */
    display: flex;
    flex-direction: column;
    height: auto;
    /* Allow flex to control height */
    flex: 1;
    /* Force equal height for both cards in the column */
    min-height: 0;
    /* Prevent overflow issues */
}

.onos-cps-card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: box-shadow 0.3s ease;
}

.onos-cps-card-inner:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

/* Image */
.onos-cps-image-container {
    background: #fff;
    height: 220px;
    display: block;
    padding: 0;
    /* Full Width */
    border-radius: 4px 4px 0 0;
    overflow: hidden;
    /* Clip corners */
}

.onos-cps-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill area */
    transition: transform 0.3s ease;
    display: block;
}

.onos-cps-card-inner:hover .onos-cps-image-container img {
    transform: scale(1.05);
}

/* Content Area - Light Blue Theme */
.onos-cps-content {
    background: #e1f5fe;
    /* Light Blue */
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    border-radius: 0 0 4px 4px;
}

.onos-cps-title {
    font-size: 16px;
    font-weight: 700;
    color: #0288d1;
    /* Strong Blue */
    margin: 0 0 10px;
    line-height: 1.3;
    /* Force single line with ellipsis */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
}

.onos-cps-price {
    font-size: 16px;
    font-weight: 700;
    color: #0288d1;
    margin: 0 0 10px;
    line-height: 1.3;
}

.onos-cps-title a {
    text-decoration: none;
    color: inherit;
}

.onos-cps-excerpt {
    font-size: 13px;
    color: #546e7a;
    line-height: 1.5;
    margin-bottom: 15px;
    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 3em;
    /* Fallback height: line-height * 2 */
}

/* View Button - Always Expanded (Pill/Rectangular) */
.onos-cps-action {
    margin-top: auto;
    padding-top: 15px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Left align the button */
    width: 100%;
}

.onos-cps-view-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 10px 20px !important;
    /* Comfortable padding */
    width: auto !important;
    min-width: 140px;
    /* Minimum width for consistency */
    height: auto !important;
    min-height: 38px;
    border-radius: 5px !important;
    /* Standard rounded button, change to 50px for pill */
    background: #00ADEF !important;
    /* Fallback, overridden by inline PHP */
    color: #fff !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-weight: 700;
    transition: all 0.3s ease;
    white-space: nowrap;
    border: none !important;
    line-height: normal !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.onos-cps-view-btn span.dashicons {
    font-size: 18px !important;
    width: 18px !important;
    height: 18px !important;
    line-height: 1 !important;
    margin-left: 10px !important;
    /* Space between text and icon */
    margin-right: 0 !important;
    text-align: center;
    display: inline-block;
}

/* Helper to show text */
.onos-cps-view-btn-text {
    opacity: 1;
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-block;
}

/* Hover State (Simple Color Change) */
.onos-cps-card-inner:hover .onos-cps-view-btn,
.onos-cps-view-btn:hover {
    background: #0081b3 !important;
    /* Darker blue on hover */
    transform: translateY(-2px);
    /* Slight lift */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Mobile/Tablet adjustment: Ensure button remains full size */
@media (max-width: 1024px) {

    /* Adjust Column Spacing */
    .onos-cps-column {
        padding: 0 5px;
        /* Tighter padding for mobile grid */
    }

    /* Smaller Image Height for Mobile Cards */
    .onos-cps-image-container {
        height: 160px;
        padding: 0;
        /* Full Width on Mobile too */
    }

    /* Smaller Fonts for Mobile density */
    .onos-cps-title {
        font-size: 14px;
        margin-bottom: 5px;
    }

    .onos-cps-excerpt {
        display: none !important;
        /* Hide excerpt on mobile for space */
    }

    /* Keep button full size on mobile but safe */
    /* Keep button full size on mobile but safe */
    .onos-cps-view-btn {
        width: 100% !important;
        /* Full width relative to container */
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 6px 4px !important;
        /* Very tight padding for narrow screens */
        font-size: 11px !important;
        /* Smaller font to fit "Add to Cart" */
        box-sizing: border-box !important;
        margin-top: 5px;
        white-space: nowrap !important;
        /* Try to keep single line */
        text-overflow: ellipsis;
        /* Ellipsis if it still overflows */
        overflow: hidden;
    }

    .onos-cps-view-btn-text {
        display: inline-block !important;
        opacity: 1 !important;
        width: auto !important;
    }

    .onos-cps-view-btn span.dashicons {
        margin-left: 4px !important;
        /* Reduced icon gap */
        margin-right: 0 !important;
        font-size: 14px !important;
        /* Scale icon down */
        width: 14px !important;
        height: 14px !important;
    }

    /* Reduce Card Padding on Mobile to give button more room */
    .onos-cps-content {
        padding: 10px !important;
        /* Reduced from 20px */
    }
}

/* =========================================
   CTA Buttons (Single Product & Global)
   ========================================= */
.onos-cta-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    align-items: center;
}

.onos-cta-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 10px 20px !important;
    background-color: #00ADEF;
    /* Cyan/Blue from screenshot */
    color: #fff !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-weight: 500;
    border-radius: 4px !important;
    transition: background 0.2s, transform 0.2s;
    min-width: 140px;
    /* Slightly wider to match screenshot */
    border: none !important;
    cursor: pointer !important;
    line-height: normal !important;
    box-shadow: none !important;
    text-transform: none;
    /* Prevent theme uppercase if not desired */
}

.onos-cta-btn:hover {
    background-color: #009ad5;
    text-decoration: none;
    color: #fff !important;
}

.onos-cta-btn .dashicons {
    font-family: 'dashicons' !important;
    /* Ensure dashicons font is used */
    margin-right: 8px;
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
}

/* SVG icons in CTA buttons (e.g., WhatsApp) */
.onos-cta-btn svg {
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Ensure WhatsApp button has consistent styling */
.onos-cta-whatsapp {
    background-color: #00ADEF !important;
    color: #fff !important;
}

.onos-cta-whatsapp:hover {
    background-color: #009ad5 !important;
    color: #fff !important;
}

/* Responsive */
@media (max-width: 1024px) {
    .onos-cps-column {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 600px) {
    .onos-cps-wrapper {
        padding: 0 2px;
        /* Maximize width on mobile */
    }

    .onos-cps-column {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .onos-cps-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }

    .onos-cps-nav-container {
        align-self: center;
    }

    .onos-cta-container {
        flex-direction: column;
        align-items: stretch;
    }

    .onos-cta-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* =========================================
   WooCommerce Shop Loop Alignment Fix (Broad Selectors)
   ========================================= */
.woocommerce .products {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    /* Force equal height rows */
}

/* Target both li and div based grids */
.woocommerce .products .product {
    display: flex !important;
    flex-direction: column !important;
    float: none !important;
    height: 100% !important;
    /* key to alignment */
    margin-bottom: 20px !important;
    padding: 0 5px !important;
    box-sizing: border-box !important;
}

/* Push CTA buttons to the bottom of the card and center them */
.woocommerce .products .product .onos-cta-container {
    margin-top: auto !important;
    /* This pushes button to bottom */
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-bottom: 15px;
    /* Add bottom padding for safety */
}

/* Ensure Titles have a minimum consistent height */
/* Ensure Titles have a minimum consistent height AND enforce single line */
.woocommerce .products .product .woocommerce-loop-product__title {
    /* min-height: 3.5em; Removed to allow single line tightness */
    display: block !important;
    /* Changed from flex to block for text-overflow to work */
    text-align: center;
    flex-grow: 0;

    /* Force single line with ellipsis */
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    margin-bottom: 5px !important;
}

/* Related Products specific clearance */
.related.products {
    clear: both;
    margin-bottom: 50px;
    width: 100%;
    display: block;
    /* Ensure it's a block context */
}

.related.products ul.products {
    margin-bottom: 0;
}

/* Mobile Related Products: 4 Products with Natural Heights */
@media (max-width: 600px) {

    /* Fix excessive spacing and ensure compact layout */
    .related.products {
        margin-bottom: 20px !important;
        padding-bottom: 0 !important;
    }

    .related.products .products,
    .related.products ul.products {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
        gap: 10px !important;
        align-items: flex-start !important;
        /* Prevent equal heights */
    }

    /* AGGRESSIVE: Remove ALL excessive margins and padding from products */
    .related.products .product,
    .related.products .products .product,
    .related.products ul.products li.product {
        margin: 0 !important;
        margin-bottom: 10px !important;
        padding: 0 !important;
        padding-bottom: 0 !important;
        min-height: auto !important;
        height: auto !important;
        /* Allow natural height */
        align-self: flex-start !important;
        /* Prevent stretching */
    }

    /* Remove spacing from product inner elements */
    .related.products .product>*,
    .related.products .products .product>* {
        margin-bottom: 5px !important;
    }

    /* Compact product images */
    .related.products .product img,
    .related.products .products .product img {
        margin-bottom: 5px !important;
    }

    /* Compact product titles */
    .related.products .product .woocommerce-loop-product__title,
    .related.products .product h2,
    .related.products .product h3 {
        margin: 0 0 5px 0 !important;
        padding: 0 !important;
        /* Enforce single line here too */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
    }

    /* Compact price */
    .related.products .product .price {
        margin: 0 0 5px 0 !important;
        padding: 0 !important;
    }

    /* CTA Button container */
    .related.products .products .product .onos-cta-container {
        margin: 5px 0 0 0 !important;
        padding: 0 !important;
        gap: 5px !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        align-items: stretch !important;
    }

    /* CTA Buttons - Ensure consistent styling */
    .related.products .onos-cta-btn,
    .related.products .products .product .onos-cta-btn {
        font-size: 12px !important;
        padding: 8px 10px !important;
        min-width: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        /* background-color: #00ADEF !important; REMOVED to allow global inline style to work */
        color: #fff !important;
        border-radius: 4px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }

    /* WhatsApp button specific styling for mobile */
    .related.products .onos-cta-whatsapp,
    .related.products .products .product .onos-cta-whatsapp {
        /* background-color: #00ADEF !important; REMOVED */
        color: #fff !important;
    }

    .related.products .onos-cta-btn:hover,
    .related.products .onos-cta-whatsapp:hover {
        background-color: #009ad5 !important;
        color: #fff !important;
    }

    /* Button icons - FIX DISPLAY */
    .related.products .onos-cta-btn .dashicons {
        font-family: 'dashicons' !important;
        /* Ensure font loads */
        font-size: 14px !important;
        line-height: 1 !important;
        width: 14px !important;
        height: 14px !important;
        margin-right: 8px !important;
        /* Increased spacing */
        display: inline-block !important;
        vertical-align: middle;
    }

    /* SVG icons in mobile buttons */
    .related.products .onos-cta-btn svg {
        width: 14px !important;
        height: 14px !important;
        margin-right: 5px !important;
        flex-shrink: 0 !important;
    }
}
