/**
 * WIZ v2: Product Grid — Layout CSS
 * Grid layout + card container styling. Atom styling is in each atom's style.css.
 */

/* ================================================================
   Skeleton Loader
   ================================================================ */
@keyframes wiz-v2-skeleton-shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.wiz-v2-skeleton-loader {
    position: relative;
    overflow: hidden;
    background-color: #f5f7fa;
    pointer-events: none;
    border-radius: 4px;
}

.wiz-v2-skeleton-loader::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f5f7fa 0%, #e8ecf1 20%, #f5f7fa 40%, #f5f7fa 100%);
    background-size: 1000px 100%;
    animation: wiz-v2-skeleton-shimmer 2s ease-in-out infinite;
    z-index: 1;
}

/* Hide content inside skeleton elements.
 * `transition: none` is required: elements like .wiz-atc__button declare
 * `transition: all 0.3s`, which includes `visibility`. Without this override
 * the visibility change is delayed by 0.3s, making ATC/wishlist appear to
 * disappear late when the skeleton kicks in. */
.wiz-v2-skeleton-loader * {
    transition: none !important;
}

/* ================================================================
   Grid Layout
   ================================================================ */
.wiz-grid {
    display: grid;
    grid-template-columns: repeat(var(--wiz-grid-cols, 4), 1fr);
    gap: var(--wiz-grid-gap, 16px);
    width: 100%;
}

/* ================================================================
   Card Container
   ================================================================ */
/* ================================================================
   Card Wrapper (for stack layers)
   ================================================================ */
.product-listing-card-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

/* Stack layers — positioned behind the card */
.product-stack-layer {
    position: absolute;
    top: 7px;
    left: -7px;
    background-color: #f7f8f8;
    border: 1px solid #e0e0e0;
    pointer-events: none;
    box-sizing: border-box;
    width: 100%;
    height: 97%;
}

.product-stack-layer-2 {
    top: 14px;
    left: -13px;
    background-color: #eef1f7;
    border: 1px solid #e0e0e0;
    height: 94%;
}

/* Card sits on top of stack layers */
.product-listing-card-wrapper .wiz-grid__card {
    position: relative;
}

.wiz-grid__card {
    display: flex;
    flex-direction: column;
    background: var(--wiz-card-bg, var(--wiz-color-background, #fff));
    border-radius: var(--wiz-card-radius, 0);
    overflow: hidden;
    transition: box-shadow var(--wiz-transition-normal), transform var(--wiz-transition-normal);
}

.wiz-grid__card:hover {
    box-shadow: var(--wiz-card-hover-shadow, none);
    transform: var(--wiz-card-hover-transform, none);
}

/* Card body: everything below the image */
.wiz-grid__card-body {
    display: flex;
    flex-direction: column;
    gap: var(--wiz-card-inner-gap, 8px);
    padding: var(--wiz-card-padding, 8px 0);
    flex: 1;
}

/* Push ATC to bottom of card */
.wiz-grid__card-body > .wiz-atc {
    margin-top: auto;
}

/* ================================================================
   Image Wrapper + QuickView Overlay
   ================================================================ */
.wiz-grid__card-image-wrap {
    position: relative;
    overflow: hidden;
}

.wiz-grid__card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: var(--wiz-space-sm, 8px);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.3));
    opacity: 0;
    transition: opacity var(--wiz-transition-normal);
    pointer-events: none;
}

.wiz-grid__card-image-wrap:hover .wiz-grid__card-overlay {
    opacity: 1;
    pointer-events: auto;
}

.wiz-grid__quickview-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--wiz-color-background, #fff);
    color: var(--wiz-color-text, #333);
    border: none;
    border-radius: var(--wiz-radius-full, 999px);
    font-family: var(--wiz-font-family);
    font-size: var(--wiz-font-size-sm, 12px);
    font-weight: var(--wiz-font-weight-medium, 500);
    cursor: pointer;
    box-shadow: var(--wiz-shadow-md);
    transition: background var(--wiz-transition-fast), box-shadow var(--wiz-transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.wiz-grid__quickview-chip:hover {
    background: var(--wiz-color-surface, #f5f5f5);
    box-shadow: var(--wiz-shadow-lg);
}

.wiz-grid__quickview-chip svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ================================================================
   Empty State — used by WizProductGridWidget::render_empty_state
   AND by product-listing-ajax.php's empty branch. Both render the
   same class structure so styling lives in one place.
   ================================================================ */
.wiz-grid--empty {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    padding: 40px 20px;
    grid-column: 1 / -1;
    font-family: var(--wiz-font-family, inherit);
}

.wiz-grid__empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    max-width: 480px;
    width: 100%;
}

.wiz-grid__empty-image {
    max-width: 300px;
    width: 200px;
    height: auto;
    display: block;
    margin-bottom: 4px;
}

.wiz-grid__empty-title {
    font-size: 18px;
    font-weight: 700;
    color: #111;
    margin: 0;
    line-height: 1.3;
}

.wiz-grid__empty-desc {
    font-size: 15px;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
}

.wiz-grid__empty-btn {
    display: inline-block;
    padding: 10px 24px;
    margin-top: 8px;
    background: var(--primary, #000);
    color: var(--primary-text, #fff);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    text-transform: capitalize;
    border-radius: 4px;
    transition: opacity 0.15s ease;
}

.wiz-grid__empty-btn:hover {
    opacity: 0.85;
}

/* Legacy — kept in case any cached markup still uses it */
.wiz-grid__empty-text {
    color: var(--wiz-color-text-muted);
    font-family: var(--wiz-font-family);
    font-size: var(--wiz-font-size-md);
    text-align: center;
}

/* ================================================================
   SKU
   ================================================================ */
.wiz-sku {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.wiz-grid__product-count {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    margin-bottom: 16px;
    width: fit-content;
}