/* Trade window of a trade with another player (see TradeWindow): two offer columns above a row of buttons that stays in view */
#trade-window > .body {
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: stretch;
  gap: 6px;
  padding: 6px;
  overflow-y: hidden;
}

/* The own offer on the left, the offer of the trade partner on the right: only the offers scroll */
.trade-offers {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.trade-offer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
}

.trade-offer + .trade-offer {
  padding-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
}

/* The name of the player that offers, with a check once it accepted: always one line, so accepting never changes the size of the window */
.trade-offer-header {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 14px;
  min-width: 0;
}

.trade-offer-name {
  flex: 0 1 auto;
  min-width: 0;
  color: #e0e0e0;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hidden but keeping its space until the player accepted */
.trade-offer-check {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--color-success);
  visibility: hidden;
}

.trade-offer.accepted .trade-offer-check {
  visibility: visible;
}

.trade-offer.accepted .trade-offer-name {
  color: var(--color-success);
}

/* The offered item first, then everything inside it */
.trade-offer-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, 34px);
  gap: 1px;
}

.trade-item {
  cursor: pointer;
}

.trade-offer-empty {
  color: var(--color-text-muted);
  font-style: italic;
}


/* Accept on the left, Cancel on the right */
.trade-actions {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  flex: 0 0 auto;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.trade-actions > button {
  flex: 1 1 0;
  margin: 0;
  padding: 2px 8px;
  color: #dddddd;
  font: inherit;
  border: 1px solid black;
  border-radius: 4px;
  background-image: var(--gradient-surface);
  box-shadow: var(--shadow-raised);
  cursor: pointer;
}

.trade-actions > button:not(:disabled):hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background-image: var(--gradient-surface-light);
}

.trade-actions > button.accent {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background-image: var(--gradient-accent);
}

.trade-actions > button.accent:not(:disabled):hover {
  background-image: var(--gradient-accent);
  box-shadow: var(--shadow-accent);
}

/* Before both offers are made, and once the trade was accepted */
.trade-actions > button:disabled {
  cursor: default;
  opacity: 0.4;
  filter: grayscale(1);
  border-color: black;
}

/* Trade page of the game menu (Menu > Trade, see TradePage): shared tabs with icons (ui-tab with-icon and ui-tab-page, see controls.css).
   The toolbar stays in place and only the list of the selected tab scrolls */
.game-menu-page.trade-page {
  gap: 10px;
  overflow: hidden;
}

.trade-page .trade-page-tab-page {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

/* Toolbar: the tabs and the search box (shared look and clear button, see text-field.css) */
.trade-page-toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.trade-page-tabs {
  flex: 0 0 auto;
  align-self: flex-start;
}

.trade-page-toolbar > .trade-page-search-wrapper {
  flex: 1 1 140px;
}

/* Number of entries of a tab: fixed width so the tabs keep their size, dimmed at zero, gold when the trade waits for the player */
.trade-page-count {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 24px;
  padding: 0 2px;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  line-height: 12px;
  text-align: center;
  white-space: nowrap;
  color: var(--color-text-soft);
  border: 1px solid #5a5a5a;
  border-radius: 7px;
  background-color: rgba(0, 0, 0, 0.45);
}

.trade-page-count.zero {
  opacity: 0.5;
}

.trade-page-count.highlight {
  color: var(--color-accent-darker);
  border-color: var(--color-accent);
  background-color: var(--color-accent);
  box-shadow: 0 0 4px var(--color-accent-glow);
}

/* Part of a name that matches the search */
.trade-page-match {
  color: var(--color-accent-text);
  border-radius: 2px;
  background-color: var(--color-accent-dark);
}

.trade-page-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Player or offer row: badge (outfit or offered item), name with details and the tags and buttons on the right */
.trade-page-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 5px;
  border: 1px solid black;
  border-radius: 8px;
  background-image: linear-gradient(to right, #444444, #2a2a2a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.6);
}

.trade-page-badge {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 10px;
  font-weight: bold;
  color: var(--color-accent);
  border: 1px solid var(--color-accent-dark);
  border-radius: 8px;
  background-image: radial-gradient(circle at 30% 25%, #555555, #1a1a1a 80%);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

/* The 40px outfit preview (see Canvas.drawOutfitPreview) is centered and its empty edges are cut off */
.trade-page-badge canvas {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

/* Items on the page are only shown (their tooltip still works) */
.trade-page .trade-item {
  flex: 0 0 auto;
  cursor: default;
}

.trade-page-row-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.trade-page-row-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 12px;
  font-weight: bold;
}

.trade-page-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-page-row-details {
  font-size: 10px;
  font-weight: normal;
  color: var(--color-text-muted);
}

/* Row labels: offers waiting for an answer in the accent, trades in progress and acceptances in green */
.trade-page-tag.highlight {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.trade-page-tag.trading {
  color: var(--color-success);
  border-color: var(--color-success);
}

/* Buttons of the rows and the trade summary: shared look and variants (ui-button, see controls.css), a bit smaller */
.modal button.trade-page-button {
  flex: 0 0 auto;
  margin: 0;
  padding: 3px 10px;
  font-size: 10px;
}

/* Summary of the current trade with its buttons */
.trade-page-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  padding: 8px 12px;
  border: 1px solid var(--color-accent-dark);
  border-radius: 10px;
  background-image:
    radial-gradient(circle at 0% 0%, var(--color-accent-haze), transparent 65%),
    var(--gradient-card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 6px rgba(0, 0, 0, 0.6);
}

.trade-page-summary-text {
  display: flex;
  flex: 1 1 160px;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.trade-page-summary-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: bold;
  color: var(--color-accent-text);
}

.trade-page-summary-subtitle {
  font-size: 10px;
  font-weight: normal;
  color: var(--color-text-muted);
}

/* Note above the players around: how close the players must stand */
.trade-page-notice {
  margin-bottom: 8px;
  padding: 7px 10px;
  font-size: 10px;
  font-weight: normal;
  line-height: 1.5;
  color: var(--color-text-soft);
  border: 1px solid black;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.3);
}

/* Gamemasters: the name of the character to look up with its buttons */
.trade-page-lookup {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.trade-page-lookup > .text-field-box {
  flex: 1 1 auto;
  min-width: 0;
}

/* A completed trade: the trade partner and the time, then the items given and received */
.trade-page-history-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid black;
  border-radius: 8px;
  background-image: var(--gradient-card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.6);
}

.trade-page-history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.trade-page-history-partner {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: bold;
}

.trade-page-history-time {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--color-text-muted);
}

.trade-page-history-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.trade-page-history-label {
  flex: 0 0 56px;
  padding-top: 10px;
  font-size: 10px;
  color: var(--color-text-soft);
}

.trade-page-history-items {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  min-width: 0;
}

/* Lists without entries */
.trade-page-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 24px 12px;
  text-align: center;
}

.trade-page-empty-title {
  font-size: 12px;
  font-weight: bold;
  color: var(--color-text-soft);
}

.trade-page-empty-text {
  max-width: 320px;
  font-size: 10px;
  font-weight: normal;
  line-height: 1.5;
  color: var(--color-text-muted);
}
