/* История заказов — полноэкранная модалка как order-modal-content */

#orders-history-modal .oh-sheet {
    max-width: 640px;
}

#orders-history-modal .oh-sheet > .oh-sheet__header {
    flex-shrink: 0;
}

/* Header */
#orders-history-modal .oh-sheet__header {
    align-items: flex-start;
    gap: 12px;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.oh-sheet__intro {
    min-width: 0;
    flex: 1;
}

#orders-history-modal .oh-sheet__intro h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: var(--text);
}

.oh-sheet__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 5px;
    margin: 5px 0 0;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: var(--muted);
}

.oh-sheet__client {
    font-weight: 600;
    color: var(--text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oh-sheet__sep {
    opacity: 0.45;
    user-select: none;
}

.oh-sheet__count {
    white-space: nowrap;
}

#orders-history-modal .modal-close {
    margin-top: -2px;
}

/* Body */
#orders-history-modal .oh-sheet__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px 16px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    background: var(--bg);
}

/* States */
.oh-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
}

.oh-state h3 {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.oh-state p {
    margin: 0 auto;
    font-size: 0.875rem;
    line-height: 1.45;
    max-width: 280px;
}

.oh-state__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: var(--card);
    border: 1px solid rgba(0, 0, 0, 0.07);
    color: var(--muted);
}

.oh-state__icon svg {
    width: 24px;
    height: 24px;
}

.oh-state__icon--error {
    color: #dc2626;
    background: #fef2f2;
}

.oh-state__spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 14px;
    border: 3px solid rgba(60, 179, 113, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: oh-spin 0.7s linear infinite;
}

@keyframes oh-spin {
    to { transform: rotate(360deg); }
}

.oh-device-prompt {
    background: var(--card);
    border-radius: 16px;
    padding: 1.75rem 1.25rem;
    border: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: var(--shadow);
}

.oh-device-id {
    width: 100%;
    max-width: 320px;
    margin: 1rem auto 0;
    text-align: left;
}

.oh-device-id__label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.oh-device-id__copy {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    background: var(--bg);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.oh-device-id__copy:active {
    border-color: rgba(60, 179, 113, 0.45);
    background: rgba(60, 179, 113, 0.06);
}

.oh-device-id__value {
    display: block;
    font-size: 0.8125rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--text);
    word-break: break-all;
    line-height: 1.4;
}

.oh-device-id__hint {
    font-size: 0.75rem;
    color: var(--muted);
}

.oh-device-prompt .oh-whatsapp-btn {
    width: 100%;
    max-width: 300px;
    min-height: 48px;
    margin: 1rem auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 14px;
    background: #25d366;
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

/* Order list — компактные строки в одной панели */
.oh-list {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.oh-card {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.oh-card:last-child {
    border-bottom: none;
}

.oh-card__trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: transparent;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.15s ease;
}

.oh-card__trigger:active {
    background: rgba(0, 0, 0, 0.04);
}

.oh-card.is-open {
    position: relative;
    z-index: 1;
    box-shadow: inset 0 0 0 1px rgba(60, 179, 113, 0.22);
}

.oh-card.is-open + .oh-card {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.oh-card__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--muted);
}

.oh-card--delivered .oh-card__dot,
.oh-card--ready_for_delivery .oh-card__dot {
    background: var(--primary);
}

.oh-card--pending .oh-card__dot {
    background: #3b82f6;
}

.oh-card--cancelled .oh-card__dot {
    background: #ef4444;
}

.oh-card__content {
    flex: 1;
    min-width: 0;
}

.oh-card__line1 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.oh-card__id {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.oh-card__sum {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.oh-card__line2 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 5px;
    margin-top: 2px;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: var(--muted);
}

.oh-card__sep {
    opacity: 0.45;
    user-select: none;
}

.oh-card__status--delivered,
.oh-card__status--ready {
    color: var(--muted);
}

.oh-card__status--pending {
    color: #60a5fa;
}

.oh-card__status--cancelled {
    color: #f87171;
}

.oh-card__pay--paid {
    color: var(--muted);
}

.oh-card__pay--unpaid {
    color: #fb923c;
    font-weight: 500;
}

.oh-card__arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    opacity: 0.45;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.oh-card.is-open .oh-card__arrow {
    transform: rotate(90deg);
    opacity: 0.7;
}

.oh-card__body {
    display: none;
    padding: 10px 14px 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(0, 0, 0, 0.02);
}

.oh-card.is-open .oh-card__body {
    display: block;
}

/* Контакты */
.oh-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.oh-meta__item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text);
}

.oh-meta__item--link {
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    transition: background 0.15s ease;
}

.oh-meta__item--link:active {
    background: rgba(60, 179, 113, 0.08);
}

.oh-meta__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
    opacity: 0.7;
}

.oh-meta__item--link .oh-meta__icon {
    opacity: 1;
}

/* Чек */
.oh-receipt {
    background: var(--card);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    overflow: hidden;
}

.oh-receipt__items {
    list-style: none;
    margin: 0;
    padding: 4px 12px;
}

.oh-receipt__item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.oh-receipt__item:last-child {
    border-bottom: none;
}

.oh-receipt__item-main {
    min-width: 0;
    flex: 1;
}

.oh-receipt__item-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.35;
}

.oh-receipt__item-note {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--muted);
}

.oh-receipt__item-sum {
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.oh-receipt__empty {
    padding: 12px 0;
    text-align: center;
    font-size: 0.875rem;
    color: var(--muted);
}

.oh-receipt__totals {
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.02);
}

.oh-receipt__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    font-size: 0.8125rem;
    color: var(--muted);
}

.oh-receipt__row span:last-child {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.oh-receipt__row--total {
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}

.oh-comment {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-left: 3px solid var(--primary);
}

.oh-comment__text {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.45;
}

.oh-card__actions {
    margin-top: 12px;
}

.oh-repeat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.oh-repeat-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.oh-repeat-btn:active {
    opacity: 0.92;
    transform: scale(0.99);
}

#orders-history-modal .oh-sheet__footer {
    display: none;
}

/* Desktop */
@media (min-width: 769px) {
    #orders-history-modal .oh-sheet {
        max-width: min(640px, calc(100% - 32px));
    }

    #orders-history-modal .oh-sheet__header {
        padding: 1.125rem 1.5rem;
    }

    #orders-history-modal .oh-sheet__body {
        padding: 14px 18px 18px;
    }

    #orders-history-modal .oh-sheet__footer {
        display: flex;
        padding: 12px 18px;
        border-top: 1px solid rgba(0, 0, 0, 0.06);
        background: var(--card);
        flex-shrink: 0;
    }

    .oh-close-btn {
        flex: 1;
        min-height: 44px;
        border: 1px solid rgba(0, 0, 0, 0.08);
        border-radius: 14px;
        background: var(--bg);
        color: var(--text);
        font-size: 0.9375rem;
        font-weight: 600;
        font-family: inherit;
        cursor: pointer;
    }
}

@media (prefers-color-scheme: dark) {
    #orders-history-modal .oh-sheet__header {
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    .oh-list {
        border-color: rgba(255, 255, 255, 0.08);
    }

    .oh-card {
        border-bottom-color: rgba(255, 255, 255, 0.06);
    }

    .oh-card__trigger:active {
        background: rgba(255, 255, 255, 0.04);
    }

    .oh-card.is-open {
        box-shadow: inset 0 0 0 1px rgba(60, 179, 113, 0.3);
    }

    .oh-card.is-open + .oh-card {
        border-top-color: rgba(255, 255, 255, 0.06);
    }

    .oh-card__body {
        border-top-color: rgba(255, 255, 255, 0.06);
        background: rgba(0, 0, 0, 0.15);
    }

    .oh-meta__item {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.08);
    }

    .oh-receipt {
        border-color: rgba(255, 255, 255, 0.08);
    }

    .oh-receipt__item {
        border-bottom-color: rgba(255, 255, 255, 0.06);
    }

    .oh-receipt__totals {
        border-top-color: rgba(255, 255, 255, 0.08);
        background: rgba(0, 0, 0, 0.15);
    }

    .oh-receipt__row--total {
        border-top-color: rgba(255, 255, 255, 0.12);
    }

    .oh-comment {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.08);
    }

    .oh-device-id__copy {
        border-color: rgba(255, 255, 255, 0.12);
        background: rgba(0, 0, 0, 0.2);
    }

    .oh-device-id__copy:active {
        border-color: rgba(60, 179, 113, 0.45);
        background: rgba(60, 179, 113, 0.1);
    }
}
