/* ==========================================================================
   PBGame Market & Inventory — Glassmorphic Dark/Green System
   ========================================================================== */

:root {
  --pb-accent: #4ace8e;
  --pb-accent-soft: rgba(74, 206, 142, 0.16);
  --pb-accent-glow: rgba(74, 206, 142, 0.35);
  --pb-card-bg: rgba(18, 20, 29, 0.68);
  --pb-card-bg-2: rgba(12, 14, 20, 0.85);
  --pb-text: #ffffff;
  --pb-text-muted: #aeb6d2;
  --pb-border: rgba(255, 255, 255, 0.08);
  --pb-border-strong: rgba(255, 255, 255, 0.14);
}

/* ---------- Layout ---------- */
.pb-market-layout {
  display: flex;
  margin-top: 10px;
  flex-direction: column;
  gap: 16px;
}

.pb-market-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  transition: opacity 0.15s ease;
}

.pb-market-list--loading {
  opacity: 0.45;
  pointer-events: none;
}

.pb-inventory-page {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.pb-inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media(max-width: 1400px) {
  .pb-market-list, .pb-inventory-grid { grid-template-columns: repeat(3, 1fr); }
}

@media(max-width: 900px) {
  .pb-market-list, .pb-inventory-grid { grid-template-columns: repeat(2, 1fr); }
}

@media(max-width: 500px) {
  .pb-market-list, .pb-inventory-grid { grid-template-columns: 1fr; }
}

/* ---------- Market Card ---------- */
.pb-market-item {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: var(--pb-card-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--pb-border);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.22s ease, box-shadow 0.22s ease;
  contain: content;
}

.pb-market-item:hover {
  border-color: rgba(74, 206, 142, 0.45);
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 0 20px var(--pb-accent-soft);
}

.pb-market-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pb-market-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(18, 20, 29, 0.95) 100%);
}

.pb-market-preview img,
.pb-market-preview canvas,
.pb-market-preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
  opacity: 0;
}

.pb-market-preview img.pb-lazy-loaded,
.pb-market-preview canvas.pb-lazy-loaded,
.pb-market-preview-video.pb-lazy-loaded {
  opacity: 1;
}

.pb-market-item:hover .pb-market-preview img,
.pb-market-item:hover .pb-market-preview canvas,
.pb-market-item:hover .pb-market-preview-video {
  transform: scale(1.05);
}

.pb-gif-poster { pointer-events: none; }
img.pb-gif-source.pb-gif-hidden { display: none; }
.pb-gif-poster.pb-gif-hidden { display: none; }

.pb-market-stock {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  background: rgba(8, 9, 12, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(74, 206, 142, 0.3);
  color: var(--pb-accent);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(74, 206, 142, 0.2);
}

.pb-market-body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
}

.pb-market-name {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--pb-text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pb-market-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pb-market-price {
  font-size: 16px;
  font-weight: 900;
  color: var(--pb-accent);
  line-height: 1;
  text-shadow: 0 0 10px rgba(74, 206, 142, 0.35);
}

.pb-market-price span { color: var(--pb-accent); }

.pb-market-item.dc-purchased { opacity: 0.5; }
.pb-market-item.dc-sold {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Inventory Card ---------- */
.pb-inventory-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--pb-border);
  border-radius: 20px;
  background: var(--pb-card-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 34px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  overflow: hidden;
  min-width: 0;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.22s ease, box-shadow 0.22s ease;
}

.pb-inventory-item:hover {
  transform: translateY(-4px);
  border-color: rgba(74, 206, 142, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 20px 45px rgba(0, 0, 0, 0.55), 0 0 20px var(--pb-accent-soft);
}

.pb-inventory-item.active {
  border-color: var(--pb-accent);
  background: radial-gradient(circle at 50% 0, rgba(74, 206, 142, 0.15), rgba(18, 20, 29, 0.8) 60%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 20px 45px rgba(0, 0, 0, 0.5), 0 0 25px var(--pb-accent-soft);
}

.pb-inventory-item-preview {
  position: relative;
  height: 220px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: radial-gradient(circle at 50% 30%, rgba(70, 80, 140, 0.22), transparent), rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 14px;
}

.pb-inventory-item-preview img,
.pb-inventory-item-preview canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pb-inventory-item-preview img.pb-lazy-loaded,
.pb-inventory-item-preview canvas.pb-lazy-loaded { opacity: 1; }
.pb-inventory-preview-video { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 10px; }

.pb-inventory-item-status {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(8, 9, 12, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--pb-border-strong);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pb-text-muted);
  font-weight: 800;
}

.pb-inventory-item.active .pb-inventory-item-status {
  background: rgba(74, 206, 142, 0.16);
  border-color: rgba(74, 206, 142, 0.45);
  color: var(--pb-accent);
  box-shadow: 0 0 10px rgba(74, 206, 142, 0.25);
}

.pb-inventory-item-name {
  font-size: 15px;
  line-height: 1.25;
  color: var(--pb-text);
  font-weight: 800;
  word-break: break-word;
  padding: 0 2px;
}

@media(max-width: 500px) {
  .pb-inventory-item-preview { height: 200px; }
}

/* ---------- Category Tabs ---------- */
ul.pb-market-categories.vertical-navigation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  padding: 6px;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 20px;
  background: rgba(18, 20, 29, 0.72) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--pb-border);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

ul.pb-market-categories.vertical-navigation::-webkit-scrollbar { height: 4px; }
ul.pb-market-categories.vertical-navigation::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 999px; }

ul.pb-market-categories.vertical-navigation li {
  list-style: none;
  border: 0;
  flex: 0 0 auto;
}

ul.pb-market-categories.vertical-navigation li a {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 11px 20px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--pb-text-muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

ul.pb-market-categories.vertical-navigation li a::before {
  content: none;
  display: none;
}

ul.pb-market-categories.vertical-navigation li a:hover {
  color: var(--pb-text);
  background: rgba(255, 255, 255, 0.06);
}

ul.pb-market-categories.vertical-navigation li a.active,
ul.pb-market-categories.vertical-navigation li.active a {
  color: #08150f !important;
  background: linear-gradient(135deg, #4ace8e 0%, #2faf73 100%) !important;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(74, 206, 142, 0.4);
  padding: 11px 20px;
}

@media(max-width: 640px) {
  ul.pb-market-categories.vertical-navigation {
    flex-wrap: nowrap;
    gap: 6px;
  }
  ul.pb-market-categories.vertical-navigation li a {
    padding: 10px 16px;
    font-size: 12.5px;
  }
}

/* ---------- Preview Drawer ---------- */
.pb-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 2000;
}

.pb-preview-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.pb-preview-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  max-width: 640px;
  background: rgba(18, 20, 29, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--pb-border-strong);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.6);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2001;
  display: flex;
  flex-direction: column;
}

.pb-preview-drawer.active { transform: translateX(0); }

@media(max-width: 1200px) { .pb-preview-drawer { width: 70%; } }
@media(max-width: 767px) { .pb-preview-drawer { width: 100%; max-width: none; } }

.pb-preview-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 1px solid var(--pb-border-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--pb-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pb-preview-close svg { width: 14px; height: 14px; }
.pb-preview-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.pb-preview-body {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
}

.pb-preview-loader, .pb-preview-empty {
  color: var(--pb-text-muted);
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

.pb-preview-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-top: 1px solid var(--pb-border);
  background: rgba(12, 14, 20, 0.85);
}

.pb-preview-info { min-width: 0; }
.pb-preview-name {
  color: var(--pb-text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.pb-preview-price {
  color: var(--pb-accent);
  font-size: 19px;
  font-weight: 900;
  margin-top: 4px;
  text-shadow: 0 0 10px rgba(74, 206, 142, 0.35);
}

.pb-preview-buy-btn {
  flex: 0 0 auto;
  border-radius: 12px;
  font-weight: 800;
  padding: 12px 26px;
  background: linear-gradient(135deg, #4ace8e 0%, #2faf73 100%);
  color: #08150f;
  box-shadow: 0 6px 20px rgba(74, 206, 142, 0.35);
  transition: all 0.2s ease;
}

.pb-preview-buy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(74, 206, 142, 0.5);
}

.pb-preview-buy-btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

/* Generic frame */
.pb-preview-frame {
  width: 100%;
  max-width: 420px;
  height: 260px;
  border-radius: 20px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0 auto;
  border: 1px solid var(--pb-border);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}

/* Background preview */
.pb-preview-frame--bg { background: #0f0f14; }
.pb-preview-bg-img, .pb-preview-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pb-preview-bg-img { background-size: cover; background-position: center; }
.pb-preview-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.75) 100%);
}

.pb-preview-card {
  position: absolute;
  left: 24px;
  bottom: 24px;
  right: 24px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
}

.pb-preview-card-avatar-wrap {
  position: relative;
  display: inline-flex;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
}

.pb-preview-card-avatar {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  position: absolute;
  top: 5px;
  left: 5px;
}

.pb-preview-card-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.pb-preview-card-login {
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Avatar preview */
.pb-preview-frame--avatar {
  background: radial-gradient(circle at 50% 30%, rgba(70, 80, 140, 0.25), transparent), #0f0f14;
  padding: 20px;
}

.pb-preview-avatar-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pb-preview-avatar-wrap--big { width: 180px; height: 180px; }
.pb-preview-avatar {
  width: 148px;
  height: 148px;
  border-radius: 22px;
  object-fit: cover;
  position: absolute;
  top: 16px;
  left: 16px;
}

.pb-preview-frame-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Plain item preview */
.pb-preview-frame--plain {
  background: radial-gradient(circle at 50% 30%, rgba(70, 80, 140, 0.25), transparent), #0f0f14;
  padding: 20px;
}

.pb-preview-plain-img, .pb-preview-plain-video {
  max-width: 100%;
  max-height: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
}

@media(max-width: 500px) {
  .pb-preview-frame { height: 220px; }
  .pb-preview-avatar-wrap--big { width: 150px; height: 150px; }
  .pb-preview-avatar { width: 124px; height: 124px; top: 13px; left: 13px; }
}