/* Purchase History Styles - Figma Design */

.purchase-history-container {
    width: 100%;
    position: relative;
}

/* Subsections visibility - show/hide based on data-subsection */
.purchase-history-subsection {
    display: none;
}

.purchase-history-container[data-subsection="vice-coins"] .purchase-history-subsection[data-subsection="vice-coins"] {
    display: block;
}

.purchase-history-container[data-subsection="vice-shop"] .purchase-history-subsection[data-subsection="vice-shop"] {
    display: block;
}

/* Sub Tabs — design: OverviewCard + ph-sub-tab (identical to newswire-redesign) */
.purchase-history-tabs-card {
    background: #fff;
    border-radius: 0.6vw;
    border: 0.06vw solid #e2e5ea;
    overflow: hidden;
    margin-bottom: 0.8vw;
}

[data-theme="dark"] .purchase-history-tabs-card {
    background: var(--card-bg, #1e293b);
    border-color: var(--card-border, #334155);
}

.purchase-history-tabs-inner {
    padding: 0.4vw 0.5vw;
    display: flex;
    gap: 0.3vw;
}

.purchase-history-subtab.ph-sub-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3vw;
    padding: 0.45vw 0.4vw;
    border-radius: 0.35vw;
    font-family: inherit;
    border: 0.08vw solid transparent;
    background: transparent;
    color: #667085;
    font-size: 0.85vw;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.purchase-history-subtab.ph-sub-tab:hover {
    transform: translateY(-0.04vw);
}

.purchase-history-subtab.ph-sub-tab.active {
    border-color: rgba(79, 110, 247, 0.25);
    background: rgba(79, 110, 247, 0.06);
    color: #4f6ef7;
}

[data-theme="dark"] .purchase-history-subtab.ph-sub-tab {
    color: #94a3b8;
}

[data-theme="dark"] .purchase-history-subtab.ph-sub-tab.active {
    border-color: rgba(79, 110, 247, 0.35);
    background: rgba(79, 110, 247, 0.1);
    color: #818cf8;
}

/* Buyer Level Status Card */
.purchase-history-level-card {
    background: rgba(255, 255, 255, 0.7);
    border: 0.1vw solid rgba(139, 92, 246, 0.2);
    border-radius: 0.8vw;
    padding: 1.2vw;
    margin-bottom: 1.5vw;
    display: flex;
    gap: 1.5vw;
    align-items: center;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(0.691vw);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Level Image */
.purchase-history-level-image {
    flex: 0 0 auto;
    width: 20vw;
    aspect-ratio: 16/9;
    border-radius: 0.6vw;
    overflow: hidden;
    border: 0.1vw solid rgba(139, 92, 246, 0.15);
}

.purchase-history-level-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Level Info */
.purchase-history-level-info {
    flex: 1;
}

/* Level Badge */
.purchase-history-level-badge {
    display: inline-block;
    padding: 0.3vw 0.8vw;
    background: rgba(139, 92, 246, 0.1);
    border: 0.08vw solid rgba(139, 92, 246, 0.2);
    border-radius: 0.4vw;
    font-size: 0.65vw;
    font-weight: 700;
    color: #8b5cf6;
    text-transform: uppercase;
    letter-spacing: 0.05vw;
    margin-bottom: 0.5vw;
}

/* Level Name */
.purchase-history-level-name {
    font-size: 1.4vw;
    font-weight: 700;
    color: #0a0a0f;
    margin: 0 0 1vw 0;
    display: flex;
    align-items: center;
    gap: 0.5vw;
}

.purchase-history-level-icon {
    width: 1.3vw;
    height: 1.3vw;
    color: #ec4899;
}

/* Stats Row */
.purchase-history-stats-row {
    display: flex;
    gap: 1.5vw;
    align-items: center;
    margin-bottom: 1vw;
}

.purchase-history-stat {
    display: flex;
    flex-direction: column;
}

.purchase-history-stat-label {
    font-size: 0.65vw;
    color: rgba(0, 0, 0, 0.5);
    margin-bottom: 0.2vw;
}

.purchase-history-stat-value {
    font-size: 1vw;
    font-weight: 700;
}

.purchase-history-stat-value-primary {
    color: #8b5cf6;
}

.purchase-history-stat-value-secondary {
    color: #ec4899;
}

/* Progress Section */
.purchase-history-progress-section {
    margin-top: 1vw;
}

.purchase-history-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4vw;
}

.purchase-history-progress-label {
    font-size: 0.7vw;
    color: rgba(0, 0, 0, 0.6);
}

.purchase-history-progress-level-text {
    font-weight: 700;
    color: #8b5cf6;
}

.purchase-history-progress-amount {
    font-size: 0.7vw;
    font-weight: 700;
    color: #ec4899;
}

/* Progress Bar */
.purchase-history-progress-bar {
    width: 100%;
    height: 0.6vw;
    background: rgba(139, 92, 246, 0.08);
    border-radius: 0.3vw;
    overflow: hidden;
    border: 0.05vw solid rgba(139, 92, 246, 0.15);
}

.purchase-history-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6 0%, #ec4899 100%);
    border-radius: 0.3vw;
    transition: width 1s ease-out;
}

/* Max Level */
.purchase-history-max-level {
    padding: 0.6vw 1vw;
    background: rgba(236, 72, 153, 0.08);
    border: 0.08vw solid rgba(236, 72, 153, 0.2);
    border-radius: 0.4vw;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4vw;
    margin-top: 1vw;
}

.purchase-history-max-level i {
    font-size: 0.9vw;
    color: #ec4899;
}

.purchase-history-max-level {
    font-size: 0.75vw;
    font-weight: 700;
    color: #ec4899;
}

/* Purchase History Table — design: ph-table-header, ph-table-row, ph-detail-btn */
.purchase-history-table-container {
    background: #fff;
    border: 0.06vw solid #e2e5ea;
    border-radius: 0.6vw;
    overflow: hidden;
    animation: fadeInUp 0.3s ease-out 0.2s backwards;
}

[data-theme="dark"] .purchase-history-table-container {
    background: var(--card-bg, #1e293b);
    border-color: var(--card-border, #334155);
}

/* Table Header (design: #f8f9fb, uppercase #a0a5b2) */
.purchase-history-table-header.ph-table-header {
    display: grid;
    gap: 0.5vw;
    padding: 0.55vw 0.85vw;
    background: #f8f9fb;
    border-bottom: 0.06vw solid #f0f1f3;
}

[data-theme="dark"] .purchase-history-table-header.ph-table-header {
    background: rgba(255, 255, 255, 0.04);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* Coins layout (no Status column — as in design) */
.purchase-history-table-header-coins {
    grid-template-columns: 1.5fr 1.5fr 1fr 2fr 0.6fr;
}

/* Shop layout: without Status column */
.purchase-history-table-header-shop {
    grid-template-columns: 2fr 1.2fr 1fr 2fr 0.6fr;
}

.purchase-history-table-header-cell {
    font-size: 0.78vw;
    font-weight: 700;
    color: #a0a5b2;
    text-transform: uppercase;
    letter-spacing: 0.05vw;
}

[data-theme="dark"] .purchase-history-table-header-cell {
    color: #64748b;
}

.purchase-history-table-header-cell-center {
    text-align: center;
}

/* Table Rows (design: ph-table-row hover rgba(79,110,247,0.015)) */
.purchase-history-table-row {
    display: grid;
    gap: 0.5vw;
    padding: 0.55vw 0.85vw;
    align-items: center;
    border-bottom: 0.06vw solid #f5f6f8;
    background: transparent;
    transition: all 0.2s ease;
    animation: fadeIn 0.25s ease-out forwards;
    opacity: 0;
}

.purchase-history-table-row.ph-table-row:hover {
    background: rgba(79, 110, 247, 0.015);
}

[data-theme="dark"] .purchase-history-table-row {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .purchase-history-table-row.ph-table-row:hover {
    background: rgba(79, 110, 247, 0.06);
}

/* Coins layout (no Status column) */
.purchase-history-table-row-coins {
    grid-template-columns: 1.5fr 1.5fr 1fr 2fr 0.6fr;
}

/* Shop layout: without Status column */
.purchase-history-table-row-shop {
    grid-template-columns: 2fr 1.2fr 1fr 2fr 0.6fr;
}

.purchase-history-table-row:last-child {
    border-bottom: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Table Cells — увеличенные шрифты, макс. длина с троеточием */
.purchase-history-table-cell {
    display: flex;
    align-items: center;
    font-size: 0.88vw;
    font-weight: 600;
    color: #111318;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
}

[data-theme="dark"] .purchase-history-table-cell {
    color: #f1f5f9;
}

.purchase-history-table-cell-title {
    max-width: 100%;
}

.purchase-history-table-cell-type {
    font-size: 0.84vw;
    font-weight: 400;
    color: #555;
    max-width: 100%;
}

.purchase-history-table-cell-price {
    font-size: 0.88vw;
    font-weight: 700;
    color: #4f6ef7;
    max-width: 100%;
}

.purchase-history-table-cell-date {
    font-size: 0.82vw;
    font-weight: 400;
    color: #667085;
    max-width: 100%;
}

.purchase-history-table-cell-center {
    justify-content: center;
    min-width: 0;
    flex-shrink: 0;
}

/* Заголовки таблицы — не вылезают за границы */
.purchase-history-table-header-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
}

/* Status Badge */
.purchase-history-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3vw;
    padding: 0.3vw 0.6vw;
    border-radius: 0.3vw;
    font-size: 0.58vw;
    font-weight: 700;
}

.purchase-history-status-badge i {
    font-size: 0.6vw;
}

.purchase-history-status-completed,
.purchase-history-status-active,
.purchase-history-status-equipped {
    background: rgba(34, 197, 94, 0.1);
    border: 0.05vw solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.purchase-history-status-used,
.purchase-history-status-failed,
.purchase-history-status-pending {
    background: rgba(236, 72, 153, 0.1);
    border: 0.05vw solid rgba(236, 72, 153, 0.3);
    color: #ec4899;
}

/* Details Button (design: ph-detail-btn 1.5vw, scale 1.08 hover) */
.purchase-history-details-btn.ph-detail-btn {
    width: 1.5vw;
    height: 1.5vw;
    min-width: 1.5vw;
    min-height: 1.5vw;
    padding: 0;
    border-radius: 0.3vw;
    background: rgba(79, 110, 247, 0.06);
    border: 0.06vw solid rgba(79, 110, 247, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.purchase-history-details-btn.ph-detail-btn:hover {
    transform: scale(1.08);
    background: rgba(79, 110, 247, 0.12);
    border-color: #4f6ef7;
}

.purchase-history-details-btn.ph-detail-btn i {
    font-size: 0.78vw;
    color: #4f6ef7;
}

/* Date cell (filled by JS in user local time AM/PM) */
.ph-date-cell:empty::before {
    content: '...';
    color: #94a3b8;
}

/* Empty State */
.purchase-history-empty {
    text-align: center;
    padding: 3vw 2vw;
    color: rgba(0, 0, 0, 0.6);
}

.purchase-history-empty i {
    font-size: 3vw;
    margin-bottom: 1vw;
    opacity: 0.5;
    color: #8b5cf6;
    display: block;
}

.purchase-history-empty p {
    font-size: 1.05vw;
    margin: 0;
}

/* Purchase Details Modal — design: light overlay, full page, modal as in newswire-redesign */
.purchase-details-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 2vw;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.purchase-details-modal.active {
    display: flex;
    opacity: 1;
}

/* Затемнение всего экрана (фиксируем относительно viewport) */
.purchase-details-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(2px);
    cursor: pointer;
    z-index: 0;
}

.purchase-details-modal-content {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 0.6vw;
    width: 100%;
    max-width: 32vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 1vw 3vw rgba(0, 0, 0, 0.18);
    transform: scale(0.96);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.purchase-details-modal.active .purchase-details-modal-content {
    transform: scale(1);
}

[data-theme="dark"] .purchase-details-modal-content {
    background: #1e293b;
}

.purchase-details-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7vw 0.85vw;
    border-bottom: 0.06vw solid #f0f1f3;
}

[data-theme="dark"] .purchase-details-modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.purchase-details-modal-header-left {
    display: flex;
    align-items: center;
    gap: 0.35vw;
}

.purchase-details-modal-icon {
    font-size: 0.82vw;
    color: #4f6ef7;
}

.purchase-details-modal-title {
    font-size: 0.9vw;
    font-weight: 700;
    color: #111318;
    margin: 0;
}

[data-theme="dark"] .purchase-details-modal-title {
    color: #f1f5f9;
}

.purchase-details-modal-close {
    width: 1.5vw;
    height: 1.5vw;
    min-width: 1.5vw;
    min-height: 1.5vw;
    padding: 0;
    border: none;
    border-radius: 0.3vw;
    background: #f5f6f8;
    color: #667085;
    font-size: 1.1vw;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.purchase-details-modal-close:hover {
    background: #fee2e2;
    color: #b91c1c;
}

[data-theme="dark"] .purchase-details-modal-close {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

.purchase-details-modal-body {
    padding: 0.8vw 0.85vw 0.65vw;
}

/* Amount highlight (design) */
.purchase-detail-amount-box {
    padding: 0.65vw 0.75vw;
    border-radius: 0.4vw;
    background: rgba(79, 110, 247, 0.03);
    border: 0.06vw solid rgba(79, 110, 247, 0.08);
    margin-bottom: 0.7vw;
    text-align: center;
}

.purchase-detail-amount-label {
    font-size: 0.62vw;
    color: #667085;
    margin-bottom: 0.15vw;
}

.purchase-detail-amount-value {
    font-size: 1.5vw;
    font-weight: 800;
    color: #4f6ef7;
}

/* Detail rows (design) — одинаковый отступ у всех, включая последнюю */
.purchase-detail-rows {
    padding-bottom: 0;
}

.purchase-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5vw 0;
    border-bottom: 0.06vw solid #f3f4f6;
}

.purchase-detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

[data-theme="dark"] .purchase-detail-row {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.purchase-detail-row-label {
    font-size: 0.72vw;
    color: #667085;
}

.purchase-detail-row-value {
    font-size: 0.75vw;
    font-weight: 600;
    color: #111318;
}

[data-theme="dark"] .purchase-detail-row-value {
    color: #f1f5f9;
}

.purchase-details-modal-footer {
    padding: 0.6vw 0.85vw;
    border-top: 0.06vw solid #f0f1f3;
    display: flex;
    justify-content: flex-end;
}

[data-theme="dark"] .purchase-details-modal-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.purchase-details-modal-btn-close {
    padding: 0.35vw 0.9vw;
    border-radius: 0.25vw;
    background: #4f6ef7;
    border: none;
    color: #fff;
    font-size: 0.7vw;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.purchase-details-modal-btn-close:hover {
    background: #3b5de7;
}

.modal-loading,
.modal-error {
    text-align: center;
    padding: 2vw 1vw;
    color: #667085;
    font-size: 0.65vw;
}

.modal-loading i {
    font-size: 1.5vw;
    margin-bottom: 0.5vw;
    display: block;
}

.modal-error {
    color: #ef4444;
}

