/* 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;
}

.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;
    padding: var(--ds-space-1);
    border-radius: var(--ds-radius-sm);
    line-height: 0;
}

.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;
}

.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);
}

.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) {
    .orders-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .orders-filter-field,
    .orders-filter-field--wide {
        width: 100%;
        min-width: unset;
    }

    .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;
    }
}
