/* ============================================================
   css/trade.css — Interfaz de Intercambio P2P (estilo MU Online)
   ============================================================ */

/* ── Overlay general ── */
.trade-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 15, 0.72);
  backdrop-filter: blur(3px);
  font-family: 'Barlow', sans-serif;
}
.trade-overlay.synced { animation: trade-overlay-in 0.25s ease; }
@keyframes trade-overlay-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Ventana principal ── */
.trade-window {
  width: 600px;
  max-width: 94vw;
  max-height: 92vh;
  margin: auto; /* centra en el overlay flex y evita recorte superior si desborda */
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1b2333 0%, #121826 100%);
  border: 1px solid #c9a227;
  border-radius: 12px;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.55), 0 0 40px rgba(201, 162, 39, 0.25), 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  color: #e2e8f0;
  animation: trade-win-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.trade-window > .trade-footer {
  margin-top: auto;
  flex-shrink: 0;
}
@keyframes trade-win-in { from { transform: translateY(24px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.trade-window.locked { border-color: #4ade80; box-shadow: 0 0 0 3px rgba(0,0,0,0.55), 0 0 46px rgba(74,222,128,0.35), 0 24px 60px rgba(0,0,0,0.6); }

/* ── Header ── */
.trade-win-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(90deg, #2a2433 0%, #3a2f1a 50%, #2a2433 100%);
  border-bottom: 1px solid #c9a227;
}
.trade-win-title {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 1px;
  color: #f5d76e;
  text-shadow: 0 0 12px rgba(245, 215, 110, 0.4);
  white-space: nowrap;
}
.trade-win-partner {
  flex: 1;
  text-align: center;
  font-weight: 600;
  color: #c4b5fd;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trade-win-close {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #f87171;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.trade-win-close:hover { background: rgba(239, 68, 68, 0.4); transform: scale(1.05); }

/* ── Banner de bloqueo ── */
.trade-lock-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(90deg, rgba(74, 222, 128, 0.12), rgba(74, 222, 128, 0.22), rgba(74, 222, 128, 0.12));
  color: #4ade80;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(74, 222, 128, 0.35);
}

/* ── Cuerpo: dos paneles apilados + chat ── */
.trade-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto; /* si el contenido no cabe, solo el cuerpo scrollea; los botones quedan fijos */
}
.trade-panel {
  width: 100%;
  background: rgba(9, 13, 22, 0.6);
  border: 1px solid #2c3a52;
  border-radius: 10px;
  padding: 6px;
}
.trade-panel-peer { border-color: #3a3352; }
.trade-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 1px;
  padding: 2px 4px 6px;
}
.trade-panel-header.me { color: #60a5fa; }
.trade-panel-header.peer { color: #f87171; }
.trade-panel-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #60a5fa; box-shadow: 0 0 8px #60a5fa;
}
.trade-panel-header.peer .trade-panel-dot { background: #f87171; box-shadow: 0 0 8px #f87171; }
.trade-panel-status {
  margin-left: auto;
  font-size: 0.72rem;
  color: #94a3b8;
}
.trade-panel-status.ok { color: #4ade80; text-shadow: 0 0 8px rgba(74,222,128,0.5); }

/* ── Grid 3x4 (slots compactos para que la ventana no desborde) ── */
.trade-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.trade-slot {
  position: relative;
  height: 58px;
  background: rgba(20, 28, 44, 0.8);
  border: 1px dashed #39486a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
}
.trade-slot[data-side="me"]:hover { border-color: #60a5fa; background: rgba(37, 54, 90, 0.8); transform: scale(1.03); }
.trade-slot[data-side="peer"] { cursor: default; }
.trade-slot.filled { border-style: solid; border-color: #4b5a7a; }
.trade-slot.pokemon { border-color: #a78bfa; }
.trade-slot.item { border-color: #fbbf24; }
.trade-slot-plus { color: #3c4c6e; font-size: 1.2rem; font-weight: 700; }
.trade-slot-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  padding: 2px;
}
.trade-slot-emoji { font-size: 1.3rem; }
.trade-slot-tag {
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  background: rgba(0, 0, 0, 0.78);
  color: #e2e8f0;
  font-size: 0.52rem;
  font-weight: 700;
  text-align: center;
  border-radius: 3px;
  padding: 1px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trade-slot-remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 16px; height: 16px;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  border-radius: 50%;
  font-size: 0.6rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.trade-slot:hover .trade-slot-remove { opacity: 1; }

/* ── Moneda ── */
.trade-currency { margin-top: 4px; display: flex; flex-direction: column; gap: 4px; }
.trade-currency-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.trade-currency-row.peer { padding: 3px 2px; }
.trade-cur-icon { width: 20px; text-align: center; font-size: 0.85rem; }
.trade-currency-row input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #33415e;
  border-radius: 5px;
  color: #fbbf24;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 3px 6px;
  outline: none;
}
.trade-currency-row input:focus { border-color: #fbbf24; }
.trade-cur-btn {
  width: 26px; height: 26px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 800;
  transition: all 0.12s;
}
.trade-cur-btn:hover { background: rgba(59, 130, 246, 0.35); }
.trade-cur-value {
  flex: 1;
  font-weight: 700;
  color: #fbbf24;
  font-size: 0.9rem;
  text-align: right;
  padding-right: 4px;
}
.trade-me-avail {
  margin-top: 4px;
  font-size: 0.66rem;
  color: #94a3b8;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

/* ── Centro ── */
.trade-center {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 1px 0;
}
.trade-exchange-icon {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #f87171);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.5);
  animation: trade-exchange-pulse 2.4s ease-in-out infinite;
}
@keyframes trade-exchange-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 14px rgba(99,102,241,0.45); }
  50% { transform: scale(1.08); box-shadow: 0 0 26px rgba(99,102,241,0.7); }
}
.trade-center-status {
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  text-align: center;
  line-height: 1.35;
}

/* ── Footer / botones ── */
.trade-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(9, 13, 22, 0.7);
  border-top: 1px solid #2c3a52;
}
.trade-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 22px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  font-size: 0.85rem;
  font-family: 'Barlow', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.trade-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }
.trade-btn-gray { background: #334155; color: #e2e8f0; border-color: #475569; }
.trade-btn-gray:hover:not(:disabled) { background: #475569; }
.trade-btn-gold { background: linear-gradient(135deg, #f59e0b, #d97706); color: #1a1205; border-color: #fbbf24; box-shadow: 0 0 14px rgba(245, 158, 11, 0.35); }
.trade-btn-gold:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 20px rgba(245, 158, 11, 0.55); }
.trade-btn-green { background: linear-gradient(135deg, #22c55e, #15803d); color: #04120a; border-color: #4ade80; box-shadow: 0 0 14px rgba(34, 197, 94, 0.35); }
.trade-btn-green:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 20px rgba(34, 197, 94, 0.55); }
.trade-btn-red { background: linear-gradient(135deg, #ef4444, #b91c1c); color: #fff; border-color: #f87171; }
.trade-btn-red:hover:not(:disabled) { transform: translateY(-1px); }

/* ── Selector (picker) ── */
.trade-picker {
  position: absolute;
  right: 14px;
  top: 64px;
  bottom: 64px;
  width: 300px;
  background: #131a2a;
  border: 1px solid #c9a227;
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  display: none;
  flex-direction: column;
  z-index: 10;
  animation: trade-picker-in 0.2s ease;
}
@keyframes trade-picker-in { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.trade-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: linear-gradient(90deg, #2a2433, #3a2f1a);
  border-bottom: 1px solid #c9a227;
  border-radius: 10px 10px 0 0;
  font-weight: 700;
  font-size: 0.8rem;
  color: #f5d76e;
}
.trade-picker-close {
  background: none;
  border: none;
  color: #f87171;
  font-size: 1rem;
  cursor: pointer;
}
.trade-picker-tabs { display: flex; border-bottom: 1px solid #2c3a52; }
.trade-picker-tab {
  flex: 1;
  padding: 7px;
  background: none;
  border: none;
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.12s;
}
.trade-picker-tab.active { color: #f5d76e; background: rgba(245, 215, 110, 0.08); border-bottom: 2px solid #c9a227; }
.trade-picker-list { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.trade-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #25314a;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.12s;
}
.trade-picker-row:hover { background: rgba(59, 130, 246, 0.12); border-color: #3b82f6; }
.trade-picker-img {
  width: 34px; height: 34px;
  object-fit: contain;
  image-rendering: pixelated;
}
.trade-picker-img.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; background: rgba(255,255,255,0.04); border-radius: 6px;
}
.trade-picker-info { flex: 1; min-width: 0; }
.trade-picker-name { font-size: 0.78rem; font-weight: 700; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade-picker-sub { font-size: 0.66rem; color: #94a3b8; }
.trade-picker-add {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid #22c55e;
  color: #4ade80;
  width: 24px; height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.12s;
}
.trade-picker-add:hover { background: rgba(34, 197, 94, 0.4); }
.trade-picker-empty { color: #64748b; font-size: 0.75rem; text-align: center; padding: 20px 10px; }

/* ── Invitación ── */
.trade-invite-overlay {
  position: fixed;
  inset: 0;
  z-index: 5500;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 15, 0.6);
  backdrop-filter: blur(2px);
}
.trade-invite-card {
  width: 340px;
  background: linear-gradient(180deg, #1b2333, #121826);
  border: 1px solid #c9a227;
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 0 40px rgba(201, 162, 39, 0.3);
  animation: trade-win-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.trade-invite-icon {
  width: 54px; height: 54px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #a78bfa);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
  animation: trade-exchange-pulse 2s ease-in-out infinite;
}
.trade-invite-title { font-family: 'Cinzel', serif; font-weight: 900; color: #f5d76e; font-size: 1rem; }
.trade-invite-name { font-size: 1.15rem; font-weight: 800; color: #e2e8f0; margin: 8px 0 2px; }
.trade-invite-sub { color: #94a3b8; font-size: 0.78rem; margin-bottom: 16px; }
.trade-invite-btns { display: flex; gap: 10px; justify-content: center; }
.trade-invite-btns .trade-btn { flex: 1; justify-content: center; padding: 9px 0; }

/* ── Menú contextual ── */
.trade-ctx-menu {
  position: fixed;
  z-index: 6000;
  background: #131a2a;
  border: 1px solid #c9a227;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  min-width: 200px;
  animation: trade-ctx-in 0.12s ease;
}
@keyframes trade-ctx-in { from { transform: scale(0.95); opacity: 0; } to { transform: none; opacity: 1; } }
.trade-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.1s;
}
.trade-ctx-item:hover { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.trade-ctx-item i { color: #60a5fa; }
#trade-ctx-cancel i { color: #94a3b8; }

/* ── Completado ── */
.trade-complete-overlay {
  position: fixed;
  inset: 0;
  z-index: 5700;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 15, 0.7);
  backdrop-filter: blur(3px);
}
.trade-complete-card {
  text-align: center;
  animation: trade-complete-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes trade-complete-pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.trade-complete-check {
  width: 90px; height: 90px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem;
  box-shadow: 0 0 40px rgba(34, 197, 94, 0.7);
}
.trade-complete-title {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 1.6rem;
  color: #4ade80;
  text-shadow: 0 0 20px rgba(74, 222, 128, 0.6);
  letter-spacing: 1px;
}
.trade-complete-sub { color: #94a3b8; font-size: 0.85rem; margin-top: 8px; }

/* ── Chat del intercambio ── */
.trade-chat {
  width: 100%;
  background: rgba(9, 13, 22, 0.6);
  border: 1px solid #2c3a52;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.trade-chat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 1px;
  color: #94a3b8;
}
.trade-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 96px;
  min-height: 44px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #25314a;
  border-radius: 7px;
  padding: 5px 6px;
}
.trade-chat-msg {
  display: flex;
  gap: 6px;
  font-size: 0.78rem;
  line-height: 1.3;
  word-break: break-word;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}
.trade-chat-msg.mine { background: rgba(59, 130, 246, 0.12); }
.trade-chat-msg.peer { background: rgba(148, 163, 184, 0.07); }
.trade-chat-who {
  font-weight: 800;
  color: #f5d76e;
  white-space: nowrap;
  flex-shrink: 0;
}
.trade-chat-msg.mine .trade-chat-who { color: #60a5fa; }
.trade-chat-body { color: #e2e8f0; }
.trade-chat-input-row {
  display: flex;
  gap: 6px;
}
.trade-chat-input-row input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #33415e;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.8rem;
  padding: 6px 10px;
  outline: none;
}
.trade-chat-input-row input:focus { border-color: #c9a227; }
.trade-chat-input-row .trade-btn { padding: 7px 16px; }

/* ── Tooltip de estadísticas del Pokémon ── */
.trade-slot-tip {
  position: fixed;
  z-index: 6500;
  width: 340px;
  background: linear-gradient(180deg, #1b2333, #121826);
  border: 1px solid #c9a227;
  border-radius: 10px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55), 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 22px rgba(201, 162, 39, 0.22);
  padding: 10px 12px;
  font-family: 'Barlow', sans-serif;
  font-size: 0.76rem;
  color: #e2e8f0;
  pointer-events: none;
  animation: trade-ctx-in 0.12s ease;
}
.trade-slot-tip .ts-head {
  font-weight: 900;
  font-size: 0.92rem;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.trade-slot-tip .ts-head em {
  font-style: normal;
  font-weight: 700;
  font-size: 0.68rem;
  color: #94a3b8;
}
.trade-slot-tip .ts-quality {
  font-size: 0.72rem;
  font-weight: 700;
  margin: 3px 0 2px;
}
.trade-slot-tip .ts-nature {
  font-size: 0.68rem;
  color: #94a3b8;
}
.trade-slot-tip .ts-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px 8px;
  margin: 7px 0;
  padding: 6px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}
.trade-slot-tip .ts-stat {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.68rem;
  color: #94a3b8;
}
.trade-slot-tip .ts-stat b {
  color: #f5d76e;
}
.trade-slot-tip .ts-ivs {
  font-size: 0.68rem;
  color: #94a3b8;
}
.trade-slot-tip .ts-side {
  margin-top: 5px;
  font-size: 0.64rem;
  color: #f87171;
  font-style: italic;
}

/* ── Toast ── */
.trade-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 6000;
  background: #1b2333;
  border: 1px solid #c9a227;
  color: #f5d76e;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.82rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  max-width: 80vw;
  text-align: center;
}
.trade-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ── */
.device-mobile .trade-body { flex-direction: column; }
.device-mobile .trade-center { width: 100%; flex-direction: row; }
.device-mobile .trade-picker { position: fixed; left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; height: 55vh; }
.device-mobile .trade-slot { height: 52px; }
.device-mobile .trade-window { width: 94vw; }
@media (max-width: 860px) {
  .trade-body { flex-direction: column; }
  .trade-center { width: 100%; flex-direction: row; }
  .trade-picker { position: fixed; left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; height: 55vh; }
  .trade-slot { height: 52px; }
  .trade-window { width: 94vw; }
}
