/* AP Wholesale — Product Cards
   Hybrid grid + list view (Style C)
   Version: 1.0.15 */

/* Base grid — applies everywhere (dashboard panels, catalogue, search) */
.ap-ws-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

/* Catalogue view overrides column width slightly larger */
.ap-ws-catalogue--grid .ap-ws-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* ── Product highlight: Sale (soft red) / Monthly Special (soft yellow) ───── */
.ap-ws-product-card--on-sale  { background: #fdf0f0 !important; border-color: #f5c6c6 !important; }
.ap-ws-product-card--monthly  { background: #fdfbec !important; border-color: #f0e68c !important; }
/* ─────────────────────────────────────────────────────────────────────────── */

.ap-ws-product-card {
    background: var(--ws-card-bg);
    border: 1px solid var(--ws-border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%; /* Ensure all cards in a row stretch to the same height */
}

/* Reset theme margins on all direct card children — gap: 8px is the only spacing */
.ap-ws-product-card > * { margin-top: 0 !important; margin-bottom: 0 !important; }

/* Image container stabilization */
.ap-ws-product-card > a:first-child {
    display: block;
    height: 180px;
    background: #fbfbfb;
    border-radius: 4px;
    overflow: hidden;
}

.ap-ws-product-card .ap-ws-product-card__image,
.ap-ws-product-card a .ap-ws-product-card__image { 
    width: 100% !important; 
    height: 100% !important; 
    object-fit: contain !important; 
}

.ap-ws-product-card__name      {
    font-weight: 600;
    font-size: 14px;
    color: var(--ws-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    flex-grow: 1;
}

.ap-ws-product-card__sku       { font-size: 11px; color: var(--ws-muted); }

.ap-ws-product-card__prices    { display: flex; flex-direction: column; gap: 2px; }

.ap-ws-product-card__price-row { display: flex; justify-content: space-between; font-size: 13px; }
.ap-ws-product-card__price-row.regular  { color: var(--ws-muted); text-decoration: line-through; }
.ap-ws-product-card__price-row.your     { color: var(--ws-text); font-weight: 600; }
.ap-ws-product-card__price-row.box      { color: var(--ws-accent); font-weight: 600; }

/* Box lot and Add to Tray area stabilization */
.ap-ws-box-lot-wrap {
    margin-top: auto; /* Pin add button to bottom of card */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.ap-ws-product-card__add       { display: flex; gap: 8px; }
.ap-ws-product-card__qty       { width: 56px; border: 1px solid var(--ws-border); border-radius: 4px; padding: 5px; text-align: center;
                                  /* Override theme CSS that may make number text invisible */
                                  color: #1a202c !important; background-color: #ffffff !important;
                                  -webkit-text-fill-color: #1a202c !important; opacity: 1 !important; }
.ap-ws-product-card__btn       { flex: 1; background: var(--ws-accent); color: #fff; border: none; border-radius: 4px; padding: 6px 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.ap-ws-product-card__btn:hover { filter: brightness(1.1); }

.ap-ws-catalogue--list .ap-ws-product-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.ap-ws-product-list-row {
    background: var(--ws-card-bg);
    border: 1px solid var(--ws-border);
    border-radius: 6px;
    display: grid;
    grid-template-columns: 56px 1fr 180px 220px 180px;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
}
.ap-ws-product-list-row__image  { width: 48px; height: 48px; object-fit: contain; }
.ap-ws-product-list-row__name   { font-weight: 600; font-size: 14px; }
.ap-ws-product-list-row__sku    { font-size: 11px; color: var(--ws-muted); }
.ap-ws-product-list-row__prices { display: flex; flex-direction: column; gap: 2px; }
.ap-ws-product-list-row__price-row { font-size: 12px; display: flex; justify-content: space-between; }

.ap-ws-view-toggle { display: flex; gap: 8px; margin-bottom: 16px; }

.ap-ws-sort-toggle { display: flex; gap: 6px; margin-left: auto; }
.ap-ws-sort-toggle button,
.ap-ws-sort-toggle .ap-ws-sort-btn {
    padding: 5px 12px !important;
    border: 1px solid #b0b8c1 !important;
    border-radius: 4px !important;
    background: #eef0f2 !important;
    color: #4a5568 !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    display: inline-block;
}
.ap-ws-sort-toggle button:hover:not(.active),
.ap-ws-sort-toggle .ap-ws-sort-btn:hover:not(.active) {
    background: #e2e6ea !important;
    border-color: #8a929a !important;
    color: #4a5568 !important;
}
.ap-ws-sort-toggle button.active,
.ap-ws-sort-toggle .ap-ws-sort-btn.active {
    background: var(--ws-accent) !important;
    color: #fff !important;
    border-color: var(--ws-accent) !important;
}
.ap-ws-view-toggle button {
    padding: 5px 12px;
    border: 1px solid #b0b8c1;
    border-radius: 4px;
    background: #eef0f2;
    color: #4a5568;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}
.ap-ws-view-toggle button:hover:not(.active) {
    background: #e2e6ea;
    border-color: #8a929a;
}
.ap-ws-view-toggle button.active {
    background: var(--ws-accent);
    color: #fff;
    border-color: var(--ws-accent);
}

/* Box lot toggle buttons */
.ap-ws-box-toggle { display: flex; gap: 4px; margin-bottom: 6px; }
.ap-ws-box-toggle__btn {
    padding: 3px 10px;
    border: 1px solid #b0b8c1;
    border-radius: 4px;
    background: #eef0f2;
    color: #4a5568;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}

.ap-ws-box-toggle__btn:hover:not(.active):not(:disabled) {
    background: #e2e6ea;
    border-color: #8a929a;
}
.ap-ws-box-toggle__btn.active {
    background: var(--ws-accent);
    color: #fff;
    border-color: var(--ws-accent);
}
.ap-ws-box-toggle__btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
