/* Product page: gallery, buy box, delivery, tabs, reviews — loaded by its page on top of shop.css */

/* ── Layout ─────────────────────────────────────────────────────
   Phones: one column.
   768px up: the buy box beside the photo, the tabs full width under both.
   992px up: the tabs join the buy box in the right column and the photo stays in view. */
.product-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

@media (min-width: 768px) {
    .product-page {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
        gap: 32px 24px;
        align-items: start;
    }

    /* The buy box and the tabs become cells of the page grid */
    .product-info {
        display: contents;
    }

    .product-tabs {
        grid-column: 1 / -1;
    }
}

@media (min-width: 992px) {
    .product-page {
        column-gap: 40px;
    }

    .product-info {
        display: block;
    }

    .product-gallery {
        position: sticky;
        top: 84px; /* under the sticky header */
    }
}

/* ── Gallery ────────────────────────────────────────────────── */
.product-gallery__main {
    aspect-ratio: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--shop-radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* No photo: a short placeholder, not a big empty square */
.product-gallery__main.is-empty {
    aspect-ratio: 16 / 9;
}

.product-gallery__main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* product.js fills the thumbnails only for two photos or more */
.product-gallery__thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.product-gallery__thumbs:not(:empty) {
    margin-top: 8px;
}

.product-gallery__thumb {
    flex: none;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-surface);
    cursor: pointer;
}

.product-gallery__thumb.active {
    border-color: var(--accent);
}

.product-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (min-width: 768px) {
    .product-gallery__thumb {
        width: 64px;
        height: 64px;
    }
}

/* ── Admin notices ──────────────────────────────────────────── */
/* Shown instead of the buy buttons to an admin */
.buy-box__admin {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px dashed var(--border);
    border-radius: var(--shop-radius);
    background: var(--bg-base);
    color: var(--tx-secondary);
    font-size: 0.875rem;
}

.buy-box__admin a {
    color: var(--accent);
    font-weight: 600;
}

/* Admin looking at a product customers cannot see */
.product-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin-bottom: 12px;
    padding: 10px 14px;
    border: 1px solid var(--shop-warn);
    border-radius: var(--shop-radius);
    background: color-mix(in srgb, var(--shop-warn) 12%, var(--bg-surface));
    color: var(--tx-primary);
    font-size: 0.875rem;
    font-weight: 600;
}

.product-preview i {
    color: var(--shop-warn);
}

/* ── Buy box: no panel of its own, it sits on the page ──────── */
.buy-box__title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
}

.buy-box__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
    color: var(--tx-secondary);
    font-size: 0.8125rem;
    margin-bottom: 8px;
}

.buy-box .shop-price__now {
    font-size: 1.5rem;
}

.buy-box .shop-price__was {
    font-size: 1rem;
}

@media (min-width: 992px) {
    .buy-box__title {
        font-size: 1.5rem;
    }

    .buy-box .shop-price__now {
        font-size: 1.75rem;
    }
}

.buy-box__promo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--bg-active);
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 700;
}

.option-group {
    margin-top: 16px;
}

.option-group__label {
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.option-group__label span {
    font-weight: 500;
    color: var(--tx-secondary);
}

.option-choice {
    min-width: 44px;
    min-height: 40px;
    padding: 6px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--tx-primary);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.option-choice:hover:not(:disabled) {
    border-color: var(--accent);
}

.option-choice.active {
    border-color: var(--accent);
    background: var(--bg-active);
    color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.option-choice:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

.option-choice--swatch {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
}

.option-choice--swatch span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

.option-choice:focus-visible,
.product-gallery__thumb:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Empty until a variant is chosen (product.js): then it takes no room */
.buy-box__stock {
    margin-top: 12px;
    font-weight: 600;
    font-size: 0.875rem;
}

.buy-box__stock:empty {
    display: none;
}

.buy-box__stock.in {
    color: var(--shop-ok);
}

.buy-box__stock.low {
    color: var(--shop-warn);
}

.buy-box__stock.out {
    color: var(--shop-sale);
}

.buy-box__qty {
    margin-top: 16px;
}

.buy-box__free {
    margin-top: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--shop-ok);
}

.buy-box__actions {
    margin-top: 12px;
}

/* Side by side; they wrap only where both labels no longer fit */
.buy-box__actions .btn {
    flex: 1 1 140px;
}

.buy-box__note {
    margin-top: 8px;
    font-size: 0.8125rem;
    color: var(--tx-secondary);
}

/* "Choose all options": the message and the choices still missing are in danger colour */
#optionHint {
    color: var(--shop-sale);
    font-weight: 600;
}

.option-group.is-missing .option-group__label,
.option-group.is-missing .option-group__label span,
.option-group.is-missing .option-choice:not(.active):not(:disabled) {
    color: var(--shop-sale);
}

.option-group.is-missing .option-choice:not(.active):not(:disabled) {
    border-color: var(--shop-sale);
}

.option-group.is-missing .option-choice--swatch:not(.active):not(:disabled) {
    box-shadow: 0 0 0 2px var(--shop-sale);
}

/* ── Delivery: what each area pays for this product, and why ── */
.delivery-box {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--shop-radius);
    background: var(--bg-hover);
    font-size: 0.875rem;
}

.delivery-box__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    margin-bottom: 8px;
    font-weight: 700;
}

.delivery-box__head i {
    margin-right: 6px;
    color: var(--accent);
}

.delivery-box__cod {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--tx-secondary);
}

.delivery-box__cod i {
    color: var(--shop-ok);
}

.delivery-box__rules {
    list-style: none;
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0; /* Bootstrap's 2rem list indent beats the reset in layout.css */
}

/* Area on the left, its charge on the right, the free-above and source note under both */
.delivery-box__rules li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    column-gap: 12px;
}

.delivery-box__charge {
    font-weight: 600;
    text-align: right;
}

/* Darker green in the light theme, lighter in the dark one, so the label stays readable on the panel */
.delivery-box__charge.is-free {
    color: color-mix(in srgb, var(--shop-ok) 75%, var(--tx-primary));
}

.delivery-box__note {
    grid-column: 1 / -1;
    margin-top: 2px;
    color: var(--tx-secondary);
    font-size: 0.75rem;
}

.delivery-box__note::first-letter {
    text-transform: uppercase;
}

/* ── Tabs: description, specification, reviews ──────────────── */
.product-tabs {
    margin-top: 24px;
}

@media (min-width: 768px) {
    .product-tabs {
        margin-top: 0; /* the page grid's row gap is the space */
    }
}

@media (min-width: 992px) {
    .product-tabs {
        margin-top: 32px;
    }
}

.product-tabs .nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: 4px;
}

/* .nav-link is also the admin sidebar link (layout.css): undo its radius, clipping and side bar here */
.product-tabs .nav-link {
    gap: 4px;
    margin-bottom: -1px; /* the active underline sits on the list's rule */
    padding: 12px 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    overflow: visible;
    background: none;
    color: var(--tx-secondary);
    font-weight: 600;
}

.product-tabs .nav-link:hover {
    color: var(--tx-primary);
}

.product-tabs .nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: none;
}

.product-tabs .nav-link.active::before {
    content: none;
}

.product-description {
    max-width: 70ch;
    padding-top: 16px;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.product-description img {
    max-width: 100%;
    height: auto;
}

.spec-table {
    width: 100%;
    margin-top: 12px;
    border-collapse: collapse;
}

.spec-table th,
.spec-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.spec-table th {
    width: 32%;
    color: var(--tx-secondary);
    font-weight: 600;
}

.review-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.review-item:last-child {
    border-bottom: 0;
}

.review-item__date {
    color: var(--tx-muted);
    font-size: 0.8125rem;
    font-weight: 400;
}

/* ── Related products: full width under the product; the footer brings its own space ── */
.product-related {
    margin: 24px 0 0;
}

@media (min-width: 768px) {
    .product-related {
        margin-top: 32px;
    }
}
