/*
 * transactions.css
 *
 * Transactions view: list rows with product thumbnails and status chips,
 * consolidation banner, and the detail sheet that holds the Tax Free actions
 * (issue / consolidate / reprint / void) and Return items. The detail sheet
 * styles (.detail-side / .detail-sheet) are shared with the customer profile.
 */

.consolidation-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: var(--r-24);
    background: var(--accent-tint);
}

.consolidation-banner__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tx-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tx-row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    padding: 14px 18px;
    border: 0;
    border-radius: var(--r-22);
    background: var(--surface);
    text-align: left;
    transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}

@media (hover: hover) and (pointer: fine) {
    .tx-row:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: var(--shadow-hover);
    }
}

.tx-row:active:not(:disabled) {
    transform: scale(.99);
}

.transaction-list-item.is-selected .tx-row {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.transaction-list-item.highlighted-transaction .tx-row {
    animation: tx-highlight 2s ease-out;
}

@keyframes tx-highlight {
    0%,
    40% {
        background: var(--accent-tint);
    }

    100% {
        background: var(--surface);
    }
}

.transaction-list-item.can-be-added-now .tx-row {
    box-shadow: inset 0 0 0 2px var(--accent-ring);
}

@media (hover: hover) and (pointer: fine) {
    .transaction-list-item.can-be-added-now .tx-row:hover {
        box-shadow: inset 0 0 0 2px var(--accent);
    }
}

.transaction-list-item.is-in-consolidation-list .tx-row {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.transaction-list-item.cannot-be-added-now:not(.is-in-consolidation-list) .tx-row {
    opacity: .45;
}

.tx-row:disabled {
    cursor: default;
}

.tx-row__thumbs {
    display: flex;
    flex: none;
    padding-right: 12px;
}

.tx-row__thumb {
    width: 46px;
    height: 46px;
    margin-right: -12px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--hairline);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.tx-row__thumb img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.tx-row__thumb--empty {
    color: var(--muted);
    background: var(--surface-2);
}

.tx-row__main {
    flex: 1 1 220px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tx-row__id {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: var(--fs-button);
}

.tx-row__id .chip {
    padding: 2px 8px;
}

.tx-row__meta {
    font-size: var(--fs-secondary);
    color: var(--muted);
}

.tx-row__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tx-row__chips:empty {
    display: none;
}

.tx-row__total {
    min-width: 110px;
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
    font-size: calc(var(--fs-card) * var(--amount-scale, 1));
    font-weight: 800;
    letter-spacing: -0.01em;
}

.tx-row__total.is-negative {
    color: var(--warning-text);
}

/* ---------- Detail sheet (also used by the customer profile) ---------- */

.detail-backdrop {
    display: none;
}

.detail-close {
    display: none;
}

.detail-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.detail-head .dialog__title {
    white-space: nowrap;
}

.detail-head__end {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

.detail-head__end .chip {
    padding: 6px 12px;
}

.detail-customer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-20);
    background: var(--surface-2);
}

.detail-customer .avatar {
    width: 42px;
    height: 42px;
    font-size: var(--fs-body);
}

.detail-customer__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.detail-customer__name {
    font-weight: 700;
}

.detail-customer__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-secondary);
    color: var(--muted);
}

.detail-lines {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.detail-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.detail-line .cart-line__thumb {
    width: 52px;
    height: 52px;
}

.detail-line__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-secondary);
    color: var(--muted);
}

.detail-line__meta .chip {
    padding: 2px 8px;
}

.detail-line__total {
    font-weight: 800;
    white-space: nowrap;
}

/* The sheet is a size container: its layout follows its own width, not the window's
   (the desktop column narrows when the Dev panel is open) */
.detail-sheet {
    container: detail / inline-size;
}

.detail-figures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.detail-figures .soft__value {
    white-space: nowrap;
}

@container detail (max-width: 460px) {
    .detail-figures {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-figures .soft:last-child {
        grid-column: 1 / -1;
    }
}

/* Very narrow column (desktop beside the Dev panel): paired buttons stack instead of wrapping their labels */
@container detail (max-width: 360px) {
    .detail-sheet .btn-pair {
        grid-auto-flow: row;
        grid-template-columns: minmax(0, 1fr);
    }
}

.detail-figures .soft {
    padding: 10px 12px;
}

.detail-figures__total {
    font-size: var(--fs-card);
}

.detail-links {
    font-size: var(--fs-secondary);
    color: var(--muted);
}

.detail-return {
    min-height: 56px;
    border-radius: var(--r-18);
}

.panel .btn {
    width: 100%;
}

.panel .btn-pair .btn {
    width: auto;
}

.panel__title--warning {
    color: var(--warning-text);
}

.panel--warning .panel__text {
    color: var(--warning-text-strong);
}

.consolidation-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.consolidation-list__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 14px;
    border-radius: var(--r-16);
    background: var(--surface);
}

.consolidation-list__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.consolidation-list__id {
    font-weight: 700;
    white-space: nowrap;
}

.consolidation-list__count {
    min-width: 26px;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .24);
    font-size: var(--fs-secondary);
}

.consolidation-list .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--r-12);
}

/* ---------- Return dialog ---------- */

.return-items-list {
    display: flex;
    flex-direction: column;
    max-height: min(50vh, 420px);
    overflow-y: auto;
}

.return-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.return-item + .return-item {
    border-top: 1px solid var(--hairline);
}

.return-item.is-disabled {
    opacity: .5;
}

.return-item__qty .input {
    width: 84px;
    height: 48px;
    text-align: center;
    font-weight: 800;
}

.return-summary {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
}

.return-summary__value {
    font-size: var(--fs-title);
}

.void-confirm-modal {
    max-width: 480px;
}

.void-confirm-modal__message {
    white-space: pre-wrap;
    margin-top: 6px;
}

/* ---------- Phones: compact rows ---------- */

@media (max-width: 767px) {
    .tx-row {
        padding: 12px 14px;
        gap: 10px 12px;
    }

    .tx-row__thumbs {
        display: none;
    }

    .tx-row__total {
        min-width: 0;
    }
}

/* ---------- Tablets and phones: detail sheet opens over the list ---------- */

@media (max-width: 1023px) {
    .detail-side {
        display: none;
    }

    .detail-side.is-open {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: var(--z-detail);
        align-items: flex-end;
        justify-content: center;
        padding: 12px;
        max-height: none;
    }

    .detail-side.is-open .detail-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(201, 205, 213, .72);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        animation: sf-fade var(--dur-fast) var(--ease);
    }

    .detail-side.is-open .detail-sheet {
        position: relative;
        width: 100%;
        max-width: 560px;
        max-height: calc(100vh - 72px);
        max-height: calc(100dvh - 72px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
        animation: sf-sheet-up var(--dur-enter) var(--ease);
    }

    .detail-close {
        display: inline-flex;
    }
}

@keyframes sf-sheet-up {
    from {
        transform: translateY(40px);
        opacity: 0;
    }
}
