/* ============================================================
   Shop products (categories, active filters, cards, pagination)
   ------------------------------------------------------------
   Markup:    resources/views/frontend/shop.blade.php (section.spg)
              resources/views/frontend/partials/shop_product_grid.blade.php
              resources/views/frontend/partials/shop-pagination.blade.php
   Behaviour: public/frontend/js/shop-grid.js
   Mobile-first. Lists are spaced with padding (the site resets list margins).
   ============================================================ */

.spg {
    --spg-ink: #0f172a;
    --spg-text: #475569;
    --spg-muted: #64748b;
    --spg-line: #e6ebf3;
    --spg-soft: #f5f8fb;
    --spg-teal: #0f766e;
    --spg-teal-2: #14b8a6;
    --spg-amber: #f59e0b;
    --spg-red: #e11d48;
    padding: 40px 0 56px;
    background: linear-gradient(180deg, #f4f7fb 0%, #fff 420px);
    scroll-margin-top: 80px;
}
.spg *, .spg *::before, .spg *::after { box-sizing: border-box; }
.spg a { text-decoration: none; }
.spg :focus-visible { outline: 3px solid rgba(20, 184, 166, .45); outline-offset: 2px; border-radius: 10px; }
.spg-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ── Heading + sort ── */
.spg-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 18px; }
.spg-head__title { margin: 0; font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); font-weight: 900; line-height: 1.2; letter-spacing: -.01em; color: var(--spg-ink); }
.spg-head__info { margin: 4px 0 0; font-size: 14px; color: var(--spg-muted); }
.spg-head__info b { color: var(--spg-ink); }
.spg-dot { margin: 0 6px; color: #cbd5e1; }

.spg-sort { display: flex; align-items: center; gap: 8px; margin: 0; }
.spg-sort label { margin: 0; font-size: 13px; font-weight: 700; color: var(--spg-muted); white-space: nowrap; }
.spg-sort select {
    min-height: 42px;
    min-width: 0;
    padding: 0 36px 0 12px;
    border: 1.5px solid var(--spg-line);
    border-radius: 12px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.8' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center / 12px 8px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--spg-ink);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.spg-sort select:focus { outline: 0; border-color: var(--spg-teal-2); box-shadow: 0 0 0 4px rgba(20, 184, 166, .15); }

/* ── Category pills (scroll on phones, wrap on larger screens) ── */
.spg-cats { display: flex; gap: 8px; margin: 0 0 14px; padding: 2px 24px 6px 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.spg-cats::-webkit-scrollbar { display: none; }
.spg-cat { flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 8px 0 16px; border: 1.5px solid var(--spg-line); border-radius: 999px; background: #fff; font-size: 14px; font-weight: 700; color: var(--spg-ink) !important; white-space: nowrap; transition: border-color .2s, background-color .2s, color .2s; }
.spg-cat span { min-width: 26px; padding: 2px 8px; border-radius: 999px; background: var(--spg-soft); font-size: 12px; font-weight: 800; text-align: center; color: var(--spg-muted); }
.spg-cat:hover { border-color: var(--spg-teal-2); color: var(--spg-teal) !important; }
.spg-cat.is-active { border-color: var(--spg-teal); background: var(--spg-teal); color: #fff !important; }
.spg-cat.is-active span { background: rgba(255, 255, 255, .2); color: #fff; }
.spg-cat.is-empty { color: #94a3b8 !important; }

/* ── Active filters ── */
.spg-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 18px; padding: 10px 12px; border: 1px dashed #cfe6e2; border-radius: 14px; background: #f0fdfa; }
.spg-active__label { font-size: 13px; font-weight: 700; color: var(--spg-teal); }
.spg-active ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.spg-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 32px; padding: 0 10px; border: 1px solid #bfe3dc; border-radius: 999px; background: #fff; font-size: 13px; font-weight: 700; color: var(--spg-ink) !important; }
.spg-chip small { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--spg-muted); }
.spg-chip i { font-size: 11px; color: var(--spg-muted); }
.spg-chip:hover { border-color: var(--spg-red); }
.spg-chip:hover i { color: var(--spg-red); }
.spg-active__clear { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--spg-red) !important; }
.spg-active__clear:hover { text-decoration: underline; }

/* ── Grid ── */
.spg-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.spg-grid.is-loading { opacity: .55; pointer-events: none; transition: opacity .2s; }

/* ── Card ── */
.spg-card { position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--spg-line); border-radius: 18px; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); transition: transform .25s, box-shadow .25s, border-color .25s; }
.spg-card:hover { transform: translateY(-4px); border-color: #d3dfeb; box-shadow: 0 18px 40px rgba(15, 23, 42, .1); }

.spg-card__media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #eef2f7; }
.spg-card__img { display: block; width: 100%; height: 100%; }
.spg-card__img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .45s; }
.spg-card:hover .spg-card__img img { transform: scale(1.05); }
.spg-card__noimg { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 100%; padding: 16px; background: linear-gradient(135deg, #ecfeff, #f0fdf4); text-align: center; color: var(--spg-teal); }
.spg-card__noimg i { font-size: 34px; opacity: .65; }
.spg-card__noimg small { max-width: 90%; font-size: 13px; font-weight: 700; line-height: 1.4; color: #134e4a; }

.spg-card__type { position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: rgba(15, 23, 42, .78); font-size: 12px; font-weight: 700; color: #fff; backdrop-filter: blur(6px); }
.spg-card__type i { font-size: 11px; color: #5eead4; }
.spg-card__deal { position: absolute; top: 12px; left: 12px; padding: 5px 10px; border-radius: 999px; background: var(--spg-red); font-size: 12px; font-weight: 800; color: #fff; box-shadow: 0 6px 14px rgba(225, 29, 72, .3); }

.spg-fav { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .95); font-size: 16px; color: var(--spg-muted); box-shadow: 0 4px 12px rgba(15, 23, 42, .12); cursor: pointer; transition: transform .2s, color .2s; }
.spg-fav:hover { color: var(--spg-red); transform: scale(1.08); }
.spg-fav.is-active { color: var(--spg-red); }
.spg-fav.is-busy { opacity: .6; pointer-events: none; }
.spg-fav.is-pop i { animation: spg-pop .35s ease; }
@keyframes spg-pop { 50% { transform: scale(1.35); } }

.spg-card__body { display: flex; flex: 1; flex-direction: column; padding: 16px 16px 14px; }
.spg-card__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.spg-card__cat { overflow: hidden; font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; text-overflow: ellipsis; white-space: nowrap; color: var(--spg-teal) !important; }
a.spg-card__cat:hover { text-decoration: underline; }
.spg-card__ver { flex-shrink: 0; padding: 2px 8px; border-radius: 6px; background: var(--spg-soft); font-size: 11.5px; font-weight: 700; color: var(--spg-muted); }

.spg-card__title { display: -webkit-box; min-height: calc(1.4em * 2); margin: 8px 0 8px; overflow: hidden; font-size: 16.5px; font-weight: 800; line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.spg-card__title a { color: var(--spg-ink) !important; }
.spg-card__title a::after { content: ""; position: absolute; inset: 0; z-index: 0; }
.spg-card__title a:hover { color: var(--spg-teal) !important; }
.spg-fav, .spg-card__cat, .spg-card__facts a, .spg-card__actions, .spg-card__type, .spg-card__deal { z-index: 1; }
.spg-card__cat, .spg-card__facts a, .spg-card__actions { position: relative; }

.spg-card__rating { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-height: 22px; font-size: 13px; color: var(--spg-muted); }
.spg-stars { display: inline-flex; gap: 1px; font-size: 13px; color: var(--spg-amber); }
.spg-card__rating b { color: var(--spg-ink); }
.spg-card__new { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #94a3b8; }

.spg-card__facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 10px 0 0; list-style: none; font-size: 13px; color: var(--spg-muted); }
.spg-card__facts:empty { display: none; }
.spg-card__facts i { margin-right: 4px; font-size: 12px; }
.spg-card__facts a { font-weight: 700; color: var(--spg-teal) !important; }
.spg-card__facts a:hover { text-decoration: underline; }

.spg-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 14px; }
.spg-card__facts + .spg-card__foot, .spg-card__rating + .spg-card__foot { margin-top: auto; }
.spg-card__body > .spg-card__foot { border-top: 1px dashed var(--spg-line); margin-top: auto; }
.spg-card__body > .spg-card__facts { margin-bottom: 14px; }
.spg-card__body > .spg-card__rating { margin-bottom: 0; }

.spg-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-width: 0; }
.spg-price b { font-size: 20px; font-weight: 900; line-height: 1.2; color: var(--spg-ink); white-space: nowrap; }
.spg-price del { font-size: 13.5px; color: #94a3b8; white-space: nowrap; }
.spg-price small { flex-basis: 100%; font-size: 12px; font-weight: 700; color: #059669; }

.spg-card__actions { display: flex; flex-shrink: 0; gap: 6px; }
.spg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 14px; border: 1.5px solid transparent; border-radius: 12px; font: inherit; font-size: 14px; font-weight: 800; white-space: nowrap; cursor: pointer; transition: background-color .2s, color .2s, border-color .2s; }
.spg-btn--cart { background: var(--spg-teal); color: #fff !important; }
.spg-btn--cart:hover { background: #115e59; }
.spg-btn--cart:disabled { opacity: .7; cursor: wait; }
.spg-btn--view { width: 42px; padding: 0; border-color: var(--spg-line); background: #fff; color: var(--spg-ink) !important; }
.spg-btn--view:hover { border-color: var(--spg-teal); color: var(--spg-teal) !important; }
.spg-btn--primary { background: var(--spg-teal); color: #fff !important; }
.spg-btn--primary:hover { background: #115e59; }
.spg-btn--ghost { border-color: #d6dfeb; background: #fff; color: var(--spg-ink) !important; }
.spg-btn--ghost:hover { border-color: var(--spg-teal); color: var(--spg-teal) !important; }

/* ── Empty state ── */
.spg-empty { grid-column: 1 / -1; padding: 44px 20px; border: 1.5px dashed #cbd5e1; border-radius: 20px; background: #fff; text-align: center; }
.spg-empty__icon { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 14px; border-radius: 18px; background: #f0fdfa; font-size: 24px; color: var(--spg-teal); }
.spg-empty h3 { margin: 0 0 6px; font-size: 20px; font-weight: 800; color: var(--spg-ink); }
.spg-empty p { max-width: 460px; margin: 0 auto 18px; font-size: 15px; line-height: 1.6; color: var(--spg-muted); }
.spg-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ── Pagination ── */
.spg-pages { margin-top: 32px; }
.spg-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.spg-pager__list { display: none; gap: 6px; margin: 0; padding: 0; list-style: none; }
.spg-pager__step, .spg-pager__num { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 0 14px; border: 1.5px solid var(--spg-line); border-radius: 12px; background: #fff; font-size: 14px; font-weight: 800; color: var(--spg-ink) !important; transition: border-color .2s, color .2s, background-color .2s; }
.spg-pager__num { padding: 0 6px; }
a.spg-pager__step:hover, a.spg-pager__num:hover { border-color: var(--spg-teal); color: var(--spg-teal) !important; }
.spg-pager__num.is-current { border-color: var(--spg-teal); background: var(--spg-teal); color: #fff !important; }
.spg-pager__step.is-disabled { color: #cbd5e1 !important; cursor: not-allowed; }
.spg-pager__gap { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: #94a3b8; }
.spg-pager__mobile { font-size: 14px; font-weight: 700; color: var(--spg-muted); }

/* ── ≥576px ── */
@media (min-width: 576px) {
    .spg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
    .spg-card__body { padding: 16px 16px 14px; }
}

/* ── ≥768px ── */
@media (min-width: 768px) {
    .spg { padding: 56px 0 72px; }
    .spg-cats { flex-wrap: wrap; margin: 0 0 16px; padding: 0; overflow: visible; -webkit-mask-image: none; mask-image: none; }
    .spg-pager { justify-content: center; }
    .spg-pager__list { display: flex; }
    .spg-pager__mobile { display: none; }
}

/* ── ≥992px ── */
@media (min-width: 992px) {
    .spg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
}

/* ── ≥1200px: roomier cards ── */
@media (min-width: 1200px) {
    .spg-card__body { padding: 18px 18px 16px; }
    .spg-card__title { font-size: 17px; }
}

/* small phones: keep the price and buttons on one line */
@media (max-width: 339.98px) {
    .spg-btn--cart span { display: none; }
    .spg-btn--cart { width: 42px; padding: 0; }
    .spg-sort label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .spg *, .spg *::before, .spg *::after { transition: none !important; animation: none !important; }
    .spg-card:hover { transform: none; }
}
