/* Mercader Errante — dual grid estilo trade + extras Survivor */

#survivor-merchant-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
}

#survivor-merchant-overlay .sv-merch-window {
  width: min(820px, 96vw);
  max-height: min(720px, 92vh);
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #1a1410 0%, #0c0a08 55%, #120e0a 100%);
  border: 2px solid #a67c00;
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(255, 215, 0, 0.12),
    0 18px 50px rgba(0, 0, 0, 0.75);
  color: #f2e6c9;
  font-family: "Segoe UI", Tahoma, sans-serif;
  overflow: hidden;
}

.sv-merch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(166, 124, 0, 0.55);
  background: linear-gradient(90deg, rgba(166, 124, 0, 0.18), transparent 60%);
}

.sv-merch-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #ffd700;
  letter-spacing: 0.04em;
  font-family: Cinzel, Georgia, serif;
}

.sv-merch-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: #b8a57a;
}

.sv-merch-close {
  background: #8b1a1a;
  color: #fff;
  border: 1px solid #c44;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: bold;
}

.sv-merch-close:hover {
  background: #a82222;
}

.sv-merch-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 16px 0;
}

.sv-merch-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.sv-merch-filters button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #4a3c28;
  color: #d4c4a0;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.75rem;
  cursor: pointer;
}

.sv-merch-filters button.is-active {
  background: rgba(166, 124, 0, 0.35);
  border-color: #ffd700;
  color: #ffd700;
}

.sv-merch-search {
  min-width: 160px;
  flex: 0 1 200px;
  background: #0a0806;
  border: 1px solid #4a3c28;
  border-radius: 6px;
  color: #f2e6c9;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.sv-merch-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 12px 16px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.sv-merch-panel {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #5a4630;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sv-merch-panel-title {
  color: #ffd700;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #4a3c28;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sv-merch-panel-title::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sv-merch-panel--shop .sv-merch-panel-title::before {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.55);
}

.sv-merch-panel--inv .sv-merch-panel-title::before {
  background: #2196f3;
  box-shadow: 0 0 6px rgba(33, 150, 243, 0.55);
}

.sv-merch-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  overflow-y: auto;
  max-height: 300px;
  padding: 2px;
}

.sv-merch-slot {
  width: 100%;
  aspect-ratio: 1;
  min-height: 52px;
  background: linear-gradient(135deg, #1a1510, #0d0a07);
  border: 2px solid #3a3228;
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

.sv-merch-slot:hover {
  transform: scale(1.04);
  z-index: 2;
}

.sv-merch-slot.is-selected {
  border-color: #ffd700 !important;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}

.sv-merch-icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  object-fit: contain;
}

.sv-merch-icon--empty {
  color: #555;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sv-merch-amt {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 2px #000, 1px 1px 0 #000;
}

/* Contorno de rareza por tier — visible en el recuadro del slot */
.sv-merch-slot.tier-border-1 {
  border-color: #9e9e9e;
  box-shadow: inset 0 0 0 1px rgba(158, 158, 158, 0.35);
}
.sv-merch-slot.tier-border-2 {
  border-color: #4caf50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.45), inset 0 0 0 1px rgba(76, 175, 80, 0.25);
}
.sv-merch-slot.tier-border-3 {
  border-color: #2196f3;
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.5), inset 0 0 0 1px rgba(33, 150, 243, 0.3);
}
.sv-merch-slot.tier-border-4 {
  border-color: #ab47bc;
  box-shadow: 0 0 10px rgba(171, 71, 188, 0.55), inset 0 0 0 1px rgba(171, 71, 188, 0.35);
}
.sv-merch-slot.tier-border-5 {
  border-color: #ffb300;
  box-shadow: 0 0 12px rgba(255, 179, 0, 0.6), inset 0 0 0 1px rgba(255, 179, 0, 0.4);
}

.sv-merch-slot.tier-border-1:hover { border-color: #cfcfcf; }
.sv-merch-slot.tier-border-2:hover { border-color: #81c784; }
.sv-merch-slot.tier-border-3:hover { border-color: #64b5f6; }
.sv-merch-slot.tier-border-4:hover { border-color: #ce93d8; }
.sv-merch-slot.tier-border-5:hover { border-color: #ffd54f; }

.sv-merch-slot.tier-border-1.is-selected,
.sv-merch-slot.tier-border-2.is-selected,
.sv-merch-slot.tier-border-3.is-selected,
.sv-merch-slot.tier-border-4.is-selected,
.sv-merch-slot.tier-border-5.is-selected {
  border-color: #ffd700 !important;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.55);
}

.sv-merch-slot.is-equipped::after {
  content: "E";
  position: absolute;
  left: 2px;
  top: 2px;
  font-size: 9px;
  font-weight: 800;
  color: #ffd700;
  text-shadow: 0 0 2px #000;
  pointer-events: none;
}

.sv-merch-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #88785a;
  font-size: 0.85rem;
  padding: 28px 8px;
}

.sv-merch-detail {
  margin: 0 16px;
  padding: 12px 14px;
  background: linear-gradient(to bottom, #1a1510, #0d0a07);
  border: 1px solid #5a4630;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.sv-merch-item-name {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.sv-merch-item-stats {
  margin-top: 4px;
  font-size: 0.78rem;
  color: #b8a57a;
  line-height: 1.35;
}

.sv-merch-price {
  font-weight: 800;
  font-size: 1rem;
  white-space: nowrap;
}

.sv-merch-price.is-buy { color: #ffd700; }
.sv-merch-price.is-sell { color: #81c784; }

.sv-merch-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(166, 124, 0, 0.35);
  margin-top: 12px;
}

.sv-merch-gold {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffd700;
  font-weight: 700;
  min-width: 100px;
}

.sv-merch-gold img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.sv-merch-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #cbb892;
  font-size: 0.85rem;
}

.sv-merch-qty input {
  width: 72px;
  background: #0a0806;
  border: 1px solid #4a3c28;
  border-radius: 4px;
  color: #fff;
  padding: 6px 8px;
}

.sv-merch-hint {
  flex: 1;
  font-size: 0.75rem;
  color: #88785a;
  min-width: 120px;
}

.sv-merch-actions {
  display: flex;
  gap: 8px;
}

.sv-merch-btn {
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-weight: 700;
  cursor: pointer;
  min-width: 96px;
}

.sv-merch-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sv-merch-btn--buy {
  background: linear-gradient(180deg, #c9a227, #8a6b10);
  color: #1a1200;
}

.sv-merch-btn--sell {
  background: linear-gradient(180deg, #3d8b40, #2e6b30);
  color: #fff;
}

.sv-merch-btn--buy:not(:disabled):hover {
  filter: brightness(1.08);
}

.sv-merch-btn--sell:not(:disabled):hover {
  filter: brightness(1.08);
}

@media (max-width: 720px) {
  .sv-merch-body {
    grid-template-columns: 1fr;
  }
  .sv-merch-grid {
    max-height: 180px;
  }
}

/* ========== Herrería Survivor (Yunque + Banco) ========== */

#survivor-smith-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
}

#survivor-smith-overlay .sv-smith-window {
  width: min(780px, 96vw);
  max-height: min(740px, 94vh);
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #1a1410 0%, #0c0a08 55%, #120e0a 100%);
  border: 2px solid #a67c00;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.12), 0 18px 50px rgba(0, 0, 0, 0.75);
  color: #f2e6c9;
  font-family: "Segoe UI", Tahoma, sans-serif;
  overflow: hidden;
}

.sv-smith-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(166, 124, 0, 0.55);
  background: linear-gradient(90deg, rgba(166, 124, 0, 0.18), transparent 60%);
}

.sv-smith-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #ffd700;
  font-family: Cinzel, Georgia, serif;
}

.sv-smith-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: #b8a57a;
}

.sv-smith-close {
  background: #8b1a1a;
  color: #fff;
  border: 1px solid #c44;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: bold;
}

.sv-smith-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
}

.sv-smith-tabs button {
  flex: 1;
  padding: 10px;
  border-radius: 8px 8px 0 0;
  border: 1px solid #5a4630;
  background: rgba(255, 255, 255, 0.03);
  color: #cbb892;
  font-weight: 700;
  cursor: pointer;
}

.sv-smith-tabs button.is-active {
  background: rgba(166, 124, 0, 0.28);
  border-color: #ffd700;
  color: #ffd700;
}

.sv-smith-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
}

.sv-smith-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.sv-smith-filters button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #4a3c28;
  color: #d4c4a0;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.75rem;
  cursor: pointer;
}

.sv-smith-filters button.is-active {
  background: rgba(166, 124, 0, 0.35);
  border-color: #ffd700;
  color: #ffd700;
}

.sv-smith-search {
  min-width: 140px;
  background: #0a0806;
  border: 1px solid #4a3c28;
  border-radius: 6px;
  color: #f2e6c9;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.sv-smith-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #b8a57a;
  cursor: pointer;
  user-select: none;
}

.sv-smith-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 16px 8px;
  font-size: 0.85rem;
  color: #d4c4a0;
}

.sv-smith-res b {
  color: #ffd700;
}

.sv-smith-body {
  padding: 0 16px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.sv-smith-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: minmax(56px, auto);
  align-content: start;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 280px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid #5a4630;
  border-radius: 8px;
}

.sv-smith-slot {
  box-sizing: border-box;
  width: 100%;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  aspect-ratio: unset;
  background: linear-gradient(135deg, #1a1510, #0d0a07);
  border: 2px solid #3a3228;
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  transform: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.sv-smith-slot:hover {
  z-index: 2;
}

.sv-smith-slot.is-selected {
  border-color: #ffd700 !important;
  z-index: 3;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.sv-smith-slot.is-locked {
  opacity: 0.45;
}

.sv-smith-slot.is-maxed {
  border-color: #9c27b0;
}

.sv-smith-slot.tier-border-1 {
  border-color: #9e9e9e;
  box-shadow: inset 0 0 0 1px rgba(158, 158, 158, 0.35);
}
.sv-smith-slot.tier-border-2 {
  border-color: #4caf50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.45), inset 0 0 0 1px rgba(76, 175, 80, 0.25);
}
.sv-smith-slot.tier-border-3 {
  border-color: #2196f3;
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.5), inset 0 0 0 1px rgba(33, 150, 243, 0.3);
}
.sv-smith-slot.tier-border-4 {
  border-color: #ab47bc;
  box-shadow: 0 0 10px rgba(171, 71, 188, 0.55), inset 0 0 0 1px rgba(171, 71, 188, 0.35);
}
.sv-smith-slot.tier-border-5 {
  border-color: #ffb300;
  box-shadow: 0 0 12px rgba(255, 179, 0, 0.6), inset 0 0 0 1px rgba(255, 179, 0, 0.4);
}

.sv-slot-icon,
.sv-smith-icon {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px;
  max-height: 32px;
  image-rendering: pixelated;
  object-fit: contain;
  pointer-events: none;
  flex-shrink: 0;
}

.sv-smith-slot canvas.sv-slot-icon,
.sv-smith-slot img.sv-slot-icon,
.sv-smith-slot canvas.sv-smith-icon,
.sv-smith-slot img.sv-smith-icon {
  width: 32px !important;
  height: 32px !important;
}

.sv-smith-icon--empty,
.sv-slot-icon--empty {
  color: #555;
  font-size: 1.2rem;
}

.sv-smith-amt {
  position: absolute;
  right: 3px;
  bottom: 2px;
  z-index: 1;
  font-size: 10px;
  font-weight: 700;
  color: #e040fb;
  text-shadow: 0 0 2px #000, 1px 1px 0 #000;
  pointer-events: none;
}

.sv-smith-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #88785a;
  font-size: 0.85rem;
  padding: 28px 8px;
  line-height: 1.4;
}

.sv-smith-detail {
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: linear-gradient(to bottom, #1a1510, #0d0a07);
  border: 1px solid #5a4630;
  border-radius: 8px;
}

.sv-smith-item-name {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.sv-smith-item-stats {
  margin-top: 4px;
  font-size: 0.78rem;
  color: #b8a57a;
  line-height: 1.35;
}

.sv-smith-progress-wrap {
  margin-top: 10px;
}

.sv-smith-progress-track {
  height: 10px;
  background: #1a1208;
  border: 1px solid #5a4630;
  border-radius: 999px;
  overflow: hidden;
}

.sv-smith-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7b1fa2, #e040fb);
  transition: width 0.2s ease;
}

.sv-smith-progress-label {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #cbb892;
}

.sv-smith-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(166, 124, 0, 0.35);
  margin-top: 12px;
}

.sv-smith-cost {
  font-weight: 800;
  font-size: 0.95rem;
  min-width: 120px;
}

.sv-smith-cost.is-ok { color: #81c784; }
.sv-smith-cost.is-bad { color: #ef5350; }

.sv-smith-hint {
  flex: 1;
  font-size: 0.75rem;
  color: #88785a;
  min-width: 120px;
}

.sv-smith-btn {
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  min-width: 110px;
  background: linear-gradient(180deg, #c9a227, #8a6b10);
  color: #1a1200;
}

.sv-smith-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sv-smith-btn:not(:disabled):hover {
  filter: brightness(1.08);
}

@media (max-width: 720px) {
  .sv-smith-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: 200px;
  }
  .sv-smith-slot {
    height: 52px;
    min-height: 52px;
    max-height: 52px;
  }
}
