/**
 * 1688buyer Storefront Header Orders Quick View
 * Desktop Popover (> 768px) & Swipeable Mobile Bottom Sheet (<= 768px)
 * Airy, regular-400 typography in 100% parity with Notification Center & Cart Drawer
 */

.header-orders-wrap {
    position: relative;
    display: inline-flex;
    align-items: flex-start;
}

.header-orders-wrap.open .orders-trigger-btn,
.header-orders-wrap.open .orders-trigger-btn i,
.orders-trigger-btn.is-active,
.orders-trigger-btn.is-active i {
    color: var(--primary-color, #ff5000);
}

/* Badge Counter - Regular 400 */
.cluster-orders-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    background: var(--brand-orange, #ff5000);
    color: #ffffff;
    font-family: var(--font-accent, 'DM Sans', -apple-system, sans-serif);
    font-size: 11px;
    font-weight: 400;
    height: 16px;
    min-width: 16px;
    width: auto;
    padding: 0 4px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 1.5px solid #ffffff;
    box-shadow: 0 1px 3px rgba(255, 80, 0, 0.28);
    box-sizing: border-box;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    overflow: visible !important;
    text-overflow: clip !important;
}

.orders-sheet-backdrop {
    display: none;
}

/* Desktop Popover Default */
.orders-dropdown-popover {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: -72px;
    width: 424px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.04);
    border: 1px solid #eef2f6;
    z-index: var(--z-dropdown, 80);
    overflow: hidden;
    font-family: inherit;
    font-weight: 400;
}

.orders-dropdown-popover,
.orders-dropdown-popover *,
.orders-dropdown-popover strong,
.orders-dropdown-popover b {
    font-weight: 400;
}

.orders-dropdown-popover .buyer-modal-drag-handle {
    display: none;
}

.header-orders-wrap.open .orders-dropdown-popover {
    display: block;
    animation: orders-qv-fade-in 0.18s ease-out;
}

@media (min-width: 769px) {
    .storefront-header:has(.header-orders-wrap.open.is-sticky-open) {
        z-index: var(--z-dropdown, 80);
    }

    .header-orders-wrap.open.is-sticky-open .orders-dropdown-popover {
        position: fixed;
        top: var(--orders-sticky-top, 60px);
        right: var(--orders-sticky-right, 24px);
    }
}

@keyframes orders-qv-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.orders-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px 11px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}

.orders-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: #0f172a;
    letter-spacing: -0.01em;
    min-width: 0;
}

.orders-active-pill {
    background: #fff5ef;
    color: #ea580c;
    border: 1px solid #fed7aa;
    font-size: 11px;
    line-height: 1.2;
    padding: 1px 7px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.orders-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.orders-header-all-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #64748b;
    font-size: 12px;
    text-decoration: none;
    padding: 4px 7px;
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
    white-space: nowrap;
}

.orders-header-all-link:hover {
    color: #ff5000;
    background: #fff7f2;
}

.orders-sheet-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.orders-sheet-close-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Filter Tabs */
.orders-qv-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    padding: 0 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.orders-qv-tabs::-webkit-scrollbar {
    display: none;
}

.orders-qv-tab {
    flex: 1 1 auto;
    background: transparent;
    border: none;
    padding: 10px 4px;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    text-align: center;
    transition: color 0.18s ease;
}

.orders-qv-tab:hover {
    color: #0f172a;
}

.orders-qv-tab.active {
    color: #ff5000;
}

.orders-qv-tab::after {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 0;
    height: 1.5px;
    border-radius: 2px;
    background: #ff5000;
    transform: scaleX(0);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.16s ease;
}

.orders-qv-tab.active::after {
    transform: scaleX(1);
    opacity: 1;
}

.orders-qv-tab-badge {
    display: inline-block;
    margin-left: 3px;
    font-size: 11px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
}

.orders-qv-tab.active .orders-qv-tab-badge {
    color: #ff5000;
}

/* Scrollable Order List */
.orders-qv-list-container {
    height: 360px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    background: #f8fafc;
}

.orders-qv-list-container.is-tab-loading::before {
    content: '';
    position: sticky;
    top: -10px;
    display: block;
    height: 2px;
    margin: -10px -10px 8px;
    background: linear-gradient(90deg, transparent 0%, #ff5000 50%, transparent 100%);
    background-size: 55% 100%;
    background-repeat: no-repeat;
    animation: sheetTabProgress 0.9s linear infinite;
    z-index: 2;
    pointer-events: none;
}

.orders-qv-list-container.is-tab-loading .orders-qv-items,
.orders-qv-list-container.is-tab-loading .orders-qv-empty {
    opacity: 0.45;
    transition: opacity 0.14s ease;
}

.orders-qv-list-container.is-tab-entering .orders-qv-items,
.orders-qv-list-container.is-tab-entering .orders-qv-empty {
    animation: sheetTabFadeIn 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.orders-qv-loading {
    min-height: 100%;
    padding: 32px 16px;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.orders-qv-empty {
    min-height: 100%;
    padding: 32px 20px;
    text-align: center;
    color: #94a3b8;
    background: #ffffff;
    border: 1px dashed #e2e8f0;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.orders-qv-empty p {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

.orders-qv-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual Order Card */
.orders-qv-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 11px 13px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    cursor: pointer;
}

.orders-qv-item:hover,
.orders-qv-item:focus-within {
    background: #fffcfa;
    border-color: #fdba74;
    box-shadow: 0 4px 12px rgba(255, 80, 0, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
}

.orders-qv-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.orders-qv-shop-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
}

.orders-qv-plat {
    flex-shrink: 0;
    font-size: 10.5px;
    line-height: 1.25;
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid #fed7aa;
    background: #fff7ed;
    color: #ea580c;
}

.orders-qv-plat.is-taobao {
    background: #fff5f0;
    border-color: #fdba74;
    color: #ea580c;
}

.orders-qv-plat.is-tmall {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.orders-qv-shop-name {
    font-size: 12px;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orders-qv-status {
    flex-shrink: 0;
    font-size: 11px;
    line-height: 1.25;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 400;
    white-space: nowrap;
}

.orders-qv-status.is-warning:not([class*="is-status-"]) {
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fed7aa;
}

.orders-qv-status.is-info:not([class*="is-status-"]) {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.orders-qv-status.is-success:not([class*="is-status-"]) {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.orders-qv-status.is-muted:not([class*="is-status-"]) {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.orders-qv-main-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    min-width: 0;
}

.orders-qv-thumb-link {
    display: inline-flex;
    flex-shrink: 0;
    text-decoration: none;
}

.orders-qv-thumb {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    border: 1px solid #f1f5f9;
    object-fit: cover;
    flex-shrink: 0;
    background: #f8fafc;
}

.orders-qv-info {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.orders-qv-title {
    display: block;
    font-size: 13px;
    line-height: 1.35;
    color: #0f172a;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.14s ease;
}

.orders-qv-title:hover {
    color: #ff5000;
}

.orders-qv-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 5px;
    font-size: 11.5px;
    color: #64748b;
    min-width: 0;
}

.orders-qv-code {
    font-family: var(--font-accent, 'DM Sans', monospace);
    color: #475569;
    text-decoration: none;
    transition: color 0.14s ease;
}

.orders-qv-code:hover {
    color: #ff5000;
}

.orders-qv-copy-btn {
    width: 20px;
    height: 20px;
    margin: 0;
}

.orders-qv-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px dashed #f1f5f9;
}

.orders-qv-amount-wrap {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-size: 12px;
    color: #64748b;
    min-width: 0;
}

.orders-qv-amount {
    font-size: 13px;
    color: #ea580c;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.orders-qv-cta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    text-decoration: none;
    padding: 3px 10px;
    border-radius: 999px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.orders-qv-cta:hover {
    color: #ff5000;
    border-color: #fdba74;
    background: #fff7ed;
}

.orders-qv-cta.is-urgent {
    color: #ea580c;
    background: #fff7ed;
    border-color: #fdba74;
}

.orders-qv-time {
    font-size: 11.5px;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Footer */
.orders-popover-footer {
    padding: 10px 16px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
    text-align: center;
    flex-shrink: 0;
}

.orders-view-all-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #ff5000;
    font-size: 12.5px;
    text-decoration: none;
}

.orders-view-all-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Mobile Bottom Sheet Transformation (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .storefront-header:has(.header-orders-wrap.open) {
        z-index: var(--z-modal-dialog, 230) !important;
    }

    .header-orders-wrap.open .orders-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: var(--z-modal-backdrop, 220);
        background: var(--overlay-backdrop-bg, rgba(15, 23, 42, 0.28));
        backdrop-filter: blur(var(--overlay-backdrop-blur, 1px));
        -webkit-backdrop-filter: blur(var(--overlay-backdrop-blur, 1px));
        animation: orders-backdrop-fade 0.2s ease-out;
    }

    .orders-dropdown-popover {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100%;
        max-width: 100%;
        height: min(76dvh, 620px);
        max-height: min(85dvh, 680px);
        margin: 0;
        border-radius: 16px 16px 0 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border: none;
        border-top: 1px solid rgba(15, 23, 42, 0.06);
        box-shadow: 0 -10px 32px rgba(15, 23, 42, 0.18);
        z-index: var(--z-modal-dialog, 230);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        touch-action: pan-y;
        overscroll-behavior-y: contain;
    }

    .header-orders-wrap.open .orders-dropdown-popover {
        display: flex;
        flex-direction: column;
        animation: sheetSlideUpMobile 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .orders-dropdown-popover .buyer-modal-drag-handle {
        display: block !important;
        position: relative;
        margin: 10px auto 4px;
        touch-action: none;
        cursor: grab;
    }

    .orders-popover-header {
        padding: 10px 16px 11px;
        flex-shrink: 0;
    }

    .orders-sheet-close-btn {
        display: inline-flex;
    }

    .orders-qv-tabs {
        padding: 0 6px;
        flex-shrink: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .orders-qv-tabs::-webkit-scrollbar {
        display: none;
    }

    .orders-qv-tab {
        padding: 10px 6px;
        font-size: 12px;
        flex-shrink: 0;
    }

    .orders-qv-list-container {
        flex: 1 1 0;
        height: auto;
        max-height: none;
        min-height: 0;
        padding: 10px 12px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .orders-qv-list-container.is-tab-loading::before {
        margin: -10px -12px 8px;
    }

    .orders-qv-item {
        padding: 11px 12px;
    }

    .orders-popover-footer {
        padding: 12px 16px;
    }
}

@keyframes orders-backdrop-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
