/* =============================================================================
   Anghang Pinoy — Shop Page Styles
   Loaded only on WooCommerce pages (is_woocommerce())
   Depends on main.css (design tokens already defined there)
   ============================================================================= */

/* ── 1. Page layout ──────────────────────────────────────────────────────────── */

.ap-shop {
    background: var(--color-bg, #ffffff);
    padding-bottom: 80px;
}

/* ── 2. Breadcrumb ───────────────────────────────────────────────────────────── */

.ap-shop__breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0 0;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 14px;
    color: var(--color-muted, #6b6b6b);
}

.ap-shop__breadcrumb a {
    color: var(--color-muted, #6b6b6b);
    text-decoration: none;
    transition: color 0.15s ease;
}

.ap-shop__breadcrumb a:hover {
    color: var(--color-primary, #c1272d);
}

.ap-shop__breadcrumb-sep {
    opacity: 0.5;
}

/* ── 3. Page header ──────────────────────────────────────────────────────────── */

.ap-shop__header {
    padding: 32px 0 24px;
    text-align: center;
}

/* ── 4. Controls row ─────────────────────────────────────────────────────────── */

.ap-shop__controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

/* ── Filter chips ────────────────────────────────────────────────────────────── */

.ap-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.ap-filter-chip {
    display: inline-flex;
    align-items: center;
    height: 38px;
    padding: 0 17px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #ffffff;
    color: var(--color-text, #2d2d2d);
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    cursor: pointer;
}

.ap-filter-chip--active {
    background: var(--color-primary, #c1272d);
    border-color: var(--color-primary, #c1272d);
    color: #ffffff;
}

.ap-filter-chip:hover:not(.ap-filter-chip--active) {
    background: var(--color-bg-alt, #f8f5f2);
    border-color: rgba(0, 0, 0, 0.15);
}

/* ── Sort row (right side) ───────────────────────────────────────────────────── */

.ap-shop__sort-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ap-shop__sort {
    height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-sm, 8px);
    background: #ffffff;
    color: var(--color-text, #2d2d2d);
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-size: 14px;
    font-weight: 500;
    min-width: 200px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%236b6b6b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.ap-shop__sort:focus {
    outline: 2px solid var(--color-primary, #c1272d);
    outline-offset: 2px;
    border-color: var(--color-primary, #c1272d);
}

/* ── View toggle ─────────────────────────────────────────────────────────────── */

.ap-shop__view-toggle {
    display: flex;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-sm, 8px);
    overflow: hidden;
}

.ap-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: #ffffff;
    color: var(--color-muted, #6b6b6b);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ap-view-btn + .ap-view-btn {
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

.ap-view-btn.is-active {
    background: var(--color-primary, #c1272d);
    color: #ffffff;
}

.ap-view-btn:hover:not(.is-active) {
    background: var(--color-bg-alt, #f8f5f2);
    color: var(--color-text, #2d2d2d);
}

/* ── 5. Product grid ─────────────────────────────────────────────────────────── */

.ap-shop__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

/* List view variant */
.ap-shop__grid.is-list {
    grid-template-columns: 1fr;
}

.ap-shop__grid.is-list .ap-shop-card {
    flex-direction: row;
}

.ap-shop__grid.is-list .ap-shop-card__image {
    width: 220px;
    height: auto;
    flex-shrink: 0;
}

.ap-shop__grid.is-list .ap-shop-card__body {
    flex: 1;
}

/* ── 6. Product card ─────────────────────────────────────────────────────────── */

.ap-shop-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ap-shop-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    transform: translateY(-2px);
}

/* Card image area */
.ap-shop-card__image {
    position: relative;
    display: block;
    height: 300px;
    background: var(--color-bg-alt, #f8f5f2);
    overflow: hidden;
    flex-shrink: 0;
}

.ap-shop-card__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
}

.ap-shop-card:hover .ap-shop-card__img {
    transform: scale(1.04);
}

/* Card body */
.ap-shop-card__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    flex: 1;
}

/* Product name */
.ap-shop-card__name {
    margin: 0;
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text, #2d2d2d);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ap-shop-card__name a {
    color: inherit;
    text-decoration: none;
}

.ap-shop-card__name a:hover {
    color: var(--color-primary, #c1272d);
}

/* ── Badges ───────────────────────────────────────────────────────────────────── */

.ap-shop-card__badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}

.ap-badge-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 16px;
    white-space: nowrap;
}

/* ── Stars ────────────────────────────────────────────────────────────────────── */

.ap-card-stars {
    display: flex;
    align-items: center;
    gap: 3px;
}

.ap-card-stars svg {
    display: block;
    flex-shrink: 0;
}

.ap-card-stars__count {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 14px;
    color: var(--color-muted, #6b6b6b);
    margin-left: 2px;
}

/* ── Pricing ──────────────────────────────────────────────────────────────────── */

.ap-shop-card__pricing {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.ap-shop-card__price {
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary, #c1272d);
}

.ap-shop-card__price--was {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 14px;
    color: var(--color-muted, #6b6b6b);
    text-decoration: line-through;
}

/* Override WooCommerce price tag styles */
.ap-shop-card__price .woocommerce-Price-amount,
.ap-shop-card__price bdi {
    font-size: inherit;
    color: inherit;
}

.ap-shop-card__price--was .woocommerce-Price-amount,
.ap-shop-card__price--was bdi {
    font-size: inherit;
    color: inherit;
}

/* ── Add to Cart button ───────────────────────────────────────────────────────── */

.ap-shop-card__atc {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 41px;
    margin-top: auto;
    padding: 0 16px;
    border-radius: var(--radius-sm, 8px);
    background: var(--color-primary, #c1272d);
    color: #ffffff;
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.ap-shop-card__atc:hover {
    background: #a51f24;
    color: #ffffff;
    transform: translateY(-1px);
}

.ap-shop-card__atc:active {
    transform: translateY(0);
}

.ap-shop-card__atc svg {
    flex-shrink: 0;
}

/* Out of stock label */
.ap-shop-card__out-of-stock {
    display: block;
    text-align: center;
    padding: 10px 16px;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid rgba(0, 0, 0, 0.12);
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 14px;
    color: var(--color-muted, #6b6b6b);
    margin-top: auto;
}

/* ── 7. Pagination ───────────────────────────────────────────────────────────── */

.ap-shop-pagination {
    margin-top: 48px;
}

.ap-shop-pagination ul {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.ap-shop-pagination li a,
.ap-shop-pagination li span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #ffffff;
    color: var(--color-text, #2d2d2d);
    font-family: var(--font-heading, 'Poppins', sans-serif);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ap-shop-pagination li a:hover {
    background: var(--color-bg-alt, #f8f5f2);
    border-color: rgba(0, 0, 0, 0.15);
}

.ap-shop-pagination li span.current {
    background: var(--color-primary, #c1272d);
    border-color: var(--color-primary, #c1272d);
    color: #ffffff;
}

.ap-shop-pagination li span.dots {
    background: transparent;
    border-color: transparent;
    color: var(--color-muted, #6b6b6b);
    width: auto;
    cursor: default;
}

/* ── 8. Empty state ──────────────────────────────────────────────────────────── */

.ap-shop__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 80px 0;
    text-align: center;
}

.ap-shop__empty-msg {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 16px;
    color: var(--color-muted, #6b6b6b);
    margin: 0;
}

/* ── 9. Responsive: Tablet (768–1024px) ──────────────────────────────────────── */

@media (max-width: 1024px) {
    .ap-shop__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ap-shop__grid.is-list .ap-shop-card {
        flex-direction: column;
    }

    .ap-shop__grid.is-list .ap-shop-card__image {
        width: 100%;
        height: 260px;
    }
}

/* ── 10. Responsive: Mobile (≤768px) ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .ap-shop {
        padding-bottom: 48px;
    }

    .ap-shop__controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .ap-filter-chips {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .ap-shop__sort-row {
        width: 100%;
        gap: 10px;
    }

    .ap-shop__sort {
        flex: 1;
        min-width: 0;
    }

    .ap-shop__grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .ap-shop__grid.is-list .ap-shop-card {
        flex-direction: column;
    }

    .ap-shop__grid.is-list .ap-shop-card__image {
        width: 100%;
        height: 240px;
    }

    .ap-shop-card__image {
        height: 240px;
    }

    .ap-shop__header {
        padding: 24px 0 16px;
    }

    .ap-shop-pagination {
        margin-top: 32px;
    }

    .ap-shop-pagination li a,
    .ap-shop-pagination li span {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

/* ── 11. WooCommerce AJAX loading indicator ──────────────────────────────────── */

.ap-shop-card__atc.loading {
    opacity: 0.7;
    pointer-events: none;
}

.ap-shop-card__atc.added {
    background: #2d8b4e;
}

.ap-shop-card__atc.added:hover {
    background: #236e3d;
}

/* ── 12. Accessibility ───────────────────────────────────────────────────────── */

.ap-filter-chip:focus-visible,
.ap-view-btn:focus-visible,
.ap-shop-card__atc:focus-visible {
    outline: 2px solid var(--color-primary, #c1272d);
    outline-offset: 2px;
}

.ap-shop-card__image:focus-visible {
    outline: 2px solid var(--color-primary, #c1272d);
    outline-offset: -2px;
}
