/* Orders page - B60 OS (page-scoped) */

.orders-page {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
    width: 100%;
}

.orders-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--ds-space-3);
}

.orders-search {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    flex: 1 1 220px;
    min-width: 180px;
    max-width: min(100%, 380px);
    padding: 0 var(--ds-space-3);
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    min-height: 40px;
    height: 40px;
    box-sizing: border-box;
}

.orders-search svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--ds-text-tertiary);
}

.orders-search .ds-input {
    border: none;
    background: transparent;
    padding: 0;
    min-height: 36px;
    box-shadow: none;
}

.orders-search .ds-input:focus {
    outline: none;
    box-shadow: none;
}

/* The input has no edge of its own, so the box around it shows focus. */
.orders-search:focus-within {
    border-color: var(--ds-primary);
    box-shadow: var(--ds-focus-ring);
}

.orders-filter-field {
    min-width: 130px;
}

.orders-filter-field--wide {
    min-width: 160px;
}

.orders-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-4);
    margin-block-end: 0;
}

.orders-table-wrap {
    overflow-x: auto;
    border: none;
    border-radius: 0;
}

/* ONE view per breakpoint - mobile hidden FIRST, then media query */
.orders-mobile-list {
    display: none;
}

.orders-desktop-table {
    display: table;
    width: 100%;
}

.orders-row-expand-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--ds-text-tertiary);
    cursor: pointer;
    /* 22x22 was under the touch minimum for the control that opens an order's
       detail -- the most-tapped thing on this page. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: var(--ds-space-1);
    border-radius: var(--ds-radius-sm);
    line-height: 0;
}

:where(.can-hover) .orders-row-expand-btn:hover {
    color: var(--ds-primary);
    background: var(--ds-primary-tint);
}

.orders-row-expand-btn.is-open {
    color: var(--ds-primary);
    transform: rotate(180deg);
}

.orders-detail-row td {
    padding: 0;
    background: var(--ds-surface-alt);
    border-block-end: 1px solid var(--ds-border);
}

.orders-detail-panel {
    padding: var(--ds-space-4) var(--ds-space-5);
}

.orders-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--ds-space-3);
    margin-block-end: var(--ds-space-3);
}

.orders-detail-label {
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-block-end: 2px;
}

.orders-detail-value {
    font-size: var(--ds-text-sm);
    font-weight: var(--ds-fw-medium);
    color: var(--ds-text-primary);
}

.orders-detail-items {
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
    line-height: 1.5;
}

.orders-toolbar {
    /* extends .ds-toolbar */
}

.orders-payment-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--ds-space-1);
}

.orders-desktop-table tbody tr {
    height: 56px;
}

.orders-desktop-table tbody td {
    vertical-align: middle;
}

.orders-actions-col {
    width: 140px;
    text-align: end;
}

.orders-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--ds-space-1);
    min-height: 40px;
}

.orders-action-view {
    color: var(--ds-primary);
    font-weight: var(--ds-fw-medium);
}

.orders-action-icon {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.orders-overflow-wrap {
    position: relative;
}

.orders-overflow-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--ds-radius-md);
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    cursor: pointer;
    font-size: var(--ds-text-lg);
    line-height: 1;
    color: var(--ds-text-secondary);
    font-family: inherit;
}

/* Holds the "..." button's place on a row with nothing in its menu. */
.orders-overflow-spacer {
    flex: 0 0 40px;
    width: 40px;
}

:where(.can-hover) .orders-overflow-btn:hover {
    background: var(--ds-surface-alt);
    color: var(--ds-text-primary);
}

.orders-overflow-menu {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    min-width: 140px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    box-shadow: var(--ds-shadow-modal);
    padding: var(--ds-space-1);
    z-index: 20;
}

.orders-overflow-menu button {
    display: block;
    width: 100%;
    text-align: start;
    border: none;
    background: transparent;
    padding: var(--ds-space-2) var(--ds-space-3);
    border-radius: var(--ds-radius-sm);
    font-size: var(--ds-text-sm);
    cursor: pointer;
    font-family: inherit;
    color: var(--ds-text-primary);
}

:where(.can-hover) .orders-overflow-menu button:hover {
    background: var(--ds-surface-alt);
}

.orders-actions {
    display: none;
}

.orders-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    padding: var(--ds-space-3) var(--ds-space-4);
    border-block-start: 1px solid var(--ds-border);
    font-size: var(--ds-text-sm);
}

.orders-pagination-info {
    color: var(--ds-text-secondary);
}

.orders-pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
}

.orders-page-indicator {
    padding: var(--ds-space-1) var(--ds-space-3);
    background: var(--ds-bg-inset);
    border-radius: var(--ds-radius-sm);
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
}

/* Mobile cards */
.order-mobile-card {
    padding: var(--ds-space-4);
    border-block-end: 1px solid var(--ds-border);
    cursor: pointer;
    transition: background-color var(--ds-motion-hover) var(--ds-ease-standard);
}

.order-mobile-card:last-child {
    border-block-end: none;
}

.order-mobile-card:active {
    background: var(--ds-surface-alt);
}

.omc-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-block-end: var(--ds-space-1);
}

.omc-id {
    font-family: var(--ds-font-mono);
    font-weight: var(--ds-fw-semibold);
    font-size: var(--ds-text-sm);
    color: var(--ds-text-primary);
}

.omc-total {
    font-weight: var(--ds-fw-bold);
    font-size: var(--ds-text-md);
    color: var(--ds-text-primary);
    font-variant-numeric: tabular-nums;
}

.omc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
    margin-block-end: var(--ds-space-1);
}

.omc-items {
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
    margin-block-end: var(--ds-space-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.omc-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
}

.orders-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
}

.orders-skeleton-bar {
    height: 14px;
    border-radius: var(--ds-radius-sm);
    background: linear-gradient(
        90deg,
        var(--ds-bg-inset) 25%,
        var(--ds-border) 50%,
        var(--ds-bg-inset) 75%
    );
    background-size: 200% 100%;
    animation: orders-shimmer 1.2s ease-in-out infinite;
}

.orders-skeleton-bar--lg {
    height: 48px;
}

.orders-skeleton-bar--md {
    height: 32px;
    width: 60%;
}

@keyframes orders-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (max-width: 768px) {
    /* A grid, not a flex column: in a column the search's flex-basis of
       220px became its HEIGHT, and the selects kept a min-width wider than
       the phone. Search and the period buttons get a row each, the four
       filters two to a row. */
    .orders-toolbar.ds-toolbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
        gap: var(--ds-space-2);
    }

    .orders-toolbar .orders-search {
        grid-column: 1 / -1;
        max-width: none;
        min-width: 0;
        height: 44px;
    }

    .orders-toolbar .orders-period {
        grid-column: 1 / -1;
        max-width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .orders-filter-field,
    .orders-filter-field--wide {
        width: auto;
        min-width: 0;
    }

    .orders-toolbar .orders-filter-field .ds-select {
        width: 100%;
        min-width: 0;
    }

    .orders-desktop-table {
        display: none !important;
    }

    .orders-mobile-list {
        display: block;
        border: 1px solid var(--ds-border);
        border-radius: var(--ds-radius-lg);
        overflow: hidden;
    }

    .orders-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .orders-card-head .ds-tabs {
        width: 100%;
        overflow-x: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .orders-skeleton-bar {
        animation: none;
    }
}


@media (max-width: 768px) {
    .orders-filters,
    .orders-filter-bar {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--ds-space-2);
    }
    .orders-filters .ds-btn,
    .orders-filter-bar .ds-btn {
        width: 100%;
    }
}

/* Wave 4 T-N: repeated inline styles lifted from orders.js */
.orders-flex-1 { flex: 1; }
.orders-flex-1-min { flex: 1; min-width: 0; }
.orders-meta { font-size: 11px; color: var(--text-secondary); }
.orders-meta-ds {
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
}
.orders-meta-caps {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.orders-row-between-mb {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.orders-icon-sm {
    vertical-align: middle;
    margin-inline-end: 4px;
}
.orders-fw-semibold { font-weight: var(--ds-fw-semibold); }
.orders-fw-title { font-weight: 600; font-size: 14px; }
.orders-m-0 { margin: 0; }
.orders-pad-16 { padding: 16px; }
.orders-gap-16 { gap: 16px; }
.orders-hint-pad {
    padding: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.orders-inset-pad {
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

/* -- Voids and cancels report (js/pages/orders.js renderRemovalsView) ----- */
.orders-view-tabs {
    align-self: flex-start;
}

.rmr-head {
    flex-wrap: wrap;
    gap: var(--ds-space-3);
}

.rmr-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--ds-space-3);
    padding: 0 var(--ds-space-4) var(--ds-space-4);
}

.rmr-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--ds-space-3);
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-md);
    border-inline-start-width: 4px;
}

.rmr-stat--cancel { border-inline-start-color: var(--ds-warning); }
.rmr-stat--void { border-inline-start-color: var(--ds-danger); }
.rmr-stat--money { border-inline-start-color: var(--ds-info); }
.rmr-stat--waste { border-inline-start-color: var(--ds-text-tertiary); }

.rmr-stat-label {
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rmr-stat-value {
    font-size: var(--ds-text-lg);
    font-weight: var(--ds-fw-semibold);
}

.rmr-stat-sub {
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
}

.rmr-reasons {
    padding: 0 var(--ds-space-4) var(--ds-space-4);
}

.rmr-reason-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    margin-top: var(--ds-space-1);
}

.rmr-reason {
    padding: 4px var(--ds-space-3);
    border-radius: 999px;
    background: var(--ds-bg-inset);
    font-size: var(--ds-text-sm);
}

.rmr-table td {
    vertical-align: top;
}

.rmr-items {
    min-width: 140px;
}

.rmr-muted {
    color: var(--ds-text-secondary);
    font-size: var(--ds-text-xs);
}

.rmr-back {
    color: var(--ds-danger-text);
    font-size: var(--ds-text-xs);
    font-weight: var(--ds-fw-medium);
}

/* --- Order panel (Orders.openOrderPanel) ---------------------------------
 *
 * On top of the page, full height at the end edge, over a dimmed page
 * (.panel-scrim, components.css) that closes it on a tap -- the same layer
 * as the product editor. The filled arrows step to the next order. Its
 * foot holds the one strong button.
 */
.oview {
    --oview-width: 440px;
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-end: 0;
    z-index: 195;
    width: min(var(--oview-width), 100%);
    display: flex;
    flex-direction: column;
    background: var(--ds-surface);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    box-shadow: var(--ds-shadow-modal);
    animation: oview-in 180ms var(--ds-ease-standard, ease-out);
}

body[dir="rtl"] .oview {
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    animation-name: oview-in-rtl;
}

@keyframes oview-in {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: none; }
}

@keyframes oview-in-rtl {
    from { opacity: 0; transform: translateX(-24px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .oview { animation: none; }
}

tr[data-order-row] {
    cursor: pointer;
}

tr[data-order-row].is-active > td {
    background: var(--ds-primary-tint);
}

.oview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    padding: var(--ds-space-2) var(--ds-space-4);
    border-bottom: 1px solid var(--ds-border);
}

.oview-nav,
.oview-head-actions {
    display: flex;
    align-items: center;
    gap: var(--ds-space-1);
}

.oview-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--ds-radius-md);
    background: transparent;
    color: var(--ds-text-secondary);
    cursor: pointer;
}

:where(.can-hover) .oview-icon-btn:hover:not(:disabled) {
    background: var(--ds-bg-inset);
    color: var(--ds-text-primary);
}

.oview-icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/*
 * Previous / "3 / 12" / next as one filled button in the cafe colour, with
 * the primary button's sheen: with the panel over the list, these are how
 * you move to the next order. Hover and press darken whatever the colour is.
 */
.oview .oview-nav {
    gap: 0;
    overflow: hidden;
    border-radius: var(--ds-radius-md);
    background-color: var(--ds-primary);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 55%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 1px 2px rgba(30, 27, 57, 0.10),
        0 6px 16px color-mix(in srgb, var(--ds-primary) 28%, transparent);
    color: var(--ds-text-on-accent);
}

.oview-nav .oview-icon-btn {
    width: 48px;
    height: 44px;
    border-radius: 0;
    color: inherit;
}

:where(.can-hover) .oview-nav .oview-icon-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
}

.oview-nav .oview-icon-btn:active:not(:disabled) {
    background: rgba(0, 0, 0, 0.2);
}

.oview-nav .oview-icon-btn:focus-visible {
    outline: 2px solid var(--ds-text-on-accent);
    outline-offset: -4px;
}

.oview-nav .oview-icon-btn:disabled {
    opacity: 0.4;
}

/* The arrows point the way the list runs. */
body[dir="rtl"] .oview-nav svg {
    transform: scaleX(-1);
}

.oview-pos {
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding-inline: var(--ds-space-2);
    border-inline: 1px solid rgba(255, 255, 255, 0.22);
    font-size: var(--ds-text-sm);
    font-weight: var(--ds-fw-semibold);
    color: inherit;
}

.oview-more {
    position: relative;
}

.oview-menu {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    z-index: 2;
    min-width: 200px;
    padding: 8px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
    box-shadow: var(--ds-shadow-modal);
}

.oview-menu[hidden] {
    display: none;
}

.oview-menu button {
    display: block;
    width: 100%;
    min-height: 40px;
    padding: 0 var(--ds-space-3);
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-primary);
    font: inherit;
    font-size: var(--ds-text-sm);
    text-align: start;
    cursor: pointer;
}

:where(.can-hover) .oview-menu button:hover {
    background: var(--ds-bg-inset);
}

.oview-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--ds-space-5);
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-5);
}

.oview-id {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-1);
}

.oview-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ds-space-3);
}

.oview-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ds-text-primary);
}

.oview-meta {
    margin: 0;
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
}

.oview-section {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
}

.oview-h {
    margin: 0;
    font-size: var(--ds-text-sm);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-primary);
}

.oview-lines {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--ds-border);
}

.oview-line {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: baseline;
    gap: var(--ds-space-2);
    padding: var(--ds-space-3) 0;
    border-bottom: 1px solid var(--ds-border);
    font-size: var(--ds-text-sm);
}

.oview-qty {
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-secondary);
}

.oview-line-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--ds-text-primary);
    font-weight: var(--ds-fw-medium);
    overflow-wrap: anywhere;
}

.oview-mods {
    font-size: var(--ds-text-xs);
    font-weight: var(--ds-fw-normal, 400);
    color: var(--ds-text-secondary);
}

.oview-line-total {
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-primary);
}

.oview-sum {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-1);
    padding-top: var(--ds-space-2);
}

.oview-sum-row {
    display: flex;
    justify-content: space-between;
    gap: var(--ds-space-3);
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
}

.oview-sum-row.is-discount {
    color: var(--ds-success-text);
}

.oview-sum-row.is-total {
    padding: var(--ds-space-1) 0;
    font-size: var(--ds-text-lg);
    font-weight: 700;
    color: var(--ds-text-primary);
}

.oview-sum-row.is-due {
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-danger-text);
}

.oview-notes {
    margin: 0;
    padding: var(--ds-space-3);
    border-radius: var(--ds-radius-md);
    background: var(--ds-bg-inset);
    font-size: var(--ds-text-sm);
    white-space: pre-wrap;
    color: var(--ds-text-primary);
}

.oview-empty {
    margin: 0;
    color: var(--ds-text-secondary);
    font-size: var(--ds-text-sm);
}

.oview-dl {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--ds-space-2) var(--ds-space-4);
    margin: 0;
    font-size: var(--ds-text-sm);
}

.oview-dl dt {
    color: var(--ds-text-secondary);
}

.oview-dl dd {
    margin: 0;
    text-align: end;
    color: var(--ds-text-primary);
}

.oview-foot {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
    padding: var(--ds-space-3) var(--ds-space-5) var(--ds-space-4);
    border-top: 1px solid var(--ds-border);
    background: var(--ds-surface);
}

.oview-foot-actions {
    display: flex;
    gap: var(--ds-space-2);
}

.oview-foot-actions .ds-btn {
    flex: 1;
}

.oview-foot-note,
.oview-foot-hint {
    margin: 0;
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
}

.oview-foot-hint {
    text-align: end;
}
