/* components.css — Menu items/orders, filter pills, cart + cart containers, utilities, product thumbs, price/favourite rows.
   Split from style.css (load order matters: see the stylesheet <link> order in index.html). */
/* ============================
Menu Items / Orders
============================ */

.menu {
    display: grid;
    gap: var(--gap-sm);
    margin-top: 8px;
}

.item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    gap: var(--gap-md);
}
.item .product-title{
    display:flex;
    align-items:center;gap: var(--gap-sm);
    justify-content: space-between;
    width: 100%;
}
.item .product-title-main{
    display:flex;
    align-items:center;
    gap: var(--gap-sm);
    min-width:0;
    flex:1;
}
.item .product-title-no-desc{
    justify-content:flex-start;
}
.item .item-name,
.admin-item {
    flex: 1;
}
.item .item-dietary-badges{
    display:inline-flex;
    align-items:center;
    gap:5px;
    flex-wrap:wrap;
}
.item .item-dietary-badge{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    height:22px;
    padding:0 7px;
    border-radius: var(--radius-pill);
    font-size:var(--font-size-xs);
    font-weight:700;
    line-height:1;
}
.item .item-dietary-badge svg{ display:block; }
.item .item-veg-badge{
    background:#eaf5ee;
    color:#2e7d46;
    width:30px;
    height:30px;
    padding:0;
    border-radius:50%;
    overflow:hidden;
}
.item .item-vegan-badge{
    background:#ddf0e4;
    color:#1a6035;
    width:30px;
    height:30px;
    padding:0;
    border-radius:50%;
    overflow:hidden;
}
.item .item-spice-badge{
    gap:4px;
    padding:0 9px;
    height:30px;
    color:#bf4515;
}
.item .item-spice-mild  { background:#fdf1ee; color:#c07020; }
.item .item-spice-medium{ background:#fce8e2; color:#c04018; }
.item .item-spice-hot   { background:#fad8d0; color:#a82010; }
.item .spice-label{
    font-size:var(--font-size-xs);
    font-weight:700;
    line-height:1;
    white-space:nowrap;
}
.item .spice-dot{
    width:6px;
    height:6px;
    border-radius:50%;
    background:#ddd8d5;
    display:inline-block;
    flex-shrink:0;
}
.item .spice-dot--on:nth-child(1){ background:#e8821a; }
.item .spice-dot--on:nth-child(2){ background:#d4461e; }
.item .spice-dot--on:nth-child(3){ background:#b82020; }

@media (max-width:600px){
    .item .item-veg-badge,
    .item .item-vegan-badge{ width:24px; height:24px; }
    .item .item-veg-badge svg,
    .item .item-vegan-badge svg{ width:24px; height:24px; }
    .item .item-spice-badge{ height:24px; padding:0 7px; }
}

.order {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
}

.order .order-station-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-md);
}

.order .order-station-section + .order-station-section {
    margin-top: var(--gap-md);
}

.order .order-station-content {
    flex: 1 1 auto;
    min-width: 0;
}

.order .products p {
    margin-top: 0;
    margin-bottom: 0;
}

.order .send-station {
    align-self: center;
    flex: 0 0 auto;
}

.order .ordernodate {
    display: flex;
    justify-content: space-between;
    gap: var(--gap-md);
}

.ordernodate p {
    margin-bottom: 0;
}

/* Delivery card header layout */
#screen-deliveries .ordernodate {
    display: block;
}

.delivery-card-row1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.delivery-card-row2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.delivery-order-num {
    font-weight: 600;
}

.delivery-card-eta {
    display: inline-flex;
    align-items: center;
}

.delivery-card-when {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.82rem;
    color: #111;
}


.ordertable:not(:first-of-type) p {
    display: none;
}

.order .ordertable:first-of-type h3,
.order .ordertable:first-of-type p {
    margin: 0;
}

/* Orders by Table – row layout */
.tableorder-row {
    display: flex;
    align-items: baseline;
    gap: var(--gap-md);
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.tableorder-ref {
    width: 180px;
    flex-shrink: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tableorder-items {
    flex: 1;
}

.tableorder-time {
    width: 100px;
    flex-shrink: 0;
    text-align: right;
    white-space: nowrap;
}

.tableorder-item-price {
    float: right;
    opacity: 0.7;
    font-size: 0.95em;
}

.tableorder-total-row {
    text-align: right;
    padding: 4px 0 2px;
    font-size: 0.95em;
}

.tableorder-refund {
    display: flex;
    justify-content: flex-end;
    gap: var(--gap-sm);
    padding: 8px 0 2px;
}

.tableorder-refund button {
    margin-left: 0;
}

.tableorder-receipt-btn:hover {
    opacity: 0.7;
}

.delivery-receipt-btn {
    display: inline-flex;
    align-items: center;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
}
.delivery-receipt-btn img { filter: brightness(0); }
.delivery-receipt-btn:hover { opacity: 0.8; }

.delivery-order-num-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

/* Inline item switches (order items) */
.tableorder-item-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

.tableorder-item-line .tableorder-item-name {
    flex: 1;
    min-width: 0;
}

.tableorder-item-line .tableorder-item-price {
    float: none;
    flex-shrink: 0;
    white-space: nowrap;
}

.tableorder-item-line.item-excluded {
    opacity: 0.4;
}

.tableorder-item-line.item-excluded .tableorder-item-name {
    text-decoration: line-through;
}

.tableorder-item-line.item-refunded {
    opacity: 0.45;
}

.tableorder-item-line.item-refunded .tableorder-item-name {
    text-decoration: line-through;
}

/* Already part-paid items: greyed with a small 'paid' tag, kept for context */
.tableorder-item-line.item-paid {
    opacity: 0.55;
}
.tableorder-item-line.item-paid .tableorder-item-name {
    text-decoration: line-through;
}
.tableorder-item-paid-tag {
    flex-shrink: 0;
    font-size: 0.78em;
    font-weight: 600;
    color: #2e7d32;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.tableorder-paid-line {
    margin-top: 2px;
    color: #2e7d32;
}

/* Mobile: show order ref above items, hide time */
@media (max-width: 600px) {
    main {
        padding: 0 6px;
    }

    .order.tableorder-group {
        padding: 8px;
    }

    .tableorder-time {
        display: none;
    }

    .tableorder-ref {
        width: 100%;
        flex-shrink: 0;
    }

    .tableorder-row {
        gap: 0;
        flex-wrap: wrap;
    }

    .tableorder-items {
        width: 100%;
    }

    .tableorder-item-line {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "name switch"
            "price price"
            "qty qty";
        align-items: start;
        gap: 2px 10px;
    }

    .tableorder-item-line .tableorder-item-name {
        grid-area: name;
        min-width: 0;
    }

    .tableorder-item-line .tableorder-item-price {
        grid-area: price;
        justify-self: start;
        margin-top: 2px;
    }

    .tableorder-item-line .tier-switch {
        grid-area: switch;
        justify-self: end;
        align-self: start;
        margin-left: 0;
    }

    .tableorder-item-line .tableorder-qty-controls {
        grid-area: qty;
        justify-self: start;
    }

    .tableorder-qty-controls {
        gap: 2px;
    }

    .tableorder-qty-display {
        min-width: 20px;
    }
}

.tableorder-qty-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.tableorder-qty-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--grey-500);
    background: transparent;
    color: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.tableorder-qty-btn:hover {
    background: rgba(255,255,255,0.1);
}

.tableorder-qty-display {
    font-size: 0.85em;
    min-width: 32px;
    text-align: center;
}

.order .ordertable h3,
.order .ordertable p {
    margin-bottom: 0;
}

.order .ordertable {
    display: flex;
    justify-content: space-between;
    gap: var(--gap-md);
}
.order.tableorder-group { position: relative; }
.order.tableorder-group .tableorder-toggle-all {
    position: absolute; top: 16px; right: 18px;
    width: 36px; height: 32px; padding: 0; margin: 0; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--white); color: var(--grey-800);
    border: 1px solid rgba(0,0,0,0.15); border-radius: var(--radius-sm);
    box-shadow: none; cursor: pointer;
}
.order.tableorder-group .tableorder-toggle-all:hover { background: rgba(0,0,0,0.05); }
.order.tableorder-group .tableorder-toggle-all img { display: block; width: 18px; height: 18px; }

/* ============================
Filters / Navigation (Pills)
============================ */

.menu-filters {
    background: var(--bg);
    z-index: 1;
    padding: 16px 0;
}

/* horizontal scroll containers */
#navigation ul,
.menu-filters ul {
    margin: 0;
    padding: 16px 0;
    list-style: none;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#navigation ul {
    padding-top: 8px;
}

.screen-pills {
    padding: 0 16px;
    margin: 0 auto;
}

.screen-pills .pill-btn,
.menu-filters .filter-btn,
#screen-ordering .filter-btn {
    background: none;
    color: var(--ink);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: flex-start;
    padding: var(--pad-card);
    cursor: pointer;
    font-weight: 100;
}

.pill-btn.active,
.filter-btn.active {
    background: var(--header-action-fill);
    color: var(--white);
}

#screen-ordering .filter-btn.active {
    background: var(--button-primary-customer);
    color: var(--white);
}

/* FIXED: no nested blocks;
list variant styling */
.menu-filters, #navigation {
    display: flex;
    position: sticky;
    top: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-padding-inline: 16px;
    flex-wrap: nowrap;
    gap: var(--gap-sm);
    align-items: baseline;
    background: var(--bg);
    z-index:100;
}

.menu-filters ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: var(--gap-sm);
}

.menu-filters li {
    display: inline-block;
}

.menu-filters a.filter-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    padding: var(--pad-card);
    border-radius: var(--radius-lg);
}

/* Ensure active filter buttons inside menu-filters show the admin colour. */
.menu-filters .filter-btn.active,
#screen-admin .menu-filters .filter-btn.active {
    background: var(--header-action-fill);
    color: var(--white);
}

.menu-filters * {
    flex-shrink: 0;
}

/* ============================
Cart / Cart Rows
============================ */

.cart {
    list-style: none;
    margin: 8px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--gap-sm);
}

.cart li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-md);
    max-width: 364px;
    box-sizing: border-box;
    margin-bottom: 8px;
}

.cart li * {
    align-self: center;
    margin-top: 0;
    margin-bottom: 0;
}

.cart .cart-name {
    width: 170px;
}

.cart li .adjustnumber {
    border: 1px solid var(--ink);
    padding: 2px;
    border-radius: 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    width: 74px;
    min-width: 74px;
}

.maximised-cart button {
    background-image: url(images/icons/cross.svg);
    display: none;
}

.cart li .adjustnumber button {
    width: 20px;
    min-width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-pill);
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 50% 50%;
    background-size: 12px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 20px;
}

.cart li .adjustnumber button:first-of-type {
    background-image: url(images/icons/remove.svg);
}

.cart li .adjustnumber button.inc {
    background-image: url(images/icons/add.svg);
}

.cart li .adjustnumber .qty {
    min-width: 18px;
    text-align: center;
    font-size: var(--font-size-body);
    line-height: 1;
    outline: none;
    cursor: text;
}

.cart li button:nth-of-type(1) {
    background-image: url(images/icons/bin.svg);
}

.total {
    font-weight: 800;
    font-size: 1.2rem;
}

/* ============================
Cart Containers
============================ */

#cartcontainer,
#till-cartcontainer {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
}

#cartcontainer>*:first-child,
#till-cartcontainer>*:first-child {
    margin-top: 0;
}

#cartcontainer>*:last-child,
#till-cartcontainer>*:last-child {
    margin-bottom: 0;
}

#cartcontainer h2 {
    margin-top: 0;
}

#cartcontainer .cart-header,
#till-cartcontainer .cart-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "bag-area close-area"
        "mode-area mode-area";
    column-gap: var(--gap-sm);
    row-gap: 6px;
    align-items: center;
}

#cartcontainer .minimised-cart,
#cartcontainer .maximised-cart,
#till-cartcontainer .minimised-cart,
#till-cartcontainer .maximised-cart {
    grid-area: bag-area;
}

#order-mode-switch {
    grid-area: mode-area;
}

/* Till cart never shows the channel switch — till has its own order-type controls */
#till-cartcontainer #till-order-mode-switch {
    display: none !important;
}

#till-cartcontainer .cart-header .cart-close,
#cartcontainer .cart-header .cart-close {
    border: 0;
    padding: 0;
    background: none;
    display: none;
    grid-area: close-area;
}

#cartcontainer .row,
#till-cartcontainer .row {
    justify-content: space-between;
    align-items: center;
    gap: var(--gap-md);
}

.cart-total-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    padding-bottom: 8px;
}
.cart-total-group > p { margin: 0; }
.cart-total-group.sc-active {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    flex: 1 1 100%;
}
.cart-sc-row > :last-child {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.cart-sc-block {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cart-sc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 1em;
}
.cart-sc-row.muted { color: var(--text-muted, var(--grey-500)); }
.cart-sc-total {
    font-size: 1.2rem;
    font-weight: 800;
}
.add-service-btn {
    width: auto;
    padding: 6px 16px;
    font-size: 0.8em;
    white-space: nowrap;
    flex-shrink: 0;
}
.add-service-btn:hover { filter: brightness(1.08); }

#bag-address-row {
    flex-wrap: nowrap;
    align-items: flex-start;
}

#bag-address-row>label:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

#bag-address-row>label:last-child {
    flex: 0 0 auto;
}

#bag-address-row #bag-street {
    width: clamp(120px, 40vw, 220px);
}

#cartcontainer input.bag-prefilled-locked {
    border: 0;
    background: transparent;
    padding: 0;
    min-height: auto;
    height: auto;
    border-radius: 0;
    color: var(--text);
    cursor: default;
    box-shadow: none;
}

#cartcontainer #bag-address-row input.bag-prefilled-locked {
    width: auto;
    max-width: clamp(120px, 40vw, 260px);
}

#cartcontainer input.bag-prefilled-locked:focus,
#cartcontainer input.bag-prefilled-locked:focus-visible {
    outline: none;
    box-shadow: none;
}

#cartcontainer .minimised-cart,
#till-cartcontainer .minimised-cart {
    display: none;
}

/* ============================
Utilities / Helpers
============================ */

.row {
    display: flex;
    gap: var(--gap-md);
    flex-wrap: wrap;
}

.row> :nth-last-child(2) {
    flex: 1;
    margin-right: auto;
}

.center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.right {
    display: flex;
    justify-content: flex-end;
}

hr {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* ============================
Product Thumbs
============================ */

.item .productimage {
    display: none;
}

.imagethumbs .item .productimage {
    display: block;
    position: relative;
    background: #C5DFE6;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.imagethumbs .item .productimage img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}

/* No-image overlay: when a productimage has no image, show a styled placeholder
   background only — no text label needed on customer-facing ordering cards. */
.productimage {
    position: relative;
    overflow: hidden;
    /* ensure overlay sits above */
}

.productimage.no-image {
    background: #eef0f3;
}

.productimage.no-image::after {
    content: none;
}

/* Allow JS to supply a runtime min-height value via --min-h so we avoid
setting inline minHeight while keeping the computed per-element value. */
.productimage {
    min-height: var(--min-h, auto);
}

.imagethumbs .item button,
.thumbs .item button {
    width: 100%;
}

/* ============================
Price + Favourite (row)
============================ */

.pricefavourite {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
    flex-wrap: nowrap;
}

.pricefavourite p:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.pricefavourite p:last-child {
    margin: 0;
    white-space: nowrap;
    flex: 0 0 auto;
}

.fav-btn {
    display: inline-block;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
    vertical-align: middle;
}

.fav-btn img {
    width: 24px;
    height: 24px;
    display: block;
}

.fav-btn:hover,
.fav-btn:focus {
    color: #6f1b63;
    text-decoration: none;
}

/* Directory business capability icons (tick / cross) */
.biz-capabilities {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

/* Capability pills overlaid on the bottom of the business card image */
.biz-cap-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 3px 4px;
    padding: 5px 6px 9px;
    background: linear-gradient(to top, rgba(0,0,0,0.45), rgba(0,0,0,0));
    pointer-events: none;
    border-radius: 0 0 16px 16px;
}

.biz-cap-pill {
    display: inline-block;
    background: rgba(22, 140, 70, 0.92);
    color: var(--white);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 10px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* Capability pills a touch bigger on small screens for readability */
@media (max-width:600px) {
    .biz-cap-pill {
        font-size: 14px;
        padding: 5px 9px;
    }
}

.biz-capabilities .cap-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.biz-capabilities .cap-item img.cap-icon {
    width: 24px;
    height: 24px;
    display: inline-block;
}

/* Directory card — photo edit button (camera icon, top-right of image) */
.biz-photo-edit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    padding: 0;
    color: var(--grey-800);
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

/* Menu item camera button — must beat ".imagethumbs .item button { width:100% }"
   (specificity 0,2,1) so we use a 0,3,1 selector here. */
.imagethumbs .item button.menu-item-photo-edit-btn,
.thumbs .item button.menu-item-photo-edit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.9);
}

/* When a menu item has no image but admin camera is present, give the wrap
   enough height for the button to be visible and clickable. */
.productimage.has-admin-camera {
    min-height: 46px;
}

/* Photo edit modal — preview area */
.biz-photo-preview-wrap {
    margin-top: 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.biz-photo-preview-wrap[hidden] {
    display: none;
}
.biz-photo-preview-wrap img {
    display: block;
    max-width: 100%;
    max-height: 320px;
}
.biz-photo-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.order-mode-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 5;
    margin: 0 0 16px;
}

.order-mode-switch .mode-btn {
    background: rgba(0,0,0,0.04);
    color: var(--ink);
    border-radius: var(--radius-lg);
    padding: var(--pad-btn);
    font-size: var(--font-size-body);
    line-height: 1.2;
    /* Beats the global `button { width:100% }` on specificity (0,2,0 vs 0,0,1). */
    width: auto;
    display: inline-flex;
    min-width: 44px;
    justify-content: center;
}

.order-mode-switch .mode-btn.active {
    background: var(--button-primary-customer);
    color: var(--white);
}

#cartcontainer.cart-open .order-mode-switch .mode-btn.active,
#till-cartcontainer.cart-open .order-mode-switch .mode-btn.active {
    background: var(--button-primary-customer);
    color: var(--white);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.28), 0 0 0 1px rgba(2, 177, 196, 0.18);
}
