/* ==========================================================================
   ORDERS PAGE
   ========================================================================== */

/* Filter tabs strip — reuses .account-tab but housed in .orders-filter-tabs */
.orders-filter-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--sbv2-line, #E0E0E0);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    padding: 0 var(--space-lg);
    background: var(--sbv2-bg, #F4F4F4);
}
.orders-filter-tabs::-webkit-scrollbar {
    display: none; /* Chrome / Safari / Edge */
}

/* Count badge next to tab label */
.orders-tab-count {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    background: var(--sbv2-line, #E0E0E0);
    color: var(--sbv2-muted, #666666);
    margin-left: 0.3rem;
    vertical-align: middle;
}

.account-tab--active .orders-tab-count {
    background: var(--sbv2-ink, #111111);
    color: var(--sbv2-paper, #FFFFFF);
}

/* Empty-state when a filter has zero matching orders */
.orders-filter-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
}

.orders-filter-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--sbv2-bg, #F4F4F4);
    color: var(--sbv2-muted-2, #AAAAAA);
    margin-bottom: var(--space-xs);
    flex-shrink: 0;
}

.orders-filter-empty-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--sbv2-ink-2, #444444);
    margin: 0;
}

.orders-filter-empty-body {
    font-size: 0.8125rem;
    color: var(--sbv2-muted-2, #696860);
    margin: 0;
    max-width: 28ch;
}

.orders-filter-empty-cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: var(--space-sm);
    min-height: 44px;
    padding: 0.5rem 1.125rem;
    background: var(--sbv2-ink, #111111);
    color: var(--sbv2-paper, #FFFFFF);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--duration) var(--ease);
}
.orders-filter-empty-cta:hover {
    background: var(--sbv2-ink-2, #2A2A26);
    color: var(--sbv2-paper, #FFFFFF);
}
.orders-filter-empty-cta:focus-visible {
    outline: 2px solid var(--sbv2-ink, #111111);
    outline-offset: 3px;
}

@media (max-width: 480px) {
    .orders-filter-tabs {
        padding: 0 var(--space-md);
    }
    /* Ensure tabs are touch-friendly at narrow widths */
    .orders-filter-tab {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .orders-filter-tabs .account-tab {
        transition: none;
    }
}

.orders-card-content {
    padding: 0;
}

.order-row {
    display: grid;
    grid-template-columns: 48px 1fr auto auto 16px;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--sbv2-tint, #EEEEEE);
    transition: background var(--duration) var(--ease);
}

.order-row:last-child {
    border-bottom: none;
}

.order-row:hover {
    background: var(--sbv2-bg, #F4F4F4);
}

.order-row:focus-visible,
.order-row:has(.order-row-link:focus-visible) {
    outline: none;
    background: var(--sbv2-bg, #F4F4F4);
    box-shadow: inset 0 0 0 2px var(--sbv2-ink, #111111);
}

.order-row-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--sbv2-tint, #EEEEEE);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sbv2-muted-2, #AAAAAA);
    flex-shrink: 0;
}

.order-row-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.order-row-info {
    min-width: 0;
}

.order-row-top {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: 0.125rem;
}

.order-row-number {
    font-weight: 600;
    font-size: 0.875rem;
}

.order-row-date {
    font-size: 0.8125rem;
    color: var(--sbv2-muted, #666666);
}

.order-row-products {
    font-size: 0.8125rem;
    color: var(--sbv2-muted, #666666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* On mobile allow product names to wrap to 2 lines so long furniture names
   are readable instead of clipped after ~10 characters */
@media (max-width: 768px) {
    .order-row-products {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: unset;
    }
}

/* Compact delivery-window hint on the orders LIST rows (pending/processing/
   on-hold only) — surfaces the same estimate as the order-detail page so
   customers can see "where's my order" without opening it. */
.order-row-delivery {
    font-size: 0.75rem;
    color: var(--sbv2-moss, #15803d);
    margin-top: 0.125rem;
}

/* Item 390: real scheduled-transport states reuse the same urgency cue
   the order-detail page's .order-transport-status modifiers already use. */
.order-row-delivery--overdue {
    color: var(--sbv2-rust, #b91c1c);
}

.order-row-delivery--today,
.order-row-delivery--tomorrow {
    color: var(--sbv2-amber, #d97706);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-badge.status-pending {
    background: var(--sbv2-amber-soft, #fef9c3);
    color: var(--sbv2-amber, #92400e);
}

.status-badge.status-processing {
    background: #eff6ff;
    color: #1d4ed8;
}

.status-badge.status-on-hold {
    background: var(--sbv2-amber-soft, #fef9c3);
    color: var(--sbv2-amber, #92400e);
}

.status-badge.status-completed {
    background: var(--sbv2-moss-soft, #dcfce7);
    color: var(--sbv2-moss, #15803d);
}

.status-badge.status-cancelled,
.status-badge.status-refunded,
.status-badge.status-failed {
    background: var(--sbv2-rust-soft, #fee2e2);
    color: var(--sbv2-rust, #b91c1c);
}

/* Custom Tresser order statuses (wc-pending-accept / wc-accepted / wc-declined) */
.status-badge.status-pending-accept {
    background: #fff7ed;
    color: #9a3412;
}

.status-badge.status-accepted {
    background: var(--sbv2-moss-soft, #dcfce7);
    color: var(--sbv2-moss, #15803d);
}

.status-badge.status-declined {
    background: var(--sbv2-rust-soft, #fee2e2);
    color: var(--sbv2-rust, #b91c1c);
}

/* Pulsing live-dot for orders actively in progress — helps customers instantly
   identify which orders need attention without scanning badge text.
   Uses ::before pseudo-element so no HTML changes needed.
   Respects prefers-reduced-motion (dot stays visible but static). */
.status-badge.status-processing::before,
.status-badge.status-pending-accept::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 5px;
    vertical-align: middle;
    opacity: 0.85;
    animation: status-dot-pulse 1.8s ease-in-out infinite;
}

@keyframes status-dot-pulse {
    0%, 100% { opacity: 0.85; transform: scale(1); }
    50%       { opacity: 0.35; transform: scale(0.7); }
}

@media (prefers-reduced-motion: reduce) {
    .status-badge.status-processing::before,
    .status-badge.status-pending-accept::before,
    .msg-status-open::before {
        animation: none;
    }
}

.order-row-total {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Mobile total — shown inside .order-row-info at ≤768px, hidden on desktop */
.order-row-total-inline {
    display: none;
}

.order-row-arrow {
    color: var(--sbv2-line-strong, #CCCCCC);
    flex-shrink: 0;
    transition: color var(--duration) var(--ease);
}

.order-row:hover .order-row-arrow {
    color: var(--sbv2-muted, #666666);
}

/* Selectable reservation rows — checkbox column + link participates in the
   same grid via display:contents so thumb/info/status/total/arrow keep their
   existing column alignment (#1461). */
.order-row--selectable {
    grid-template-columns: 20px 48px 1fr auto auto 16px;
}

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

.order-row-select input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.order-row-link {
    display: contents;
    color: inherit;
    text-decoration: none;
}

.order-row-age {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--sbv2-muted, #666666);
}

.order-row-age--overdue {
    font-weight: 600;
    color: var(--sbv2-rust, #b91c1c);
}

/* Self-service reservation cancel (item 266) — a sibling of .order-row-link
   (not nested inside the <a>, so its click doesn't also trigger navigation),
   explicitly placed under the status column since it's the 6th grid item in
   a 5-column .order-row. */
.reservation-cancel-btn {
    grid-column: 3;
    grid-row: 2;
    justify-self: start;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--sbv2-muted, #666666);
    background: none;
    border: none;
    padding: 0;
    margin-top: 0.25rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.reservation-cancel-btn:hover,
.reservation-cancel-btn:focus-visible {
    color: var(--sbv2-rust, #b91c1c);
}

.reservation-cancel-btn:disabled {
    color: var(--sbv2-muted-2, #AAAAAA);
    cursor: not-allowed;
    text-decoration: none;
}

.reservation-group-send {
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--sbv2-ink, #111111);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    white-space: nowrap;
}

.reservation-group-send:hover:not(:disabled) {
    text-decoration: underline;
}

.reservation-group-send:disabled {
    color: var(--sbv2-muted-2, #AAAAAA);
    cursor: not-allowed;
}

/* "I butikken" reservations grouped by customer (#1461) */
.reservation-group {
    margin-bottom: var(--space-lg);
    border: 1px solid var(--sbv2-tint, #EEEEEE);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.reservation-group:last-child {
    margin-bottom: 0;
}

.reservation-group-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-lg);
    background: var(--sbv2-bg, #F4F4F4);
    border-bottom: 1px solid var(--sbv2-tint, #EEEEEE);
}

.reservation-group-name {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.reservation-group-noaccount {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--sbv2-muted, #666666);
    background: var(--sbv2-tint, #EEEEEE);
    border-radius: var(--radius-sm, 4px);
    padding: 2px 6px;
}

.reservation-group-count {
    font-size: 0.8125rem;
    color: var(--sbv2-muted, #666666);
    margin-right: auto;
}

.reservation-group-action {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--sbv2-ink, #111111);
    text-decoration: none;
    white-space: nowrap;
}

.reservation-group-action:hover {
    text-decoration: underline;
}

.reservation-group .order-row {
    border-bottom: 1px solid var(--sbv2-tint, #EEEEEE);
}

.reservation-group .order-row:last-child {
    border-bottom: none;
}

@media (max-width: 768px) {
    .reservation-group-header {
        flex-wrap: wrap;
    }

    .reservation-group-count {
        margin-right: 0;
        flex-basis: 100%;
        order: 3;
    }
}

.orders-empty-inline {
    text-align: center;
    padding: var(--space-xl) 0;
}

.orders-empty-inline p {
    color: var(--sbv2-muted, #666666);
    margin-bottom: var(--space-lg);
}

@media (max-width: 768px) {
    .order-row {
        grid-template-columns: 40px 1fr auto;
        align-items: start;
        gap: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
    }

    .order-row-thumb {
        width: 40px;
        height: 40px;
        /* Optically align thumb with order number line rather than entire multi-line info block */
        align-self: start;
        padding-top: 2px;
    }

    .order-row-total,
    .order-row-arrow {
        display: none;
    }

    .order-row-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.125rem;
    }

    /* Show inline total inside info cell; hide the separate grid column */
    .order-row-total-inline {
        display: block;
        font-weight: 600;
        font-size: 0.8125rem;
        color: var(--sbv2-ink, #111827);
        margin-top: 0.25rem;
    }
}

/* "Se lignende møbler" discovery strip on completed order rows */
.order-row-similar {
    padding: 0.375rem var(--space-lg) 0.375rem calc(48px + var(--space-lg) + var(--space-md));
    border-bottom: 1px solid var(--sbv2-tint, #EEEEEE);
    background: var(--sbv2-bg, #F4F4F4);
}

.order-row-similar:last-of-type {
    border-bottom: none;
}

.order-row-similar-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--sbv2-muted, #666666);
    text-decoration: none;
    transition: color var(--duration) var(--ease);
}

.order-row-similar-link:hover {
    color: var(--sbv2-ink, #111111);
    text-decoration: underline;
}

.order-row-similar-link:focus-visible {
    outline: 2px solid var(--sbv2-ink, #111111);
    outline-offset: 2px;
    border-radius: 2px;
    color: var(--sbv2-ink, #111111);
}

@media (max-width: 768px) {
    .order-row-similar {
        padding: 0.375rem var(--space-md) 0.375rem calc(40px + var(--space-md) + var(--space-sm));
    }
}

/* Touch devices: "Se lignende" link must be tall enough to tap (WCAG 2.5.5).
   The link renders as ~0.75rem text (~18px) — on touch screens without hover
   there is no secondary affordance, so enforce 44px minimum height. */
@media (hover: none) {
    .order-row-similar-link {
        min-height: 44px;
    }
}

