/* The trade window of an NPC (OfferModal, r182): as Minibia's, Buy From / Sell To, the offers with their prices, the
   selected offer with its weight, price and amount, the gold and the total; what cannot be paid, carried or sold in red */
#offer-modal.npc-trade {
  --trade-panel: rgba(38, 37, 35, 0.97);
  --trade-well: rgba(24, 23, 22, 0.92);
  width: min(380px, 94vw);
  background: var(--trade-panel);
  color: #ece6d6;
  border: 1px solid #0c0c0c;
  outline: 1px solid #4a4741;
  border-radius: 3px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
  font: 12px Verdana, Arial, sans-serif;
}

#offer-modal.npc-trade-faded {
  --trade-panel: rgba(38, 37, 35, 0.62);
  --trade-well: rgba(18, 17, 16, 0.55);
}

#offer-modal .modal-header {
  padding: 8px 60px;
  background: linear-gradient(180deg, rgba(60, 58, 54, 0.9), rgba(40, 39, 36, 0.9));
  border-bottom: 1px solid #0c0c0c;
  font-size: 14px;
  font-weight: bold;
  color: #f4efe2;
}

#offer-modal .close-button-transparent,
#offer-modal .npc-trade-fade {
  top: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 12px;
  line-height: 20px;
  color: #e9e4d8;
  background: #1d1c1a;
  border: 1px solid #55514a;
  border-radius: 3px;
  cursor: pointer;
}

#offer-modal .close-button-transparent {
  right: 8px;
}

#offer-modal .npc-trade-fade {
  position: absolute;
  right: 36px;
}

#offer-modal .npc-trade-fade::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  vertical-align: -1px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

#offer-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: none;
  box-shadow: none;
}

.npc-trade-panel {
  padding: 8px;
  background: var(--trade-well);
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3b3833;
  border-radius: 4px;
}

.npc-trade-tabs {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: var(--trade-well);
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3b3833;
  border-radius: 4px;
}

#offer-modal .offer-tab {
  flex: 1 1 0;
  padding: 6px 4px;
  font: bold 11px Verdana, Arial, sans-serif;
  color: #b9b2a2;
  background: #151413;
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #34312c;
  border-radius: 4px;
  cursor: pointer;
}

#offer-modal .offer-tab.selected {
  color: #f0c24b;
  box-shadow: inset 0 0 0 1px #c9a13b;
}

#offer-modal .offers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px 6px;
  max-height: 168px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.npc-trade-offer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px 0 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}

.npc-trade-offer canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  background: #121110;
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3d3a34;
}

.npc-trade-offer:hover {
  background: rgba(255, 255, 255, 0.04);
}

.npc-trade-offer.selected {
  border-color: #c9a13b;
  background: rgba(201, 161, 59, 0.08);
}

/* An item the player does not have, in the Sell tab */
.npc-trade-offer.missing {
  opacity: 0.4;
}

.npc-trade-price {
  font-size: 10px;
  font-weight: bold;
  white-space: nowrap;
}

/* The gold coin of the game (item 2148, one coin: its 9 x 9 pixels, not scaled), before every price and the gold
   (r183, user: "no debe salir un puntito marcando el dinero, debe salir un gold coin, pero que no sea muy grande") */
.npc-trade-coin {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 2px;
  vertical-align: -1px;
  background: url("../png/gold-coin.png") no-repeat;
  image-rendering: pixelated;
}

.npc-trade-empty-list {
  grid-column: 1 / -1;
  padding: 8px;
  text-align: center;
  color: #9a9384;
}

#offer-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.npc-trade-empty,
.npc-trade-detail {
  display: flex;
  align-items: center;
  gap: 10px;
}

.npc-trade-empty[hidden],
.npc-trade-detail[hidden],
.npc-trade-amount[hidden] {
  display: none;
}

.npc-trade-placeholder {
  width: 44px;
  height: 44px;
  border: 1px dashed #5a564e;
  border-radius: 4px;
}

.npc-trade-empty span {
  font-size: 13px;
  font-weight: bold;
  color: #9a9384;
}

.npc-trade-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  image-rendering: pixelated;
}

.npc-trade-facts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  font-weight: bold;
}

#offer-name {
  font-size: 14px;
  color: #f4efe2;
}

.npc-trade-good {
  color: #7bd87b;
}

.npc-trade-bad {
  color: #ff6b6b;
}

.npc-trade-amount {
  display: flex;
  align-items: center;
  gap: 8px;
}

#offer-modal .offer-step {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  padding: 0;
  font: bold 14px Verdana, Arial, sans-serif;
  line-height: 20px;
  color: #ece6d6;
  background: #1b1a18;
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3d3a34;
  border-radius: 4px;
  cursor: pointer;
}

#offer-modal .offer-step[hidden] {
  display: none;
}

body.force-mobile #offer-modal .offer-step {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

/* The amount: a thin track filled in gold up to a round gold knob (Minibia's), over the slider.css look of the other
   sliders. --fill is set by OfferModal.handleChangeCount */
#offer-modal #buy-count {
  flex: 1 1 auto;
  min-width: 0;
  height: 16px;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  cursor: pointer;
}

#offer-modal #buy-count::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  border: 1px solid #0c0c0c;
  background: linear-gradient(90deg, #b8913a 0 var(--fill, 0%), #2c2a26 var(--fill, 0%) 100%);
}

#offer-modal #buy-count::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  border: 1px solid #0c0c0c;
  background: linear-gradient(90deg, #b8913a 0 var(--fill, 0%), #2c2a26 var(--fill, 0%) 100%);
}

#offer-modal #buy-count::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  border: 1px solid #6b4f12;
  background: radial-gradient(circle at 35% 35%, #fff1b8, #e6bd52 55%, #a97d22);
}

#offer-modal #buy-count::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #6b4f12;
  background: radial-gradient(circle at 35% 35%, #fff1b8, #e6bd52 55%, #a97d22);
}

.npc-trade-times {
  min-width: 34px;
  text-align: right;
  font-weight: bold;
  color: #f0c24b;
}

.npc-trade-totals {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #3b3833;
  font-weight: bold;
}

.npc-trade-totals [hidden] {
  display: none;
}

.npc-trade-error {
  text-align: center;
  font-weight: bold;
  color: #ff6b6b;
}

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

#offer-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#offer-modal .modal-footer button {
  min-width: 84px;
  padding: 6px 14px;
  font: bold 12px Verdana, Arial, sans-serif;
  color: #ece6d6;
  background: #1b1a18;
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3d3a34;
  border-radius: 4px;
  cursor: pointer;
}

#offer-modal .modal-footer button[action="confirm"] {
  color: #f0c24b;
  box-shadow: inset 0 0 0 1px #c9a13b;
}

/* r183, the phone (user 2026-11-02 with Minibia's screenshots): the trade window was a child of the game screen and was
   cut at its edges (488 px high in a 428 px landscape: no title above, no Confirm below). On the phone it sits over the
   HUD in the middle of the screen and always fits it: lying down the offers on the left and the chosen one with Cancel /
   Confirm on the right, upright one column with about two rows of offers that scroll. Items, buttons and icons the size
   of a finger */
body.force-mobile #offer-modal.npc-trade {
  position: fixed;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
  z-index: 40000;
  width: min(600px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  font-size: 13px;
}

body.force-mobile #offer-modal .modal-header {
  padding: 12px 96px;
  font-size: 16px;
}

body.force-mobile #offer-modal .close-button-transparent,
body.force-mobile #offer-modal .npc-trade-fade {
  top: 6px;
  max-width: none;
  width: 34px;
  height: 34px;
  font-size: 16px;
  line-height: 32px;
}

body.force-mobile #offer-modal .npc-trade-fade {
  right: 46px;
}

body.force-mobile #offer-modal .npc-trade-fade::before {
  width: 14px;
  height: 14px;
}

body.force-mobile #offer-modal .offer-tab {
  min-height: 36px;
  font-size: 13px;
}

body.force-mobile #offer-modal .offers {
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  align-content: start;
}

body.force-mobile .npc-trade-offer canvas {
  width: 40px;
  height: 40px;
}

body.force-mobile .npc-trade-price {
  font-size: 12px;
}

body.force-mobile #offer-modal .modal-footer button {
  min-height: 38px;
  min-width: 100px;
  font-size: 14px;
}

body.force-mobile #offer-modal #buy-count {
  height: 34px;
}

@media (orientation: landscape) {
  body.force-mobile #offer-modal .modal-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "tabs tabs" "offers info" "offers footer";
    grid-template-rows: auto 1fr auto;
  }

  body.force-mobile #offer-modal .npc-trade-tabs { grid-area: tabs; }
  body.force-mobile #offer-modal .offers { grid-area: offers; max-height: calc(100dvh - 150px); }
  body.force-mobile #offer-modal #offer-info { grid-area: info; align-self: start; }
  body.force-mobile #offer-modal .modal-footer { grid-area: footer; }
}

@media (orientation: portrait) {
  body.force-mobile #offer-modal.npc-trade {
    width: min(360px, calc(100vw - 16px));
  }

  body.force-mobile #offer-modal .offers {
    max-height: 132px;
  }
}
