/* Product listings (FRS-0008): the shared item template (Views/Partials/_ProductItem.cshtml) and the list around it.
   One markup per product: where the list has room (its own width, not the screen's: on the Deals page it sits beside a
   menu) the parts line up as a table row under the column header; otherwise the same parts become a card. Linked by the pages that show a listing (home). */

/* ===== List ===== */

/* The list sizes its layout by its own width (the container query below) */
.lsg-product-listing {
    container-type: inline-size;
}

/* The tabs on one row; the date picker on their right, or below them on a phone */
.lsg-product-bar {
    display: flex;
    flex-wrap: wrap-reverse;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px 12px;
    border-bottom: 1px solid var(--lsg-color-border);
}

/* Tabs as plain text: grey, the open one bold with a primary underline */
.lsg-product-tabs {
    flex-wrap: nowrap;
}

/* Bootstrap's nav links: muted, darker on hover; the open tab bold and underlined in the accent */
.lsg-product-tabs {
    --bs-nav-link-padding-x: 14px;
    --bs-nav-link-padding-y: 8px;
    --bs-nav-link-color: var(--lsg-color-text-muted);
    --bs-nav-link-hover-color: var(--lsg-color-text);
}

.lsg-product-tabs .nav-link {
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.lsg-product-tabs .nav-link.active {
    border-bottom-color: var(--lsg-color-primary);
    color: var(--lsg-color-text);
    font-weight: 700;
}

.lsg-product-date {
    width: auto;
    margin-bottom: 6px;
}

.lsg-product-loading {
    opacity: 0.5;
    pointer-events: none;
}

.lsg-product-pager {
    display: flex;
    justify-content: center;
    padding-block: 20px;
}

/* ===== Product: a card on a phone ===== */

.lsg-product {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    grid-template-areas:
        "img desc desc"
        "img stock stock"
        "details details price"
        "details details msrp"
        "cart cart cart";
    gap: 6px 12px;
    margin-block: 12px;
    padding: 14px;
    border: 1px solid var(--lsg-color-border);
    border-radius: 10px;
    background-color: var(--lsg-color-surface);
    font-size: 0.85rem;
}

.lsg-product-img { grid-area: img; }
.lsg-product-details { grid-area: details; }
.lsg-product-desc { grid-area: desc; }
.lsg-product-msrp { grid-area: msrp; }
.lsg-product-price { grid-area: price; }
.lsg-product-stock { grid-area: stock; }
.lsg-product-cart { grid-area: cart; }

/* A smaller product image, e.g. on an order or invoice line (the image card itself is .lsg-product-img) */
.lsg-product-thumb {
    width: 5.5rem;
}

/* The image in a small rounded card */
.lsg-product-img img {
    width: 100%;
    max-height: 80px;
    padding: 4px;
    border-radius: 6px;
    background-color: var(--lsg-color-surface);
    box-shadow: var(--lsg-shadow-thumb);
    object-fit: contain;
}

.lsg-product-details,
.lsg-product-desc {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-wrap: anywhere;
}

.lsg-product-details {
    color: var(--lsg-color-text-muted);
}

/* Labels grey, values dark; Category, Case Qty and Country bold */
.lsg-product-details span > span,
.lsg-product-details strong {
    color: var(--lsg-color-text);
}

.lsg-product-brand {
    width: fit-content;
}

.lsg-product-name {
    font-size: 1rem;
}

.lsg-product-price,
.lsg-product-msrp,
.lsg-product-cart {
    text-align: right;
    white-space: nowrap;
}

.lsg-product-msrp {
    color: var(--lsg-color-text);
    font-size: 1rem;
}

.lsg-price {
    font-size: 1.25rem;
    font-weight: 700;
}

.lsg-price-off {
    margin-right: 4px;
    color: var(--lsg-color-danger);
    font-weight: 700;
}

.lsg-price-was {
    display: block;
    color: var(--lsg-color-text-muted);
}

.lsg-stock-in { color: var(--lsg-color-success); }
.lsg-stock-out { color: var(--lsg-color-danger); }

.lsg-stock {
    display: block;
}

.lsg-stock-qty {
    display: block;
    line-height: 1.2;
}

.lsg-cart {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.lsg-cart-qty {
    width: 70px;
}

.lsg-cart-moq {
    display: block;
    margin-top: 4px;
    font-weight: 700;
}

/* A visitor's "Login to View Prices" (a Bootstrap .btn): the column's width, dark text in an accent frame, filled on hover */
.lsg-cart-login {
    --bs-btn-border-width: 2px;
    --bs-btn-border-color: var(--lsg-color-primary);
    --bs-btn-color: var(--lsg-color-text);
    --bs-btn-hover-bg: var(--lsg-color-primary);
    --bs-btn-hover-border-color: var(--lsg-color-primary);
    --bs-btn-hover-color: var(--lsg-color-on-primary);
    --bs-btn-active-bg: var(--lsg-color-primary-dark);
    --bs-btn-active-border-color: var(--lsg-color-primary-dark);
    --bs-btn-active-color: var(--lsg-color-on-primary);
    width: 100%;
}

/* The column header is for the wide layout only */
.lsg-product-head {
    display: none;
}

/* ===== Product: a table row where the list is wide enough for every column ===== */

/* 910px: the columns' minimum widths, gaps and padding; the home list (full width) and the Deals list (beside the menu)
   both have that from the lg screen size up */
@container (min-width: 910px) {
    /* The list framed like a table */
    .lsg-product-list {
        border: 1px solid var(--lsg-color-border);
    }

    .lsg-product-list > .lsg-product:last-child {
        border-bottom: 0;
    }

    .lsg-product {
        grid-template-columns: 60px minmax(130px, 190px) minmax(170px, 1fr) 80px 150px 80px 160px;
        grid-template-areas: "img details desc msrp price stock cart";
        align-items: start;
        column-gap: 10px;
        margin: 0;
        padding: 8px 10px;
        border: 0;
        border-bottom: 1px solid var(--lsg-color-border);
        border-radius: 0;
        font-size: 0.75rem;   /* old-row sizes: small details, a 10pt name, the price a step above the other numbers */
    }

    .lsg-product-list-visitor .lsg-product {
        grid-template-columns: 60px minmax(130px, 190px) minmax(170px, 1fr) 80px 160px;
        grid-template-areas: "img details desc msrp cart";
    }

    .lsg-product-name,
    .lsg-product-msrp {
        font-size: 0.875rem;
    }

    /* The price a step above the other numbers; one line (a narrow column puts the % off above it, below) */
    .lsg-price {
        font-size: 1rem;
        white-space: nowrap;
    }

    /* A long name stops at 4 lines with an ellipsis, so one product can't make its row very tall; the full name is its
       title (shown on hover) */
    .lsg-product-name {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        line-clamp: 4;
        overflow: hidden;
    }

    .lsg-product-head {
        display: grid;
        font-size: 0.875rem;
        font-weight: 700;
        background-color: var(--lsg-color-surface-muted);
    }

    .lsg-product-stock {
        text-align: center;
    }

    .lsg-product-head > div {
        color: var(--lsg-color-text);
    }

    .lsg-product-head .lsg-product-cart {
        text-align: left;
    }

    /* A narrow price column: the % off goes above the price instead of past the column */
    .lsg-product-price {
        white-space: normal;
    }

    /* The "CAD SRP:" / "USD MSRP:" label is the column header on a wide screen */
    .lsg-product-label {
        display: none;
    }
}

/* ===== Deals page: the deal menu (a Bootstrap list group) in the portal colours ===== */

/* On the list group itself: Bootstrap sets these variables on .list-group, so a parent's values would not reach it */
.lsg-deal-menu .list-group {
    --bs-list-group-color: var(--lsg-color-text);
    --bs-list-group-item-padding-y: 0.35rem;
    --bs-list-group-action-hover-color: var(--lsg-color-text);
    --bs-list-group-active-bg: var(--lsg-color-primary);
    --bs-list-group-active-border-color: var(--lsg-color-primary);
    --bs-list-group-active-color: var(--lsg-color-on-primary);
    font-size: 0.875rem;
    overflow-wrap: anywhere;  /* a long deal name breaks inside the menu */
}

/* ===== Product detail page (ProdDetail.cshtml) ===== */

.lsg-detail-brand {
    font-weight: 700;
}

.lsg-detail-name {
    margin: 8px 0 16px;
    font-size: 1rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.lsg-detail-stock {
    display: flex;
    gap: 8px;
    align-items: start;
    margin-bottom: 16px;
}

.lsg-detail-stock .lsg-product-stock {
    text-align: left;
}

.lsg-detail-fields li {
    margin-bottom: 6px;
    color: var(--lsg-color-text-muted);
    overflow-wrap: anywhere;
}

.lsg-detail-fields strong {
    color: var(--lsg-color-text);
}

/* The price, list price and cart, on the right of the fields (below them on a phone) */
.lsg-detail-buy {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.lsg-detail-msrp {
    font-size: 1rem;
}

/* Bootstrap's tabs (class="nav nav-tabs lsg-detail-tabs"): the open tab filled with the accent */
.lsg-detail-tabs {
    --bs-nav-link-color: var(--lsg-color-text);
    --bs-nav-link-hover-color: var(--lsg-color-primary);
    --bs-nav-tabs-border-color: var(--lsg-color-border);
    --bs-nav-tabs-border-radius: 6px;
    --bs-nav-tabs-link-hover-border-color: var(--lsg-color-border);
    --bs-nav-tabs-link-active-color: var(--lsg-color-on-primary);
    --bs-nav-tabs-link-active-bg: var(--lsg-color-primary);
    --bs-nav-tabs-link-active-border-color: var(--lsg-color-primary);
}

.lsg-detail-tabs .nav-link {
    margin-right: 6px;
}

/* The open tab's content, framed below the tabs' own line */
.lsg-detail-panes {
    padding: 16px;
    border: 1px solid var(--lsg-color-border);
    border-top: 0;
}

.lsg-detail-html {
    display: block;
    width: 100%;
    min-height: 60px;
    border: 0;
}

.lsg-detail-specs {
    width: auto;
}

.lsg-detail-specs th {
    padding-right: 24px;
    font-weight: 400;
    color: var(--lsg-color-text-muted);
}
