/* ============================================================
   Amazon Product Grid v3.0
   Flexbox layout — no empty slots ever
   2 col mobile | 3 col tablet | 4 col desktop
   ============================================================ */

/* ── Grid wrapper ─────────────────────────────────────────── */
.apg-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    --apg-gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* ── Card ─────────────────────────────────────────────────── */
/* Single unified rule — flex sizing + visual styles together */
.apg-card {
    /* Layout — 2 columns mobile */
    flex: 0 0 calc(50% - 10px) !important;
    max-width: calc(50% - 10px) !important;
    box-sizing: border-box;
    /* Visual */
    position: relative;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    display: flex;
    flex-direction: column;
    text-decoration: none !important;
    color: inherit !important;
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
    cursor: pointer;
}

@media (min-width: 768px) {
    .apg-card {
        flex: 0 0 calc(33.333% - 14px) !important;
        max-width: calc(33.333% - 14px) !important;
    }
}

@media (min-width: 1024px) {
    .apg-card {
        flex: 0 0 calc(25% - 15px) !important;
        max-width: calc(25% - 15px) !important;
    }
}

.apg-card:hover {
    box-shadow: 0 8px 28px rgba(0,0,0,0.13);
    transform: translateY(-3px);
    text-decoration: none !important;
}

/* ── Badge ────────────────────────────────────────────────── */
.apg-badge {
    position: absolute;
    top: 10px; left: 10px;
    z-index: 2;
    background: #B12704;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    line-height: 1.5;
    pointer-events: none;
}

/* ── Image ────────────────────────────────────────────────── */
.apg-image-wrap {
    width: 100%;
    background: #f7f7f7;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.apg-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    box-sizing: border-box;
    display: block;
    transition: transform 0.3s ease;
}
.apg-card:hover .apg-image { transform: scale(1.05); }
.apg-no-img {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}
.apg-no-img svg { width: 40px; height: 40px; color: #bbb; }

/* ── Body ─────────────────────────────────────────────────── */
.apg-body {
    padding: 12px 14px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 5px;
}

/* ── Category ─────────────────────────────────────────────── */
.apg-cat {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #007185;
    line-height: 1;
}

/* ── Title — color/size/weight set via inline PHP style ───── */
.apg-title {
    margin: 0 !important;
    padding: 0 !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

/* ── Pricing — bottom center ──────────────────────────────── */
.apg-pricing {
    margin-top: auto;
    padding-top: 8px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    text-align: center;
}
.apg-sale {
    font-size: 17px;
    font-weight: 700;
    color: #B12704;
    line-height: 1;
}
.apg-orig {
    font-size: 12px;
    color: #888;
    line-height: 1;
}
.apg-orig s { text-decoration: line-through; }

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 767px) {
    .apg-body  { padding: 10px 10px 12px; }
    .apg-sale  { font-size: 15px; }
    .apg-badge { font-size: 9px; padding: 2px 6px; }
}
