/* Product previews remain visible when order details are collapsed. */
.order-card.has-order-badges { position: relative; }
.has-order-badges .order-status-stack { padding-top: 18px; }
.order-card-badges {
    position: absolute;
    top: 0;
    left: 20px;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.order-card .order-urgent-badge {
    background: #f8f5f6;
    color: #bca7b0;
}
.order-card .order-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 32px;
    height: 26px;
    padding: 3px 8px;
    border: 0;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    font-family: inherit;
    cursor: default;
}
.order-icon-badge svg { width: 19px; height: 19px; fill: currentColor; }
.order-icon-badge img { display: block; object-fit: contain; }
.order-card button.order-icon-badge,
.order-card a.order-icon-badge { cursor: pointer; }
.order-card button.order-icon-badge:disabled { cursor: default; }
.order-card .order-invoice-badge {
    background: #eaf2ec;
    color: #6e917c;
}
.order-card .order-invoice-badge:hover { background: #deebe2; }
.order-card .order-icon-badge:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}
.order-carrier-badge { background: #eef1f4; color: #748797; }
a.order-carrier-badge:hover { filter: brightness(.95); }
.order-payment-badge { position: relative; background: #eaf0f8; color: #6886b0; }
.order-payment-count {
    position: absolute;
    top: 0;
    right: -4px;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 999px;
    background: #8da3c4;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
}
.order-badge-tooltip {
    position: fixed;
    z-index: 10000;
    max-width: calc(100vw - 32px);
    padding: 8px 11px;
    border-radius: 8px;
    background: #172033;
    color: #fff;
    box-shadow: 0 4px 14px #0f172a26;
    font-family: inherit;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-line;
    pointer-events: none;
}
.order-badge-tooltip[hidden] { display: none; }
.order-card .order-urgent-badge:hover:not(:disabled) {
    background: #f1dde5;
    color: #9d5972;
    text-decoration: none;
}
.order-card .order-urgent-badge.is-active {
    background: #f2dce4;
    color: #a34f6c;
}
.order-card .order-urgent-badge:focus-visible {
    outline: 2px solid #be123c;
    outline-offset: 2px;
}
.order-header {
    display: grid;
    grid-template-columns: 170px 180px minmax(0, 1fr) 180px;
    align-items: center;
    padding: 16px 20px;
    gap: 16px;
}
.order-header > .order-info { min-width: 0; overflow-wrap: anywhere; }
.order-header > .order-status-stack { min-width: 0; }
.order-header .order-status-group,
.order-header .order-payment-pending-actions { flex-wrap: wrap; }
.order-header > .order-total { grid-column: 4; white-space: nowrap; margin-left: 12px; justify-content: flex-end; }
.order-products-preview {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    cursor: pointer;
    width: 100%;
    /* Four 92px images, three image gaps and space for both arrows. */
    max-width: 444px;
    justify-self: start;
    margin: 0;
}
.order-products-track {
    display: flex;
    flex: 1;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
    padding: 0;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}
.order-products-track::-webkit-scrollbar { display: none; }
.order-products-track:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.order-preview-arrow {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    background: var(--color-white);
    color: var(--color-text-dark);
    cursor: pointer;
}
.order-preview-arrow svg { width: 16px; height: 16px; fill: currentColor; }
.order-products-preview.is-compact .order-preview-arrow { visibility: hidden; pointer-events: none; }
.order-preview-more {
    position: absolute;
    top: -14px;
    right: 0;
    padding: 2px 5px;
    border-radius: 8px;
    background: #56677f;
    color: var(--color-white);
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    white-space: nowrap;
    pointer-events: none;
}
.order-preview-rest { display: none; }
.order-preview-arrow:disabled { opacity: 0.3; cursor: default; }
.order-preview-arrow:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.order-preview-arrow:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.order-product-preview {
    scroll-snap-align: start;
    position: relative;
    display: block;
    flex: 0 0 calc((100% - 12px) / 4);
    width: calc((100% - 12px) / 4);
    aspect-ratio: 1;
    overflow: hidden;
    border: none;
    border-radius: 0;
    background: var(--color-white);
}
.order-product-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    object-fit: contain;
    /* transform: scale(1.2); */
    transform-origin: center;
    background: var(--color-white);
}
.order-product-preview-qty {
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 1;
    min-width: 22px;
    padding: 1px 5px;
    border-radius: 9999px;
    background-color: #64748b;
    font-size: 10px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    color: #fff;
}
.order-product-preview-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-light);
}
.order-product-preview-fallback svg { width: 24px; height: 24px; fill: currentColor; }
a.order-product-preview:focus-visible {
    outline: 1px solid var(--color-text-light);
    outline-offset: -2px;
}
.order-detail-products {
    max-height: 448px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    scrollbar-gutter: stable;
    padding: 2px 6px 2px 2px;
}
.order-detail-products:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 8px;
}
.order-detail-products .product-text { min-width: 0; overflow-wrap: anywhere; }
.order-detail-products .product-meta { flex-wrap: wrap; }
.order-detail-products .product-price { flex-shrink: 0; }
.order-detail-products .product-item { gap: 16px; }
@media (max-width: 1200px) {
    .order-header { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; }
    .order-header > .order-status-stack { grid-column: 1 / -1; }
    .order-header > .order-total { grid-column: 2; grid-row: 2; margin-left: 0; }
    .order-products-preview { grid-column: 1 / -1; max-width: 300px; }
}
@media (max-width: 768px) {
    .order-card-badges { left: 12px; }
    .order-header { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 10px; }
    .order-header > .order-total { grid-column: 1; grid-row: auto; justify-content: space-between; }
    .order-status-stack,
    .order-status-group,
    .order-payment-pending-actions { min-width: 0; flex-wrap: wrap; }
    .order-meta { flex-wrap: wrap; gap: 8px; }
    .order-header { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
    .order-header > .order-status-stack,
    .order-header > .order-info { grid-column: 1 / -1; }
    .order-header > .order-total { grid-column: 2; grid-row: auto; justify-content: flex-end; }
    .order-products-preview { position: relative; grid-column: 1; max-width: none; gap: 8px; padding-top: 6px; }
    .order-preview-arrow { display: none; }
    .order-products-track { flex: 0 0 auto; gap: 8px; overflow: visible; }
    .order-products-track .order-product-preview { flex: 0 0 48px; width: 48px; overflow: visible; }
    .order-products-track .order-product-preview-qty { top: -6px; right: -6px; min-width: 24px; padding: 1px 6px; border: 2px solid #fff; font-size: 11px; line-height: 15px; }
    .order-header .total-amount { font-size: 17px; }
    .order-products-track .order-product-preview:nth-child(n + 4) { display: none; }
    .order-products-preview:has(.order-preview-rest) .order-product-preview:nth-child(3) .order-product-preview-qty { display: none; }
    .order-preview-rest {
        position: absolute;
        top: 6px;
        left: 112px;
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        border-radius: 8px;
        background: rgba(86, 103, 127, 0.9);
        font-size: 14px;
        font-weight: 700;
        color: #fff;
        pointer-events: none;
    }
    .order-card .order-details { padding: 8px; }
    .order-detail-products { max-height: min(448px, 60vh); }
    .order-detail-products .product-item { padding: 12px; }
    .order-detail-products .product-item-link { width: 100%; }
}
@media (max-width: 380px) {
    .order-products-track .order-product-preview { flex-basis: 40px; width: 40px; }
    .order-header .total-amount { font-size: 16px; }
    .order-products-preview,
    .order-products-track { gap: 6px; }
    .order-preview-rest { left: 92px; width: 40px; height: 40px; }
}
@media (max-width: 355px) {
    .order-header > .order-total { grid-column: 1 / -1; }
}
