/* ============================================================
   TRADE SYSTEM — Styles
   ============================================================ */

/* ── Lobby ────────────────────────────────────────────────── */
.trade-lobby {
  width: 100%; min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #11332a 0%, #0a0a1a 60%);
  box-sizing: border-box;
  display: flex; flex-direction: column;
  overflow-x: hidden;
}

.trade-lobby-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 16px;
}
.trade-lobby-loading p { color: #94a3b8; font-size: 1.05rem; }

/* ── Top Bar ──────────────────────────────────────────────── */
.trade-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: linear-gradient(180deg, #0b2e1f 0%, transparent 100%);
  border-bottom: 1px solid #1f6e4d44;
  position: sticky; top: 0; z-index: 10;
}
.trade-topbar-back {
  background: none; border: 1px solid #38ca5a55; color: #7bfa9e;
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: .85rem;
  transition: all .2s;
}
.trade-topbar-back:hover { background: #38ca5a33; border-color: #7bfa9e; }
.trade-topbar-title {
  flex: 1; display: flex; align-items: center; gap: 8px;
  color: #e2e8f0; font-size: 1.2rem; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
}
.trade-topbar-icon { font-size: 1.4rem; }
.trade-topbar-user {
  display: flex; align-items: center; gap: 10px;
}
.trade-topbar-username {
  color: #7bfa9e; font-weight: 600; font-size: .95rem;
  background: #1b4b30; padding: 4px 12px; border-radius: 6px;
  border: 1px solid #38ca5a44;
}

/* ── Top Section (Create + Info) ──────────────────────────── */
.trade-top-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 24px 24px 0;
}

.trade-create-card, .trade-info-card {
  background: linear-gradient(135deg, #1a2e26 0%, #0f1f1a 100%);
  border: 1px solid #2d6e4d55;
  border-radius: 12px;
  padding: 20px;
}
.trade-create-card-title, .trade-info-title {
  color: #7bfa9e; font-weight: 700; font-size: 1rem;
  margin-bottom: 12px;
}
.trade-create-card-form {
  display: flex; gap: 8px;
}
.trade-create-input {
  flex: 1;
  background: #0f1f1a; border: 1px solid #2d6e4d66; color: #e2e8f0;
  padding: 10px 14px; border-radius: 8px; font-size: .9rem;
  outline: none;
}
.trade-create-input:focus { border-color: #7bfa9e; }
.trade-create-btn {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff; border: none; padding: 10px 20px;
  border-radius: 8px; font-weight: 700; cursor: pointer;
  font-size: .9rem; white-space: nowrap;
  transition: all .2s;
}
.trade-create-btn:hover { filter: brightness(1.2); transform: translateY(-1px); }
.trade-create-btn:disabled { opacity: .5; cursor: not-allowed; }

.trade-info-list {
  color: #94a3b8; font-size: .85rem;
  padding-left: 20px; margin: 0;
  line-height: 1.8;
}
.trade-info-list li { margin-bottom: 2px; }

/* ── Rooms ────────────────────────────────────────────────── */
.trade-rooms-section {
  padding: 24px;
}
.trade-rooms-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.trade-rooms-title {
  color: #e2e8f0; font-weight: 700; font-size: 1.1rem;
}
.trade-rooms-count {
  color: #64748b; font-size: .85rem;
}
.trade-rooms-empty {
  text-align: center; padding: 40px 20px;
  color: #64748b;
}
.trade-rooms-empty-icon { font-size: 3rem; margin-bottom: 12px; }
.trade-rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.trade-room-tile {
  background: linear-gradient(135deg, #1a2e26 0%, #0f1f1a 100%);
  border: 1px solid #2d6e4d44;
  border-radius: 12px;
  padding: 16px;
  transition: all .2s;
}
.trade-room-tile:hover { border-color: #7bfa9e; transform: translateY(-2px); }
.trade-room-tile-top {
  display: flex; justify-content: space-between; margin-bottom: 8px;
}
.trade-room-tile-status {
  font-size: .75rem; padding: 2px 8px; border-radius: 999px;
  font-weight: 600;
}
.trade-room-tile-status.waiting { background: #1b4b30; color: #7bfa9e; }
.trade-room-tile-status.trading { background: #4b3b1b; color: #fbbf24; }
.trade-room-tile-name {
  color: #e2e8f0; font-weight: 700; font-size: 1rem; margin-bottom: 8px;
}
.trade-room-tile-players {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .85rem; color: #94a3b8;
}
.trade-room-tile-host { color: #fbbf24; }
.trade-room-tile-vs { color: #7bfa9e; }
.trade-room-tile-btn {
  width: 100%; margin-top: 12px;
  padding: 8px; border-radius: 8px;
  font-weight: 700; font-size: .85rem;
  cursor: pointer; border: none;
  transition: all .2s;
}
.trade-room-tile-btn.join {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
}
.trade-room-tile-btn.join:hover { filter: brightness(1.2); }
.trade-room-tile-btn.own {
  background: #1b4b30; color: #7bfa9e;
  border: 1px solid #38ca5a44;
  cursor: pointer;
}
.trade-room-tile-btn.full {
  background: #1f2937; color: #64748b;
  cursor: not-allowed;
}
.trade-room-tile-btn:disabled {
  opacity: .5; cursor: not-allowed;
}

/* ── Pulse animation ─────────────────────────────────────── */
.trade-pulse {
  font-size: 3rem;
  animation: tradePulse 1.5s ease-in-out infinite;
}
.trade-pulse-small {
  font-size: 1.2rem;
  animation: tradePulse 1.5s ease-in-out infinite;
}
@keyframes tradePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: .7; }
}

/* ── Trade Room ──────────────────────────────────────────── */
.trade-room {
  width: 100%; min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #11332a 0%, #0a0a1a 60%);
  box-sizing: border-box;
  display: flex; flex-direction: column;
}

.trade-room-header {
  text-align: center; padding: 32px 24px 16px;
}
.trade-room-header h2 { color: #e2e8f0; margin: 0 0 8px; }
.trade-badge {
  background: #1b4b30; color: #7bfa9e;
  padding: 4px 14px; border-radius: 999px;
  font-size: .8rem; font-weight: 600;
}

.trade-waiting {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}
.trade-waiting-anim {
  text-align: center; padding: 32px;
}
.trade-waiting-anim p { color: #94a3b8; margin: 8px 0; }

/* ── Trade Complete ──────────────────────────────────────── */
.trade-complete {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}
.trade-complete-banner {
  text-align: center;
  animation: tradeCompleteIn .5s ease;
}
.trade-complete-icon {
  font-size: 4rem; margin-bottom: 16px;
}
.trade-complete-banner h2 {
  color: #7bfa9e; font-size: 2rem; margin: 0 0 8px;
}
.trade-complete-banner p {
  color: #94a3b8; font-size: 1rem;
}
@keyframes tradeCompleteIn {
  from { transform: scale(.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ── Buttons ─────────────────────────────────────────────── */
.trade-back-btn, .trade-leave-btn {
  background: none; border: 1px solid #38ca5a55; color: #7bfa9e;
  padding: 10px 24px; border-radius: 8px; cursor: pointer;
  font-size: .9rem; font-weight: 600;
  transition: all .2s;
}
.trade-back-btn:hover, .trade-leave-btn:hover {
  background: #38ca5a22; border-color: #7bfa9e;
}

/* ── Main Trade Layout ───────────────────────────────────── */
.trade-main-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* ── Collection Panel (left) ─────────────────────────────── */
.trade-collection {
  display: flex; flex-direction: column;
  border-right: 1px solid #2d6e4d33;
  overflow: hidden;
}
.trade-collection-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #2d6e4d33;
}
.trade-collection-header h3 {
  color: #e2e8f0; margin: 0 0 10px; font-size: 1rem;
}
.trade-filters {
  display: flex; gap: 8px;
}
.trade-search-input {
  flex: 1;
  background: #0f1f1a; border: 1px solid #2d6e4d44; color: #e2e8f0;
  padding: 6px 12px; border-radius: 6px; font-size: .85rem;
  outline: none;
}
.trade-search-input:focus { border-color: #7bfa9e; }
.trade-type-filter {
  background: #0f1f1a; border: 1px solid #2d6e4d44; color: #e2e8f0;
  padding: 6px 10px; border-radius: 6px; font-size: .85rem;
  cursor: pointer; outline: none;
}

.trade-card-grid {
  flex: 1; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  padding: 12px;
  align-content: start;
}
.trade-card-item {
  background: #1a2e26;
  border: 1px solid #2d6e4d44;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
  position: relative;
}
.trade-card-item:hover { border-color: #7bfa9e; transform: translateY(-2px); }
.trade-card-item.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.trade-card-item.depleted { opacity: .35; }
.trade-card-img {
  width: 100%; aspect-ratio: 421/614;
  object-fit: cover; border-radius: 4px;
  display: block;
}
span.trade-card-img {
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  background: #0f1f1a;
}
.trade-card-info {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 4px; padding: 0 2px;
}
.trade-card-name {
  color: #cbd5e1; font-size: .65rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; text-align: left;
}
.trade-card-qty {
  color: #7bfa9e; font-size: .7rem; font-weight: 700;
  margin-left: 4px;
}
.trade-card-stats {
  color: #94a3b8; font-size: .6rem; margin-top: 2px;
}
.trade-no-cards {
  grid-column: 1/-1;
  text-align: center; color: #64748b; padding: 32px;
}

/* ── In-deck badge ───────────────────────────────────────── */
.trade-card-in-deck {
  opacity: .45;
  cursor: not-allowed !important;
  pointer-events: none;
}
.trade-card-in-deck-badge {
  display: inline-block;
  background: #f59e0b22;
  color: #f59e0b;
  border: 1px solid #f59e0b44;
  border-radius: 4px;
  font-size: .58rem;
  font-weight: 700;
  padding: 1px 5px;
  margin-top: 3px;
  letter-spacing: .02em;
}

/* ── Offers Panel (right) ────────────────────────────────── */
.trade-offers {
  display: flex; flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.trade-offer-panel {
  background: #0f1f1a;
  border: 1px solid #2d6e4d44;
  border-radius: 10px;
  padding: 12px;
  flex: 1;
  min-height: 160px;
  display: flex; flex-direction: column;
}
.trade-offer-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.trade-offer-header h4 {
  color: #e2e8f0; margin: 0; font-size: .9rem; flex: 1;
}
.trade-locked-badge {
  background: #fbbf2422; color: #fbbf24;
  padding: 2px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 700;
}
.trade-confirmed-badge {
  background: #10b98122; color: #10b981;
  padding: 2px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 700;
}

.trade-offer-cards {
  display: flex; flex-wrap: wrap; gap: 6px;
  flex: 1; align-content: start;
}
.trade-offer-empty {
  color: #64748b; font-size: .8rem;
  text-align: center; padding: 20px 8px;
  width: 100%;
}

.trade-offer-card {
  width: 70px;
  background: #1a2e26;
  border: 1px solid #2d6e4d66;
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  text-align: center;
}
.trade-offer-card:hover { border-color: #f87171; }
.trade-offer-card.locked { cursor: default; opacity: .85; }
.trade-offer-card.locked:hover { border-color: #2d6e4d66; }
.trade-offer-card.partner { cursor: default; }
.trade-offer-card.partner:hover { border-color: #2d6e4d66; }

.trade-offer-card-img {
  width: 100%; aspect-ratio: 421/614;
  object-fit: cover; border-radius: 3px;
  display: block;
}
span.trade-offer-card-img {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  background: #0f1f1a;
}
.trade-offer-card-name {
  color: #94a3b8; font-size: .55rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: block; margin-top: 2px;
}
.trade-offer-remove {
  position: absolute; top: -4px; right: -4px;
  background: #ef4444; color: #fff;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: .6rem; display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  opacity: 0; transition: opacity .15s;
}
.trade-offer-card:hover .trade-offer-remove { opacity: 1; }

/* ── Divider ─────────────────────────────────────────────── */
.trade-arrow-divider {
  text-align: center; padding: 8px 0;
  color: #7bfa9e; font-size: 1.5rem; font-weight: 700;
}

/* ── Actions ─────────────────────────────────────────────── */
.trade-actions {
  padding: 12px 0 0;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
}
.trade-lock-btn {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #fff; border: none; padding: 10px 28px;
  border-radius: 8px; font-weight: 700; font-size: .9rem;
  cursor: pointer; transition: all .2s; width: 100%;
}
.trade-lock-btn:hover { filter: brightness(1.15); }
.trade-lock-btn:disabled { opacity: .4; cursor: not-allowed; }

.trade-confirm-btn {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff; border: none; padding: 10px 28px;
  border-radius: 8px; font-weight: 700; font-size: .9rem;
  cursor: pointer; transition: all .2s; width: 100%;
}
.trade-confirm-btn:hover { filter: brightness(1.15); }
.trade-confirm-btn:disabled { opacity: .4; cursor: not-allowed; }

.trade-unlock-btn {
  background: none; border: 1px solid #f59e0b44; color: #f59e0b;
  padding: 8px 20px; border-radius: 8px;
  font-size: .8rem; cursor: pointer;
  transition: all .2s; width: 100%;
}
.trade-unlock-btn:hover { background: #f59e0b11; }

.trade-waiting-confirm {
  display: flex; align-items: center; gap: 8px;
  color: #94a3b8; font-size: .85rem;
}

.trade-error {
  color: #f87171; font-size: .8rem;
  background: #f8717111; padding: 6px 12px;
  border-radius: 6px; border: 1px solid #f8717133;
  text-align: center; width: 100%;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .trade-top-section {
    grid-template-columns: 1fr;
  }
  .trade-main-layout {
    grid-template-columns: 1fr;
  }
  .trade-collection {
    border-right: none;
    border-bottom: 1px solid #2d6e4d33;
    max-height: 45vh;
  }
  .trade-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
}

@media (max-width: 520px) {
  /* Topbar */
  .trade-topbar {
    padding: 8px 12px;
    gap: 8px;
  }
  .trade-topbar-title {
    font-size: .95rem;
    letter-spacing: 0;
  }
  .trade-topbar-icon { font-size: 1.1rem; }
  .trade-topbar-username {
    font-size: .8rem;
    padding: 3px 8px;
  }
  .trade-topbar-back {
    font-size: .78rem;
    padding: 5px 10px;
  }

  /* Top section */
  .trade-top-section {
    padding: 12px 12px 0;
    gap: 10px;
  }
  .trade-create-card, .trade-info-card {
    padding: 14px;
  }
  .trade-create-card-form {
    flex-direction: column;
    gap: 8px;
  }
  .trade-create-btn {
    width: 100%;
  }

  /* Rooms */
  .trade-rooms-section {
    padding: 14px 12px;
  }
  .trade-rooms-grid {
    grid-template-columns: 1fr;
  }

  /* Trade room layout */
  .trade-main-layout {
    display: flex;
    flex-direction: column;
  }
  .trade-collection {
    max-height: 40vh;
  }
  .trade-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 6px;
    padding: 8px;
  }
  .trade-offers {
    padding: 10px;
  }
  .trade-offer-panel {
    min-height: 120px;
  }
  .trade-actions {
    padding: 10px 0 0;
  }
  .trade-lock-btn,
  .trade-confirm-btn,
  .trade-unlock-btn {
    font-size: .82rem;
    padding: 10px 16px;
  }

  /* Badge in-deck */
  .trade-card-in-deck-badge {
    font-size: .52rem;
    padding: 1px 4px;
  }
}
