/* ============================================================
   ChargeBox.GE Shop — catalog, product detail, cart
   Reuses root variables from assets/css/style.css (not edited here)
   ============================================================ */

/* ── Sub-nav (cart / continue shopping strip) ───────────────── */
.shop-subnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.shop-subnav-links { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.shop-subnav-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.shop-subnav a { color: var(--text-dim); font-size: .9rem; font-weight: 500; }
.shop-subnav a:hover { color: var(--primary); }
.shop-account-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 16px;
    color: var(--text) !important;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}
.shop-account-link:hover { border-color: var(--primary); color: var(--primary) !important; }
.shop-cart-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 16px;
    color: var(--text) !important;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
}
.shop-cart-link:hover { border-color: var(--primary); color: var(--primary) !important; }
.shop-cart-badge {
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: 5px;
}

/* ── Toolbar: search + category filter ──────────────────────── */
.shop-toolbar {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 36px;
}
.shop-search { flex: 1; min-width: 220px; max-width: 420px; }
.shop-search-form { display: flex; gap: 8px; }
.shop-search-form input[type="text"] { flex: 1; }
.shop-cats { display: flex; gap: 8px; flex-wrap: wrap; }
.shop-cat-chip {
    display: inline-flex;
    align-items: center;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-dim);
    font-size: .85rem;
    font-weight: 600;
    transition: border-color .2s, color .2s, background .2s;
    min-height: 44px;
}
.shop-cat-chip:hover { color: var(--text); border-color: var(--primary); }
.shop-cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.shop-filters { display: flex; align-items: center; }
.shop-filters-form { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.shop-sort-select { min-height: 44px; min-width: 190px; }
.shop-instock-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding-inline: 4px;
    color: var(--text-dim);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}
.shop-instock-toggle input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.shop-instock-toggle:hover { color: var(--text); }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Product grid ────────────────────────────────────────────── */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}
.product-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color .2s, transform .2s;
}
.product-card:hover { border-color: var(--primary); transform: translateY(-3px); }
.product-card-img {
    aspect-ratio: 1 / 1;
    background: var(--card2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    overflow: hidden;
    position: relative;
}
.product-card-img img { width: 100%; height: 100%; object-fit: cover; }
.product-card-body { padding: 18px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.product-card-body h3 { font-size: 1rem; line-height: 1.35; }
.product-card-body h3 a { color: var(--text); }
.product-card-body h3 a:hover { color: var(--primary); }
.product-price { font-size: 1.15rem; font-weight: 700; color: var(--primary); margin-top: auto; }
.product-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.product-card-actions form { flex: 1; }
.product-card-actions .btn { width: 100%; }

.stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    width: fit-content;
}
.stock-badge.in    { background: rgba(34,197,94,.14);  color: var(--success); }
.stock-badge.low   { background: rgba(245,158,11,.14); color: var(--warning); }
.stock-badge.out   { background: rgba(239,68,68,.14);  color: var(--danger); }

/* ── Pagination ──────────────────────────────────────────────── */
.shop-pagination { display: flex; justify-content: center; gap: 8px; margin-top: 44px; flex-wrap: wrap; }
.shop-pagination a, .shop-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding-inline: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: .875rem;
    font-weight: 600;
}
.shop-pagination a:hover { border-color: var(--primary); color: var(--primary); }
.shop-pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.shop-pagination .disabled { opacity: .35; pointer-events: none; }
.shop-pagination .ellipsis { border-color: transparent; min-width: 24px; padding-inline: 0; }

/* ── Product detail ──────────────────────────────────────────── */
.product-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 48px;
    align-items: flex-start;
}
.product-gallery-main {
    aspect-ratio: 1 / 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 5rem;
}
.product-gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.product-gallery-thumbs { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.product-gallery-thumbs img {
    width: 68px;
    height: 68px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: border-color .2s;
}
.product-gallery-thumbs img:hover,
.product-gallery-thumbs img.active { border-color: var(--primary); }

.product-info .breadcrumb { font-size: .85rem; color: var(--text-dim); margin-bottom: 14px; }
.product-info .breadcrumb a { color: var(--text-dim); }
.product-info .breadcrumb a:hover { color: var(--primary); }
.product-info h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 12px; }
.product-info .sku { font-size: .8rem; color: var(--text-dim); margin-bottom: 16px; }
.product-info .product-price-lg { font-size: 2rem; font-weight: 800; color: var(--primary); margin-bottom: 16px; }
.product-info .product-desc { color: var(--text-dim); line-height: 1.7; margin-bottom: 24px; }

.qty-selector { display: flex; align-items: center; gap: 10px; }
.qty-selector input[type="number"] {
    width: 80px;
    text-align: center;
}
.add-to-cart-form { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 24px; }

/* ── Cart page ───────────────────────────────────────────────── */
.cart-table-wrap { overflow-x: auto; }
.cart-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.cart-table th {
    text-align: left;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.cart-table td { padding: 16px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cart-table tr:last-child td { border-bottom: none; }
.cart-item-info { display: flex; align-items: center; gap: 14px; }
.cart-item-thumb {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: var(--card2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 1.6rem;
    flex-shrink: 0;
}
.cart-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info a { color: var(--text); font-weight: 600; }
.cart-item-info a:hover { color: var(--primary); }
/* withdrawn product: no link (shop-product.php 404s for it) */
.cart-item-name-plain { color: var(--text-dim); font-weight: 600; text-decoration: line-through; }
.cart-qty-input { width: 70px; text-align: center; }
.cart-remove-btn {
    /* Measured 32.5 x 50 px at 375px wide: the <=640px rule shrinks the padding with no min-width, and
       this is the one control a customer MUST hit to clear a cart that blocks checkout. */
    min-width: 44px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: .8rem;
    min-height: 44px;
}
.cart-remove-btn:hover { border-color: var(--danger); color: var(--danger); }

.cart-summary {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-top: 28px;
    margin-left: auto;
    max-width: 380px;
}
.cart-summary-row { display: flex; justify-content: space-between; font-size: .95rem; color: var(--text-dim); padding-block: 6px; }
.cart-summary-row.total { font-size: 1.2rem; font-weight: 800; color: var(--text); border-top: 1px solid var(--border); margin-top: 10px; padding-top: 14px; }
.cart-actions-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

.cart-empty { text-align: center; padding-block: 60px; }
.cart-empty .icon { font-size: 3.5rem; margin-bottom: 16px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
    /* `1fr` is `minmax(auto, 1fr)`, so the track's automatic minimum is the row's min-content and it
       inflates past the container. The Georgian add-to-cart row (qty label + 80px input + the 243px
       "kalatashi damateba" button) measured 389px inside a 310px container, pushing the page to 409px
       of scroll width and leaving the right 49px of the ONLY buy control off-screen. The English row is
       310px — it fitted exactly, which is why this never showed up. */
    .product-detail { grid-template-columns: minmax(0, 1fr); }
    .add-to-cart-form { flex-wrap: wrap; }
    .add-to-cart-form .btn { min-width: 0; }
}
@media (max-width: 768px) {
    .shop-toolbar { flex-direction: column; }
    .shop-search { max-width: none; }
    .shop-filters { width: 100%; }
    /* The 190px floor was removed here while the Georgian in-stock label (23 chars vs 13) ate the
       flex row, clipping the sort control to two glyphs. Stack instead of competing for width. */
    .shop-filters-form { width: 100%; flex-direction: column; align-items: stretch; }
    .shop-sort-select { flex: 1 1 auto; min-width: 0; width: 100%; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
    .cart-summary { max-width: none; }
    .shop-subnav { flex-direction: column; align-items: flex-start; }
    /* .form-control is .95rem (≈15.2px). iOS Safari zooms the whole page whenever a focused field is
       under 16px, which on the cart leaves the table scrolled off-centre and the layout enlarged until
       the user pinches back. Only the shop's own fields are bumped — style.css is not edited here. */
    .shop-search-form .form-control,
    .shop-sort-select,
    .cart-qty-input,
    .qty-selector input[type="number"] { font-size: 16px; }
}

/* The cart table is min-width:640px inside an overflow-x:auto wrapper, so on a phone the Qty, Total and
   Remove columns start off-screen. Removing an unavailable line is MANDATORY to reach checkout, so the
   one control the customer must reach was the one hidden behind a horizontal scroll. Fit it instead. */
@media (max-width: 640px) {
    /* auto table layout on purpose — it gives the product column the slack and shrinks the rest */
    .cart-table { min-width: 0; }
    .cart-table th, .cart-table td { padding: 10px 5px; }
    .cart-table th { font-size: .65rem; letter-spacing: .02em; }
    .cart-table td { font-size: .85rem; overflow-wrap: anywhere; }
    .cart-item-info { flex-direction: column; align-items: flex-start; gap: 8px; }
    .cart-item-thumb { width: 44px; height: 44px; font-size: 1.2rem; }
    .cart-qty-input { width: 56px; padding-inline: 4px; }
    .cart-remove-btn { padding: 8px 6px; font-size: .72rem; }
}

@media (max-width: 480px) {
    /* Two 150px grid columns leave ~140px for a row of two buttons — the labels wrapped mid-word. */
    .product-card-actions { flex-direction: column; }
    .product-card-actions .btn { width: 100%; }
    .add-to-cart-form { width: 100%; }
    .add-to-cart-form .btn { flex: 1; }
}

/* Measured 21px in the account orders table at 375px - 16 such targets. Everything else on the account
   surface already meets the 44px rule. */
.acct-cell-link { display: inline-block; padding-block: 12px; }
@media (max-width: 768px) { .acct-cell-link { min-height: 44px; display: inline-flex; align-items: center; } }
