/* language: CSS, file: assets/css/shop.css, runtime: browser
   Category cards, product cards, product detail page, stat frames and the admin
   switches that go with them. Loaded after nav.css so tokens are available. */

/* ============================================================
   CATEGORY CARD — image on top, text underneath
   ============================================================ */
.cc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.cc-card {
    display: flex; flex-direction: column;
    border: 1px solid var(--line); border-radius: 16px;
    background: var(--surface); overflow: hidden;
    text-decoration: none; color: inherit;
    transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.cc-card:hover {
    transform: translateY(-2px);
    border-color: var(--sky-l);
    box-shadow: 0 16px 34px -22px rgba(58, 167, 232, .65);
}

/* The recommended art is 1640x500; keeping the natural ratio means whatever the
   admin uploads is shown whole instead of being cropped to a square. */
.cc-art {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1640 / 500;
    background: var(--bg-sky);
    overflow: hidden;
}
.cc-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-art-empty {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    font-size: 30px; font-weight: 800; color: var(--sky);
    background: linear-gradient(140deg, var(--sky-l), var(--sky));
    -webkit-text-fill-color: #fff;
}

.cc-body { padding: 11px 14px 13px; display: grid; gap: 5px; }
.cc-name {
    font-size: 14.5px; font-weight: 700; color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cc-meta {
    display: flex; align-items: center; gap: 7px;
    font-size: 11.5px; color: var(--ink-3);
}
.cc-meta em { font-style: normal; font-weight: 700; color: var(--sky-d); }
.cc-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

/* sub-category cards are a touch smaller than main ones */
.cc-grid-sub { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cc-sub .cc-art { aspect-ratio: 1640 / 560; }
.cc-sub .cc-name { font-size: 13.5px; }

/* ============================================================
   PRODUCT CARD
   ============================================================ */
.pc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}
.pc-card {
    display: flex; flex-direction: column;
    border: 1px solid var(--line); border-radius: 16px;
    background: var(--surface); overflow: hidden;
    transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.pc-card:hover {
    transform: translateY(-2px);
    border-color: var(--sky-l);
    box-shadow: 0 16px 34px -24px rgba(58, 167, 232, .6);
}
.pc-card.is-out { opacity: .82; }

.pc-art {
    position: relative; display: block;
    aspect-ratio: 1 / 1;
    background: var(--bg-sky); overflow: hidden;
}
.pc-art img { width: 100%; height: 100%; object-fit: contain; padding: 12px; display: block; }
.pc-art-empty {
    position: absolute; inset: 0; display: grid; place-items: center;
    font-size: 34px; font-weight: 800; color: #fff;
    background: linear-gradient(140deg, var(--sky-l), var(--sky));
}

.pc-tag {
    position: absolute; font-size: 9.5px; font-weight: 800; letter-spacing: .04em;
    padding: 3px 8px; border-radius: 999px;
}
.pc-hot { top: 8px; left: 8px; background: #ffe9e9; color: #d9534f; border: 1px solid #f5c7c7; }
.pc-off { top: 8px; right: 8px; background: #fff3d6; color: #a06f00; border: 1px solid #f0dba8; }
/* ป้ายโปรบนการ์ด: "ลดแรง 7 วันเท่านั้น" / "จำกัด 10 คนแรกเท่านั้น" */
.pc-promo {
    left: 8px; bottom: 8px; max-width: calc(100% - 16px);
    background: linear-gradient(135deg, #ff5a3c, #e0341c); color: #fff;
    box-shadow: 0 3px 10px rgba(224, 52, 28, .35);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-promo-line {
    font-size: 11.5px; font-weight: 700; color: #d23418;
    background: #fff1ee; border: 1px solid #ffd2c8;
    border-radius: 7px; padding: 4px 8px; margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-out {
    left: 50%; top: 50%; transform: translate(-50%, -50%);
    background: rgba(22, 35, 46, .8); color: #fff;
}

.pc-body { display: flex; flex-direction: column; gap: 6px; padding: 11px 13px 13px; flex: 1 1 auto; }
.pc-name {
    font-size: 13.5px; font-weight: 700; color: var(--ink);
    text-decoration: none; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pc-name:hover { color: var(--sky-d); }
.pc-desc {
    margin: 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.pc-price { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; margin-top: auto; }
.pc-price-now { font-size: 17px; font-weight: 800; color: var(--sky-d); letter-spacing: -.01em; }
.pc-price-old { font-size: 12px; color: var(--ink-3); text-decoration: line-through; }
.pc-price-note { font-size: 10.5px; color: var(--ink-3); margin-top: -2px; }

.pc-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-top: 6px; padding-top: 9px;
    border-top: 1px solid var(--line);
}
.pc-stock { font-size: 11.5px; color: var(--ink-3); }
.pc-stock.is-zero { color: #d9534f; font-weight: 600; }
.pc-buy { flex: 0 0 auto; }
.pc-buy[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* TOP 10 keeps the rank badge beside the normal card */
.hm-top-wrap { position: relative; }
.hm-top-wrap .hm-rank {
    position: absolute; top: 8px; left: 8px; z-index: 2;
    width: 24px; height: 24px; border-radius: 8px;
    display: grid; place-items: center;
    background: var(--sky); color: #fff;
    font-size: 12px; font-weight: 800;
    box-shadow: 0 4px 10px -3px rgba(31, 134, 198, .7);
}

/* ============================================================
   SEARCH BAR (catalogue)
   ============================================================ */
.ct-searchbar {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 7px 7px 14px; margin-bottom: 18px;
    border: 1px solid var(--line-strong); border-radius: 999px;
    background: var(--surface);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.ct-searchbar:focus-within {
    border-color: var(--sky);
    box-shadow: 0 0 0 3px rgba(58, 167, 232, .14);
}
.ct-searchbar svg { width: 17px; height: 17px; color: var(--ink-3); flex: 0 0 auto; }
.ct-searchbar input {
    flex: 1 1 auto; min-width: 0;
    border: 0; background: none; outline: none;
    font: inherit; font-size: 14px; color: var(--ink);
    padding: 6px 0;
}

.ct-group { margin-top: 22px; }
.ct-group:first-of-type { margin-top: 8px; }

/* ============================================================
   PRODUCT DETAIL
   ============================================================ */
.pd-layout {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 26px;
    align-items: start;
}
@media (max-width: 820px) {
    .pd-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

.pd-art {
    position: relative;
    border: 1px solid var(--line); border-radius: 18px;
    background: var(--bg-sky); overflow: hidden;
    aspect-ratio: 1 / 1;
    display: grid; place-items: center;
}
.pd-art img { width: 100%; height: 100%; object-fit: contain; padding: 20px; }
.pd-art-empty { font-size: 64px; font-weight: 800; color: #fff; }

.pd-info { display: grid; gap: 12px; align-content: start; }
.pd-name { margin: 0; font-size: 22px; line-height: 1.3; letter-spacing: -.01em; }
.pd-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.pd-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pd-price-now { font-size: 26px; font-weight: 800; color: var(--sky-d); letter-spacing: -.02em; }
.pd-price-old { font-size: 14px; color: var(--ink-3); text-decoration: line-through; }
.pd-price-off {
    font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 999px;
    background: #fff3d6; color: #a06f00; border: 1px solid #f0dba8;
}
.pd-stock { margin: 0; font-size: 12.5px; color: var(--ok); font-weight: 600; }
.pd-stock.is-zero { color: #d9534f; }
.pd-desc {
    font-size: 13px; color: var(--ink-2); line-height: 1.75;
    white-space: pre-wrap; padding: 12px 14px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
}

.pd-form { display: grid; gap: 10px; margin-top: 4px; }
.pd-variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.pd-variant { position: relative; cursor: pointer; }
.pd-variant input {
    position: absolute; opacity: 0; width: 0; height: 0;
}
.pd-variant-body {
    display: grid; gap: 2px;
    padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 12px;
    background: var(--surface);
    transition: border-color .14s var(--ease), background .14s var(--ease);
}
.pd-variant-body b { font-size: 13px; color: var(--ink); font-weight: 600; }
.pd-variant-body small { font-size: 12px; color: var(--sky-d); font-weight: 700; }
.pd-variant input:checked + .pd-variant-body {
    border-color: var(--sky); background: var(--bg-sky);
    box-shadow: 0 0 0 2px rgba(58, 167, 232, .16);
}
.pd-variant input:focus-visible + .pd-variant-body { outline: 2px solid var(--sky); outline-offset: 2px; }

.pd-qty {
    display: inline-flex; align-items: center; gap: 2px;
    border: 1px solid var(--line-strong); border-radius: 12px;
    background: var(--surface); width: fit-content; overflow: hidden;
}
.pd-qty button {
    width: 38px; height: 40px; border: 0; background: none; cursor: pointer;
    font-size: 17px; color: var(--ink-2); line-height: 1;
}
.pd-qty button:hover { background: var(--bg-sky); color: var(--sky-d); }
.pd-qty input {
    width: 54px; height: 40px; border: 0; background: none; outline: none;
    text-align: center; font: inherit; font-size: 14px; font-weight: 700;
    -moz-appearance: textfield;
}
.pd-qty input::-webkit-outer-spin-button,
.pd-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pd-total {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 15px; margin-top: 2px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
}
.pd-total span { font-size: 12.5px; color: var(--ink-2); }
.pd-total b { font-size: 20px; font-weight: 800; color: var(--sky-d); letter-spacing: -.01em; }
.pd-hint { margin: 0; font-size: 11.5px; color: var(--ink-3); text-align: center; }

/* ============================================================
   HOME STAT FRAMES
   ============================================================ */
.hm-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 22px 16px; }

.hm-stat {
    position: relative;
    display: grid; justify-items: center; gap: 5px;
    padding: 16px 12px 15px;
    border: 1px solid var(--line); border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(58, 167, 232, .06), transparent 62%),
        var(--surface);
    overflow: hidden;
    transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s var(--ease);
}
/* the accent bar reads as the frame's top edge, one colour per metric */
.hm-stat::before {
    content: ""; position: absolute; inset: 0 0 auto; height: 3px;
    background: var(--sky);
}
.hm-stat-stock::before { background: #17a673; }
.hm-stat-sold::before { background: #d98514; }
.hm-stat:hover {
    transform: translateY(-2px);
    border-color: var(--sky-l);
    box-shadow: 0 16px 34px -24px rgba(58, 167, 232, .6);
}

.hm-stat-ico {
    display: grid; place-items: center;
    width: 34px; height: 34px; border-radius: 11px;
    background: var(--bg-sky); color: var(--sky-d);
    margin-bottom: 2px;
}
.hm-stat-stock .hm-stat-ico { background: #e7f7f0; color: #12855a; }
.hm-stat-sold .hm-stat-ico { background: #fdf3e3; color: #a9660c; }
.hm-stat-ico svg { width: 18px; height: 18px; }

.hm-stat b {
    display: block; font-size: 26px; font-weight: 800;
    color: var(--ink); letter-spacing: -.02em; line-height: 1.15;
}
.hm-stat-k { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }

html.theme-dark .hm-stat-stock .hm-stat-ico { background: #12301f; color: #4ecb8b; }
html.theme-dark .hm-stat-sold .hm-stat-ico { background: #33260f; color: #f0b95a; }
html.theme-dark .hm-stat-ico { background: #16283a; color: #7ec3ef; }

@media (max-width: 620px) {
    .hm-stats-grid { gap: 9px; padding: 16px 12px; }
    .hm-stat { padding: 13px 8px; border-radius: 14px; }
    .hm-stat b { font-size: 20px; }
    .hm-stat-k { font-size: 10.5px; }
    .hm-stat-ico { width: 30px; height: 30px; border-radius: 10px; }
    .hm-stat-ico svg { width: 16px; height: 16px; }
    .cc-grid, .cc-grid-sub { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .cc-name { font-size: 12.5px; }
    .cc-meta { font-size: 10.5px; }
    .pc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .pc-price-now { font-size: 15px; }
}
@media (max-width: 380px) {
    .cc-grid, .cc-grid-sub, .pc-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   ADMIN — inline open/close switch + category thumbnails
   ============================================================ */
.ad-switch {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 3px 10px 3px 4px; border-radius: 999px;
    border: 1px solid var(--line-strong); background: var(--surface);
    cursor: pointer; font: inherit; font-size: 11.5px; font-weight: 600;
    color: var(--ink-3);
    transition: border-color .14s var(--ease), background .14s var(--ease), color .14s var(--ease);
}
.ad-switch-dot {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--line-strong);
    transition: background .14s var(--ease), transform .16s var(--ease);
}
.ad-switch.is-on { color: #12855a; border-color: #a7ddc5; background: #eefaf4; }
.ad-switch.is-on .ad-switch-dot { background: #17a673; transform: scale(1.06); }
html.theme-dark .ad-switch.is-on { background: #12301f; border-color: #235c41; color: #4ecb8b; }
.ad-switch:hover { border-color: var(--sky-l); }

.ad-cat-thumb {
    width: 74px; height: 24px; object-fit: cover; border-radius: 5px; display: block;
}
.ad-cat-thumb.is-sub { width: 52px; height: 18px; opacity: .9; }
.ad-cat-sub-row td { background: var(--bg-soft); }
.ad-cat-sub-row td:first-child { padding-left: 26px; }
.ad-cat-branch {
    display: inline-block; width: 10px; height: 10px;
    border-left: 1.5px solid var(--line-strong);
    border-bottom: 1.5px solid var(--line-strong);
    margin-right: 8px; margin-bottom: 2px;
    border-bottom-left-radius: 3px;
}
.ad-tbl-cat { min-width: 720px; }

/* category table: 7 columns must stay reachable on a phone. Tightening the floor
   width and dropping the thumbnail under 560px keeps the open/close switch on
   screen without a horizontal drag for the common case. */
@media (max-width: 560px) {
    .ad-tbl-cat { min-width: 0; }
    .ad-tbl-cat th:nth-child(1),
    .ad-tbl-cat td:nth-child(1) { display: none; }
    .ad-tbl-cat th, .ad-tbl-cat td { padding: 9px 7px; font-size: 12px; }
    .ad-tbl-cat td:nth-child(2) { max-width: 120px; }
}

/* small "adjusted" note next to the lifetime top-up figure in the admin card */
.ad-topped-adj {
    display: inline-block; margin-top: 3px;
    font-size: 10px; font-weight: 700;
    padding: 1px 6px; border-radius: 999px;
    background: #fff3d6; color: #a06f00; border: 1px solid #f0dba8;
}
html.theme-dark .ad-topped-adj { background: #33260f; color: #f0b95a; border-color: #5a451f; }

/* secondary line under a profile figure (paid vs adjusted) */

/* ---- supplier badge on the product card ----------------------------------
   P = Premium24HR, G = GaFiwShop. Both suppliers carry the same brands, so the
   letter is what tells the two Netflix cards apart at a glance. */
.pc-src { bottom: 8px; left: 8px; }
.pc-src-p { background: #e8efff; color: #274b9f; border: 1px solid #c7d7fb; }
.pc-src-label {
    font-size: 10px; font-weight: 700; letter-spacing: .02em;
    margin-top: -4px; display: block;
}
.pc-src-label-p24 { color: #274b9f; }
