/* Orders page. Tokens and components come from style.css; only what is particular to this page is here. */

.top b { color: var(--ivory); font-weight: 600; }
.top { align-items: center; }

/* ---------- account header ---------- */

/* Trades left, visibility, the auto-invisible switch and the account buttons, in one chamfered read-out */
.account-actions {
  --cut: 10px;
  --fill: var(--surface-1);
  display: grid;
  grid-template-columns: auto minmax(11rem, auto);
  align-items: start;
  gap: var(--sp-2) var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--hairline);
  border-top-color: color-mix(in srgb, var(--gold) 50%, transparent);
  box-shadow: var(--edge);
}
.account-actions[hidden] { display: none; }
.account-cell { display: grid; gap: 0.15rem; min-width: 0; }
.account-cell .eyebrow { margin: 0; color: var(--muted); }
.account-cell .quiet { font-size: var(--step--2); line-height: 1.35; }
#trades-remaining { font: 600 var(--step-2)/1.15 var(--num); color: var(--ivory); }
#trades-remaining[data-empty="true"] { color: var(--danger); }
.account-visibility select { justify-self: start; min-width: 10rem; }
.account-auto, .account-buttons { grid-column: 1 / -1; }
.account-auto { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--step--1); color: var(--muted); }
.account-buttons { display: flex; gap: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--line-soft); }
.account-buttons #signout { margin-left: auto; }

/* Your presence on warframe.market, as other players see it */
.presence.ingame { background: var(--void-soft); color: var(--info); }
.presence.online { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }

/* ---------- incoming buyers ---------- */

.buyer-queue .panel-head p { color: var(--muted); }
.buyers-help { margin: 0 0 var(--sp-3); }
.buyers-help p { max-width: 60rem; margin: var(--sp-2) 0 0; color: var(--muted); }
.buyers-sync { margin: 0 0 var(--sp-2); font-size: var(--step--1); }
.buyer-queue .empty { padding: var(--sp-5) var(--sp-4); }
.buyer-queue .skeleton span { height: 2rem; }

.buyer-group { padding: var(--sp-3) 0 var(--sp-2); border-top: 1px solid var(--line-soft); animation: rise 320ms var(--ease) backwards; }
.buyer-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--sp-1) var(--sp-4); }
.buyer-head h3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: 0; font: 400 var(--step-1)/1.3 var(--display); color: var(--ivory); }
.buyer-head p { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); margin: 0; font-size: var(--step--1); }
.buyer-list { margin: var(--sp-2) 0 0; padding: 0; list-style: none; }
.buyer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--line);
  font-size: var(--step--1);
  transition: background var(--fast) ease, border-color var(--fast) ease;
}
.buyer-row + .buyer-row { border-top: 1px solid var(--line-soft); }
.buyer-row:hover { background: var(--surface-2); border-left-color: var(--gold); }
.buyer-pos { color: var(--gold); min-width: 1.75rem; }
.buyer-name { color: var(--ivory); font-weight: 600; }
.buyer-row button { margin-left: auto; }
/* A quote that does not match your sell order (or has no visible order to match). */
.buyer-row.mismatch { border-left-color: var(--danger); background: rgba(224, 138, 122, 0.06); }
.buyer-row.mismatch:hover { border-left-color: var(--danger); }
.buyer-row.mismatch .buyer-quote .listed { color: var(--danger); }
.buyer-alert { display: inline-flex; align-items: center; max-width: 100%; gap: var(--sp-1); color: var(--danger); font-weight: 600; }
.alert-icon {
  flex: none;
  width: 1em;
  height: 1em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1 15.5 14.5H.5Z M7 6v4.5h2V6Zm0 5.5v2h2v-2Z' fill-rule='evenodd'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1 15.5 14.5H.5Z M7 6v4.5h2V6Zm0 5.5v2h2v-2Z' fill-rule='evenodd'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- sign in ---------- */

.signin { max-width: 36rem; padding: var(--sp-5); animation: rise 420ms var(--ease) backwards; }
.signin[hidden] { display: none; }
.signin h2 { margin: 0 0 var(--sp-1); font: 400 var(--step-2)/1.2 var(--display); color: var(--gold); }
.signin > p { margin: 0 0 var(--sp-4); font-size: var(--step--1); }
.signin form { display: grid; gap: var(--sp-3); }
.signin label { display: grid; gap: var(--sp-1); font-size: var(--step--1); color: var(--muted); }
.signin input { width: 100%; padding: 0.55rem 0.7rem; }
.signin input[name="token"] { font-family: ui-monospace, monospace; font-size: var(--step--1); }
.signin-submit { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); }
.signin-submit .primary { flex: none; }
.signin-submit p { flex: 1 1 14rem; margin: 0; font-size: var(--step--2); line-height: 1.4; }
.signin .token { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line-soft); }
.signin .token summary { width: fit-content; max-width: 100%; color: var(--info); font-size: var(--step--1); cursor: pointer; }
.signin .token summary:hover { color: var(--ivory); }
.signin .token ol { margin: var(--sp-3) 0; padding-left: 1.25rem; font-size: var(--step--1); }
.signin .token ol li + li { margin-top: var(--sp-1); }
.form-error { margin: 0; padding: var(--sp-2) var(--sp-3); border-left: 2px solid var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); font-size: var(--step--1); }
.form-error:empty { display: none; }

/* ---------- tools ---------- */

.tool-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tool-hint { flex-basis: 100%; margin: calc(-1 * var(--sp-1)) 0 0; font-size: var(--step--2); }
.tool-hint:empty { display: none; }
.tool .batch-progress, .sellbar .batch-progress { flex: 1 1 100%; }
.table-note { margin: var(--sp-3) 0 0; font-size: var(--step--2); }

/* ---------- tables ---------- */

td.pick, th.pick { width: 2rem; padding-right: 0; }
td.pick input, th.pick input { accent-color: var(--gold); }
table.sell tbody tr:not(.picked) td { color: var(--muted); }
table.sell tbody tr:not(.picked) img { opacity: 0.6; }
table.sell tbody tr.picked td:first-child { box-shadow: inset 2px 0 0 var(--gold); }

.cell-name > div { display: grid; gap: 0.15rem; min-width: 0; }
.cell-name .sub { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; }
.cell-name .chip { white-space: normal; }

input.num.qty { width: 4rem; }

.listed { font-family: var(--num); color: var(--gold); }
.hidden-order .listed, .listed.hidden-order { color: var(--muted); }
td.warn { color: var(--warn); }

.standing { font-size: var(--step--1); }
.standing .best { color: var(--ok); }
.standing .behind { color: var(--gold); }
.standing .match { margin-left: var(--sp-1); padding: 0.05rem 0.45rem; }

/* A hidden order stays in the list, dimmed */
table.orders tr.hidden-order td:not(:nth-last-child(-n+2)) { opacity: 0.55; }
table.orders tr.busy { opacity: 0.6; }

.row-actions { display: inline-flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; justify-content: flex-end; }
/* Save appears once the price or quantity typed differs from the order */
tr:not(.dirty) .save { display: none; }
tr.dirty .save { animation: pop 260ms var(--ease); }
tr.dirty input.num { border-color: var(--void); }

/* Visible on warframe.market: a switch */
.switch {
  position: relative;
  flex: none;
  width: 2.4rem;
  height: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--lapis-900);
  cursor: pointer;
  transition: background var(--mid) ease, border-color var(--mid) ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--mid) var(--ease), background var(--mid) ease;
}
.switch:hover:not(:disabled) { border-color: var(--line-hover); }
.switch[aria-checked="true"] { background: var(--gold-soft); border-color: var(--gold); }
.switch[aria-checked="true"]::after { transform: translateX(1.05rem); background: var(--gold-hi); }
.switch:disabled { opacity: 0.5; cursor: default; }

/* ---------- listing bar ---------- */

.sellbar {
  --cut: 10px;
  --fill: color-mix(in srgb, var(--surface-2) 94%, transparent);
  --cut-line: var(--gold);
  position: sticky;
  bottom: var(--sp-4);
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-5);
  margin-top: var(--sp-5);
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-5);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--edge);
  animation: rise 320ms var(--ease);
}
.sellbar[hidden] { display: none; }
.sellbar p[hidden], .sellbar button[hidden] { display: none; }
.sellbar p { margin: 0; font-size: var(--step--1); color: var(--muted); }
.sellbar b { color: var(--ivory); font-family: var(--num); font-size: var(--step-0); }

/* ---------- repricing every order ---------- */

dialog.reprice {
  width: min(56rem, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  display: flex;
  flex-direction: column;
}
dialog.reprice:not([open]) { display: none; }
.reprice-head, .reprice-tools, .reprice-summary, .reprice-foot { padding: 0 var(--sp-5); }
.reprice-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding-top: var(--sp-4); }
.reprice-head h2 { margin: 0; }
.reprice-tools { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); margin-top: var(--sp-3); }
.reprice-tools .tool-hint { margin: 0; }
.reprice-summary { margin-top: var(--sp-4); }
.reprice-summary p { margin: var(--sp-2) 0 0; font-size: var(--step--1); }
.reprice-summary .down { color: var(--danger); }
.reprice-stats { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.reprice-stats > div {
  --cut: 8px;
  --fill: var(--surface-1);
  display: grid;
  min-width: 7rem;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-soft);
}
.reprice-stats b { font: 600 var(--step-1)/1.15 var(--num); font-variant-numeric: tabular-nums; color: var(--ivory); }
.reprice-stats span { font-size: var(--step--2); color: var(--muted); }
.reprice-stats .up b { color: var(--up); }
.reprice-stats .down b { color: var(--down); }
.reprice-list {
  flex: 1;
  min-height: 6rem;
  margin-top: var(--sp-4);
  overflow: auto;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.reprice-list .empty { margin: var(--sp-4) var(--sp-5); }
.reprice-table thead th { background: var(--surface-3); }
.reprice-table th:first-child, .reprice-table td:first-child { padding-left: var(--sp-5); }
.reprice-table th:last-child, .reprice-table td:last-child { padding-right: var(--sp-5); }
.reprice-table td.new { color: var(--ivory); font-weight: 600; }
.reprice-table.preview tbody tr:not(.picked) td:not(.pick) { opacity: 0.5; }
.reprice-table tr.failed td:first-child { box-shadow: inset 2px 0 0 var(--danger); }
.reprice-table .chip { white-space: normal; }
dialog.reprice td.pick input, dialog.reprice th.pick input { width: 1rem; margin: 0; padding: 0; }
dialog.reprice > .batch-progress { margin: var(--sp-3) var(--sp-5) 0; }
.reprice-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); padding-top: var(--sp-3); padding-bottom: var(--sp-4); }
.reprice-foot p { margin: 0; font-size: var(--step--1); }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 10;
  display: grid;
  gap: var(--sp-2);
  max-width: min(26rem, calc(100vw - 2rem));
}
.toast {
  --cut: 8px;
  --fill: var(--surface-3);
  --cut-line: var(--ok);
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  box-shadow: var(--edge);
  font-size: var(--step--1);
  animation: rise 320ms var(--ease);
  transition: opacity var(--mid) ease, transform var(--mid) var(--ease);
}
.toast::before { content: "\25C6"; flex: none; color: var(--ok); font-size: 0.6rem; }
.toast.error { --cut-line: var(--danger); border-left-color: var(--danger); }
.toast.error::before { color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- tablet and phone ---------- */

@media (max-width: 64rem) {
  .top { align-items: flex-start; }
}

/* Wide tables scroll inside their box between phone and desktop widths only, so their headers
   stay sticky against the page elsewhere */
@media (min-width: 40.01rem) and (max-width: 64rem) {
  .table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
}

@media (max-width: 40rem) {
  .account-actions { width: 100%; grid-template-columns: 1fr 1fr; gap: var(--sp-2) var(--sp-3); }
  .account-visibility select { width: 100%; min-width: 0; }
  .signin { padding: var(--sp-4); }
  .signin-submit .primary { width: 100%; }
  .buyer-row { padding: var(--sp-2); }
  .buyer-row button { margin-left: 0; }
  .tool-actions { width: 100%; }

  /* Stacked rows: the tick box sits in the card's corner, the name heads the card */
  table.stack tr { position: relative; }
  table.stack td.hide-sm { display: none; }
  table.stack td.pick { position: absolute; top: var(--sp-2); right: var(--sp-3); padding: 0; }
  table.stack td.name { display: block; padding: 0 2rem var(--sp-1) 0; text-align: left; }
  table.stack td input.num { width: 6rem; }
  table.orders td.actions { display: block; padding-top: var(--sp-2); }
  table.orders .row-actions { display: flex; justify-content: flex-start; }
  table.orders .standing { white-space: normal; text-align: right; }
  table.sell tbody tr.picked { border-left-color: var(--gold); }
  table.sell tbody tr.picked td:first-child { box-shadow: none; }
  .reprice-head, .reprice-tools, .reprice-summary, .reprice-foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .reprice-list { padding: var(--sp-2) var(--sp-3) 0; }
  .reprice-table th:first-child, .reprice-table td:first-child, .reprice-table th:last-child, .reprice-table td:last-child { padding-left: 0; padding-right: 0; }
  .reprice-table td.pick { padding: 0 !important; }
  .reprice-table td.name { padding-right: 2rem !important; }
  .reprice-foot .primary { width: 100%; }
  .sellbar { bottom: var(--sp-2); padding: var(--sp-3); }
  .sellbar .primary { width: 100%; }
  .toasts { left: var(--sp-3); right: var(--sp-3); bottom: var(--sp-3); max-width: none; }
}

/* ---------- trades to confirm (wfcli matched an in-game trade to your orders) ---------- */

.trade-prompts .panel-head p { color: var(--muted); }
.trade-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-3);
  border-left: 2px solid var(--gold);
  border-top: 1px solid var(--line-soft);
  animation: rise 320ms var(--ease) backwards;
}
.trade-prompt.failed { border-left-color: var(--danger); }
.trade-prompt-text { flex: 1 1 20rem; margin: 0; font-size: var(--step--1); }
.trade-prompt-text b { color: var(--ivory); }
.trade-prompt-text ul { margin: var(--sp-1) 0 0; padding-left: var(--sp-4); }
.trade-prompt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.trade-prompt .state { font-size: var(--step--1); color: var(--muted); }
.trade-prompt .state.error { color: var(--danger); }

/* My orders filters and bulk actions */
.tool[data-for="orders"] > .batch-progress { flex: 1 1 100%; }
.row-actions .add-unit { min-width: 2.6rem; }
