/* mshelf.css — Mystery Shelf grid panel + floating button */

/* Floating toggle button (PC + mobile).
   On desktop: top-right near existing toolbar. On mobile: shifted up so it
   doesn't collide with system home-indicator / nav. 44×44 min hit target. */
#mshelf-fab {
  position: fixed;
  top: 180px;
  right: 12px;
  z-index: 1550;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: rgba(26,28,34,0.94);
  border: 1px solid #3a3f4a;
  color: #f0c060;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.1s ease, background 0.1s ease;
}
#mshelf-fab:hover {
  background: rgba(40,42,50,0.98);
  transform: scale(1.05);
}
#mshelf-fab:active {
  transform: scale(0.95);
}
#mshelf-fab[data-active="true"] {
  background: #f0c060;
  color: #1a1c20;
  border-color: #f0c060;
}
.mshelf-fab-ico {
  pointer-events: none;
  font-size: 20px;
  line-height: 1;
}
.mshelf-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #e85858;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: Inter, system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
/* Mobile: slightly bigger target, keep away from topbar edge */
@media (max-width: 900px) {
  #mshelf-fab {
    width: 52px;
    height: 52px;
    top: auto;
    bottom: calc(16px + env(safe-area-inset-bottom, 0));
    right: calc(16px + env(safe-area-inset-right, 0));
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  }
  .mshelf-fab-ico { font-size: 24px; }
  .mshelf-fab-badge { min-width: 20px; height: 20px; font-size: 11px; }
}

/* Panel: on mobile take full width minus margins and sit above the FAB */
@media (max-width: 900px) {
  #mshelf-panel {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    right: 12px !important;
    left: 12px !important;
    top: calc(60px + env(safe-area-inset-top, 0)) !important;
    bottom: calc(80px + env(safe-area-inset-bottom, 0));
    max-height: none !important;
  }
}

.mshelf-waiting {
  padding: 20px 12px;
  color: #888;
  font-style: italic;
  text-align: center;
  font-size: 12px;
}

/* Shelf selector in header (when multiple merchants visible) */
#mshelf-shelf-picker {
  display: flex;
  gap: 3px;
  margin-left: 8px;
}
.mshelf-shelf-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid #3a3f4a;
  color: #ccc;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  padding: 2px 6px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 20px;
}
.mshelf-shelf-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.mshelf-shelf-btn[data-active="true"] {
  background: #f0c060;
  color: #1a1c20;
  border-color: #f0c060;
  font-weight: 700;
}
.mshelf-shelf-btn small { font-size: 9px; opacity: 0.7; }

#mshelf-panel {
  position: fixed;
  top: 60px;
  right: 12px;
  width: 440px;
  max-width: 60vw;
  resize: both;
  max-height: calc(100vh - 80px);
  background: rgba(18,20,24,0.96);
  border: 1px solid #3a3f4a;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  color: #ddd;
  z-index: 1500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#mshelf-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #2a2f38;
  font-weight: 600;
  color: #f0c060;
}
#mshelf-count {
  margin-left: auto;
  font-weight: 400;
  color: #888;
  font-size: 11px;
}
#mshelf-close, #mshelf-flip {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 3px;
}
#mshelf-close:hover, #mshelf-flip:hover { color: #fff; background: rgba(255,255,255,0.08); }
#mshelf-close { font-size: 18px; }
#mshelf-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px;
  flex: 1;
}
.mshelf-grid {
  max-width: 100%;
}

/* Compact cell content: image or diamond, sized to fit cell with 4px pad. */
.mshelf-img-single {
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: rgba(0,0,0,0.15);
  border-radius: 2px;
}
.mshelf-dia-wrap, .mshelf-dia { display: none; }
.mshelf-crate {
  width: 70%;
  height: 70%;
  max-width: 32px;
  max-height: 32px;
  display: block;
  margin: auto;
  opacity: 0.85;
}
.mshelf-cell:hover .mshelf-crate { opacity: 1; }
.mshelf-empty { color: #555; }

/* Grid of merchant boxes — mirrors in-game shelf layout. */
.mshelf-grid {
  display: grid;
  gap: 3px;
}
.mshelf-cell {
  position: relative;
  background: rgba(255,255,255,0.03);
  border: 1px solid #444;
  border-top-width: 2px;
  border-radius: 2px;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  cursor: default;
  z-index: 1;
}
.mshelf-cell:hover { background: rgba(255,255,255,0.1); z-index: 2; }
.mshelf-cell:hover {
  background: rgba(255,255,255,0.07);
  z-index: 10;
}
.mshelf-cell[data-rev="1"] {
  background: rgba(76,175,80,0.15) !important;
}
/* With 32px square cells there's no room for text labels — hide them.
   All details live in the hover/tap popup. */
.mshelf-pool, .mshelf-top, .mshelf-meta, .mshelf-bot { display: none; }
.mshelf-tname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.mshelf-tprice {
  font-weight: 700;
  font-size: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.mshelf-empty {
  color: #666;
  font-style: italic;
}
.mshelf-meta {
  display: flex;
  gap: 3px;
  align-items: baseline;
  font-size: 8px;
  color: #888;
  line-height: 1.1;
}
.mshelf-rtxt {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
.mshelf-count {
  margin-left: auto;
  color: #666;
}
.mshelf-grid { gap: 2px; }

/* Legacy per-cell tip removed — see #mshelf-ftip shared floating popup */
.mshelf-tip { display: none !important; }

/* Shared floating tooltip (hover PC / tap mobile) */
#mshelf-ftip {
  position: fixed;
  display: none;
  z-index: 2000;
  width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(10,12,16,0.98);
  border: 1px solid #666;
  border-radius: 4px;
  padding: 6px 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.8);
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  color: #ddd;
}
#mshelf-ftip[data-pinned="1"] {
  border-color: #f0c060;
  padding-top: 48px;
}
.mshelf-ftip-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  background: #c0453d;
  border: 1px solid #e85858;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  touch-action: manipulation;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.mshelf-ftip-close:hover,
.mshelf-ftip-close:active { background: #d8544c; }

/* Backdrop on mobile — tap it to close pinned popup */
#mshelf-ftip-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1999;
  display: none;
  touch-action: none;
}
#mshelf-ftip-backdrop[data-on="1"] { display: block; }
@media (min-width: 701px) {
  #mshelf-ftip-backdrop { display: none !important; }
}
.mshelf-tip-head {
  font-size: 11px;
  color: #f0c060;
  font-weight: 700;
  padding-bottom: 4px;
  margin-bottom: 6px;
  border-bottom: 1px solid #333;
  text-align: center;
}
.mshelf-cand {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 3px 4px;
  border-left: 3px solid #666;
  margin: 2px 0;
  border-radius: 2px;
  background: rgba(255,255,255,0.02);
}
.mshelf-cand-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: rgba(0,0,0,0.3);
  border-radius: 2px;
  flex-shrink: 0;
}
.mshelf-cand-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mshelf-cand-name {
  font-size: 11px;
  color: #ddd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.1;
}
.mshelf-cand-sub {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
}
.mshelf-cand-price {
  margin-left: auto;
  color: #4caf50;
}
