/**
 * Cardshop Product Grid - Structural Styles Only
 *
 * IMPORTANT: This file contains ONLY structural CSS required for functionality.
 * Visual styling (colors, borders, padding, fonts, etc.) should be done through
 * Elementor's style controls in the widget panel.
 *
 * These styles handle:
 * 1. Image swap functionality (featured ↔ gallery image)
 * 2. Grid layout structure
 * 3. Basic positioning for interactive elements
 */

/* ==== PRODUCT CARD STRUCTURE ==== */
.product-card {
    position: relative; /* Required for absolute positioned children (badges, overlay) */
    display: flex;
    flex-direction: column;
    height: 100%; /* Fill parent container height */
}

/* ==== PRODUCT TITLE STYLING ==== */
.product-title {
    margin: 0; /* Remove default h3 margin */
    line-height: 1.2; /* Tight line height for multi-line titles */
}

.product-title a {
    transition: color 0.3s ease; /* Smooth color transition on hover */
    text-decoration: none;
    display: block; /* Ensures link takes full width */
}

/* ==== IMAGE SWAP FUNCTIONALITY ==== */
/* This is the core functionality: hover/tap to show gallery image */

.product-image-wrapper {
    position: relative; /* Required for stacking images and badges */
    cursor: pointer; /* Indicates clickable area */
    overflow: hidden; /* Prevents image overflow during transitions - clips border radius */
    display: block;
    width: 100%;
}

.product-images-container {
    position: relative; /* Stack images */
    width: 100%;
    height: 300px; /* Default height - configurable via Elementor */
    overflow: hidden;
    display: flex; /* Enable flexbox for centering */
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
}

.product-images-container img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center the image */
    width: 100%;
    height: 100%;
    object-fit: cover; /* Crop to fit while maintaining aspect ratio - fills entire 300px */
    display: block;
    transition: opacity 0.3s ease-in-out; /* Smooth fade between images */
}

/* First image visible by default */
.product-images-container img.first-image {
    opacity: 1;
}

/* Second image (gallery) hidden by default */
.product-images-container img.hover-image {
    opacity: 0;
}

/* Ensure link overlay covers entire image area */
.product-image-link-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2; /* Above images but below badges */
}

/* ==== DESKTOP: HOVER BEHAVIOR ==== */
/* Only applies to devices with hover capability (not touch devices) */
@media (hover: hover) and (pointer: fine) {
    .product-image-wrapper.has-hover:hover img.first-image {
        opacity: 0; /* Hide featured image */
    }
    .product-image-wrapper.has-hover:hover img.hover-image {
        opacity: 1; /* Show gallery image */
    }
}

/* ==== MOBILE: TAP BEHAVIOR ==== */
/* Class added by JavaScript on first tap */
.product-image-wrapper.has-hover.mobile-active img.first-image {
    opacity: 0; /* Hide featured image */
}
.product-image-wrapper.has-hover.mobile-active img.hover-image {
    opacity: 1; /* Show gallery image */
}

/* ==== PRODUCT BADGES (Sale, Out of Stock) ==== */
.product-badge-wrapper {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    z-index: 5; /* Above images */
    pointer-events: none; /* Allow clicks to pass through to image */
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
}

.product-badge {
    pointer-events: auto; /* Badges can be clicked if needed */
}

/* ==== PRODUCT GRID LAYOUT ==== */
.cardshop-product-grid.product-grid {
    display: grid;
    /* Grid columns controlled by Elementor's responsive controls */
    /* Default fallback: auto-fit responsive grid */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    align-items: stretch; /* Ensure all grid items have equal height */
}

/* ==== PAGINATION STYLING (Product Grid Only) ==== */
.cardshop-pagination {
    display: block;
    margin-top: 30px;
    text-align: center;
}

.cardshop-pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin-right: 5px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.cardshop-pagination .page-numbers.current {
    font-weight: bold;
}

.cardshop-pagination .page-numbers:last-child {
    margin-right: 0;
}

/* ==== FRONTEND SORT DROPDOWN ==== */
.cardshop-orderby-form {
    text-align: right;
    margin-bottom: 20px;
}

.cardshop-orderby-form select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}
