/* Trades page — complements assets/style.css */

.trade-invite-section {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.trade-invite-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.trade-invite-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.trade-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.trade-field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.trade-field input,
.trade-field select {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--font);
}

.trade-field-invite {
  position: relative;
  flex: 1 1 14rem;
  min-width: 0;
}

.invite-suggestions {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.invite-suggestions[hidden] {
  display: none !important;
}

.invite-suggestion {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.invite-suggestion:last-child {
  border-bottom: none;
}

.invite-suggestion:hover,
.invite-suggestion:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.invite-suggestion-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

.invite-suggestion-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.invite-suggestion-handle {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
}

.invite-suggestion-display {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invite-suggestion-hint {
  padding: 0.45rem 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.trade-error {
  color: #f07178;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.trade-error[hidden] { display: none !important; }

.trade-muted { color: var(--muted); font-size: 0.9rem; }

.trade-msg-ok  { color: #c3e88d; margin-top: 0.5rem; font-size: 0.9rem; }
.trade-msg-err { color: #f07178; margin-top: 0.5rem; font-size: 0.9rem; }

/* Trade list items */
.trade-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.trade-list-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.trade-list-info strong { font-size: 0.95rem; }

.trade-list-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Trade room */
body.trade-room-active .page-head,
body.trade-room-active #trade-invite-section,
body.trade-room-active #trade-list-section {
  display: none;
}

body.trade-room-active .app-main {
  padding-top: 0.25rem;
}

.trade-room-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.trade-room-header-main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.65rem 1rem;
  min-width: 0;
}

.trade-room-back {
  flex-shrink: 0;
}

.trade-room-header h2 { margin: 0; font-size: 1.15rem; }

.trade-room-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.trade-offers-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.trade-offer-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.trade-offer-mine {
  border-color: rgba(91, 140, 255, 0.35);
}

.trade-offer-theirs {
  border-color: rgba(255, 255, 255, 0.12);
}

.trade-offer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.trade-offer-head h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.trade-offer-cards,
.trade-side-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-content: flex-start;
  min-height: 4.5rem;
  max-height: min(28vh, 220px);
  overflow-y: auto;
  margin-bottom: 0.65rem;
  padding: 0.35rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--border);
}

.trade-offer-currency {
  margin-top: auto;
  margin-bottom: 0;
}

.trade-picker-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.trade-picker-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-bottom: 1px solid transparent;
}

.trade-picker-panel[open] .trade-picker-summary {
  border-bottom-color: var(--border);
}

.trade-picker-summary::-webkit-details-marker {
  display: none;
}

.trade-picker-summary::before {
  content: "▸";
  color: var(--accent);
  transition: transform 0.15s ease;
}

.trade-picker-panel[open] .trade-picker-summary::before {
  transform: rotate(90deg);
}

.trade-picker-panel .trade-card-picker {
  padding: 0.85rem 1rem 1rem;
}

/* Legacy side blocks (picker moved out) */
.trade-room-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.trade-side {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.trade-side h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.trade-card-chip {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 0.82rem;
  overflow: hidden;
  border: 1px solid transparent;
}

.trade-card-chip-missing {
  padding: 0.35rem 0.6rem;
  color: var(--muted);
  font-size: 0.78rem;
  border: 1px dashed var(--border);
  background: transparent;
}

.trade-card-chip-hit {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  min-width: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.trade-card-chip-hit:hover,
.trade-card-chip-hit:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.06);
}

.trade-card-chip-hit:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.trade-card-chip img {
  width: 32px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.trade-card-chip .remove-card {
  flex-shrink: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  padding: 0 0.45rem;
  margin: 0;
  border: none;
  border-left: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  cursor: pointer;
  color: #f07178;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
}

.trade-card-chip .remove-card:hover,
.trade-card-chip .remove-card:focus-visible {
  background: rgba(240, 113, 120, 0.15);
  outline: none;
}

.trade-balance-hint {
  flex: 1 1 100%;
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.trade-balance-hint span:not(.trade-balance-sep) {
  font-family: var(--font-mono, var(--font));
  color: var(--text);
}

.trade-balance-sep {
  margin: 0 0.35rem;
  opacity: 0.5;
}

.trade-currency-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.trade-currency-inputs input {
  width: 6rem;
}

.trade-currency-display {
  display: flex;
  gap: 1rem;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.trade-card-picker input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  margin-bottom: 0.65rem;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 0.4rem;
  max-height: min(42vh, 360px);
  overflow-y: auto;
}

.picker-evo-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.85rem;
}

.picker-evo-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.picker-evo-heading {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.picker-evo-grid {
  max-height: min(28vh, 220px);
}

.picker-card {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.12s ease;
  text-align: center;
  padding: 0.25rem;
  font-size: 0.7rem;
}

.picker-card:hover { border-color: var(--accent); }

.picker-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.picker-card img {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.trade-ready-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.trade-ready-badge.is-ready {
  background: rgba(195, 232, 141, 0.15);
  color: #c3e88d;
}

.trade-ready-badge.not-ready {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.btn-accent {
  background: #c3e88d;
  color: #0c0e12;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 10px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
}

.btn-accent:hover { background: #a8d86e; }

.btn-accent.is-ready {
  background: #f07178;
  color: #fff;
}

.btn-small {
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
}

.btn-small:hover { border-color: var(--accent); }

.picker-pager {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

/* ----- Responsive ------------------------------------------------------- */

@media (max-width: 600px) {
  .trade-invite-form {
    flex-direction: column;
    align-items: stretch;
  }

  .trade-field-invite {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }

  .trade-list-item {
    flex-direction: column;
    align-items: stretch;
  }

  .trade-list-actions {
    justify-content: flex-end;
  }

  .trade-room-actions {
    width: 100%;
    justify-content: stretch;
  }

  .trade-room-actions .btn {
    flex: 1 1 auto;
  }

  .trade-currency-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    align-items: end;
  }

  .trade-currency-inputs .trade-balance-hint {
    grid-column: 1 / -1;
  }

  .trade-currency-inputs #btn-save-side {
    grid-column: 1 / -1;
    width: 100%;
  }

  .trade-card-chip {
    max-width: 100%;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .trade-offer-cards,
  .trade-side-cards {
    max-height: min(22vh, 120px);
  }

  .picker-grid,
  .picker-evo-grid {
    max-height: min(30vh, 150px);
  }

  body.trade-room-active .trade-picker-panel {
    max-height: min(38vh, 200px);
    overflow-y: auto;
  }
}
