/* ─── SwapBins app-area styles ───────────────────────────────────────────────
   Layered on top of site.css. Uses the same brand tokens (:root in site.css).
   Covers auth pages, /listings, and the signed-in /app area. */

:root {
  --sb-line: #dfe8e9;
  --sb-danger: #c23b22;
  --sb-ok: #1b7f74;
  --sb-radius: 14px;
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.wrap { max-width: 1000px; margin: 0 auto; padding: 28px clamp(16px, 5vw, 40px) 80px; }
.wrap--narrow { max-width: 520px; }
.wrap--wide { max-width: 1160px; }

.pagelead { margin: 8px 0 24px; }
.pagelead h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(26px, 4vw, 38px); line-height: 1.1; color: var(--brand-silhouette); margin: 0;
}
.pagelead p { color: var(--brand-body); font-size: 15px; margin: 8px 0 0; }

.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row--between { justify-content: space-between; }
.muted { color: var(--brand-body); font-size: 14px; }
.spacer { flex: 1; }

/* ─── App bar ─────────────────────────────────────────────────────────────── */
.appbar {
  position: sticky; top: 0; z-index: 100;
  background: #fff; border-bottom: 1px solid var(--sb-line);
}
.appbar__inner {
  max-width: 1160px; margin: 0 auto; padding: 12px clamp(16px, 5vw, 40px);
  display: flex; align-items: center; gap: 18px;
}
.appbar__brand { display: inline-flex; align-items: center; }
.appbar__brand img { height: 30px; width: auto; display: block; }
.appbar__nav { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.appbar--bare .appbar__inner { justify-content: center; }
.appbar__link {
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  color: var(--brand-body); padding: 8px 12px; border-radius: 9px;
}
.appbar__link:hover { background: var(--brand-tint); color: var(--brand-silhouette); }
.appbar__link.is-active { color: var(--brand-silhouette); background: var(--brand-tint); }
.appbar__avatar {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  background: var(--brand-tint); border: 1px solid var(--sb-line);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  letter-spacing: .02em; cursor: pointer;
  padding: 11px 20px; border-radius: 999px; border: 1.5px solid transparent;
  background: var(--brand-tint); color: var(--brand-silhouette);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--brand-secondary); color: #fff; box-shadow: 0 10px 24px rgba(242,112,75,.28); }
.btn--accent { background: var(--brand-primary); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--brand-silhouette); }
.btn--danger { background: transparent; border-color: var(--sb-danger); color: var(--sb-danger); }
.btn--sm { padding: 7px 13px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-primary); font: inherit; cursor: pointer; text-decoration: underline; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid var(--sb-line); border-radius: var(--sb-radius);
  padding: clamp(18px, 3vw, 28px);
}
.card + .card { margin-top: 16px; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.field { margin: 0 0 16px; }
.field > label { display: block; font-weight: 600; font-size: 14px; color: var(--brand-silhouette); margin: 0 0 6px; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=date], .field input[type=number], .field input[type=search],
.field textarea, .field select {
  width: 100%; font: inherit; color: var(--brand-silhouette);
  padding: 11px 13px; border: 1.5px solid var(--sb-line); border-radius: 10px; background: #fff;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(28,160,166,.15);
}
.field__hint { font-size: 12.5px; color: var(--brand-body); margin: 5px 0 0; }
.field__error { font-size: 12.5px; color: var(--sb-danger); margin: 5px 0 0; font-weight: 600; }
.field--invalid input, .field--invalid textarea, .field--invalid select { border-color: var(--sb-danger); }
.field--invalid .taginput { border-color: var(--sb-danger); }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 200px; min-width: 0; }
/* On phones, form fields always stack full-width (side-by-side inputs collided).
   Reset the flex basis or it becomes a 200px *height* once the axis is vertical. */
@media (max-width: 560px) {
  .field-row { flex-direction: column; gap: 0; }
  .field-row > .field { flex: 0 0 auto; }
}
fieldset { border: 1px solid var(--sb-line); border-radius: 10px; padding: 14px 16px; margin: 0 0 16px; }
fieldset legend { font-weight: 600; font-size: 13px; padding: 0 6px; color: var(--brand-silhouette); }
.radio-line { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }
.radio-line input { margin: 0; }

/* ─── Alerts / flash ──────────────────────────────────────────────────────── */
.alert { border-radius: 10px; padding: 12px 14px; font-size: 14px; margin: 0 0 16px; border: 1px solid; }
.alert--success { background: #e7f6f2; border-color: #b7e2d8; color: #145b52; }
.alert--error { background: #fdece7; border-color: #f4c3b4; color: #8f2f1a; }
.alert--info { background: var(--brand-tint); border-color: #bfe4e4; color: #14323B; }
.flash-stack { margin-bottom: 8px; }

/* ─── Listing grid + card ─────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.lcard { display: flex; flex-direction: column; border: 1px solid var(--sb-line); border-radius: var(--sb-radius); overflow: hidden; background: #fff; }
.lcard:hover { box-shadow: 0 16px 40px rgba(12,30,36,.12); }
.lcard__media { aspect-ratio: 4 / 3; background: var(--brand-tint); overflow: hidden; }
.lcard__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lcard__media--empty { display: flex; align-items: center; justify-content: center; color: #9bb3b5; font-size: 13px; }
.lcard__body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 4px; }
.lcard__title { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--brand-silhouette); line-height: 1.3; }
.lcard__meta { font-size: 12.5px; color: var(--brand-body); }

.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--brand-tint); color: #14323B; }
.badge--draft { background: #fff4e5; color: #97591b; }
.badge--swapped { background: #eee; color: #555; }
.badge--active { background: #e7f6f2; color: #145b52; }

/* ─── Filters ─────────────────────────────────────────────────────────────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 22px; }
.filters form.search { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--sb-line); color: var(--brand-body); }
.chip.is-active { background: var(--brand-silhouette); color: #fff; border-color: var(--brand-silhouette); }

/* ─── Listing detail ─────────────────────────────────────────────────────── */
.detail { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 44px); }
.gallery { display: flex; flex-direction: column; gap: 10px; }
.gallery__main { border-radius: var(--sb-radius); overflow: hidden; background: var(--brand-tint); aspect-ratio: 4 / 3; }
.gallery__main img, .gallery__main video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery__thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery__thumbs img { width: 68px; height: 68px; object-fit: cover; border-radius: 8px; border: 1px solid var(--sb-line); }
.definition { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 16px 0; }
.definition dt { color: var(--brand-body); }
.definition dd { margin: 0; color: var(--brand-silhouette); font-weight: 600; }
.gallery__main img[role="button"] { cursor: zoom-in; }

/* ─── Profile photo editor ───────────────────────────────────────────────── */
.avatar-edit { position: relative; width: 96px; height: 96px; margin: 2px 0 4px; }
.avatar-edit__img {
  display: block; width: 96px; height: 96px; border-radius: 50%; overflow: hidden;
  background: var(--brand-tint); border: 1px solid var(--sb-line);
}
.avatar-edit__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-edit__img--empty { display: flex; align-items: center; justify-content: center; color: var(--brand-body); }
.avatar-edit__img--empty svg { width: 46px; height: 46px; }
.avatar-edit__btn {
  position: absolute; right: -2px; bottom: -2px;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-secondary); color: #fff;
  border: 2px solid #fff; cursor: pointer; padding: 0;
  box-shadow: 0 4px 12px rgba(12, 30, 36, .2);
}
.avatar-edit__btn svg { width: 15px; height: 15px; }
.avatar-edit__btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }

/* ─── Image lightbox ─────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 20, 24, .92); touch-action: pan-y;
}
.lightbox[hidden] { display: none; }
.lightbox__img {
  max-width: 92vw; max-height: 86vh; object-fit: contain;
  border-radius: 8px; user-select: none; -webkit-user-drag: none;
}
.lightbox__close, .lightbox__nav {
  position: absolute; border: 0; cursor: pointer; color: #fff;
  background: rgba(255, 255, 255, .15);
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px; line-height: 1;
}
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255, 255, 255, .28); }
.lightbox__close { top: 16px; right: 16px; width: 42px; height: 42px; font-size: 26px; }
.lightbox__nav { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 30px; }
.lightbox__nav[hidden] { display: none; }
.lightbox__nav--prev { left: 12px; }
.lightbox__nav--next { right: 12px; }
.lightbox__count {
  position: absolute; left: 0; right: 0; bottom: 18px; text-align: center;
  color: rgba(255, 255, 255, .82); font-size: 13px; font-weight: 600;
}

/* ─── Searchable combobox (over a native <select>) ───────────────────────── */
.combo { position: relative; }
.combo__input, .combo__list { display: none; }
.combo.is-enhanced .combo__select { display: none; }
.combo.is-enhanced .combo__input { display: block; }
.combo__list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--sb-line); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(12, 30, 36, .14); max-height: 240px; overflow-y: auto;
}
.combo.is-enhanced .combo__list:not([hidden]) { display: block; }
.combo__opt { padding: 9px 11px; border-radius: 7px; font-size: 14px; color: var(--brand-silhouette); cursor: pointer; }
.combo__opt.is-active { background: var(--brand-tint); }

/* ─── Tag input (chips) ─────────────────────────────────────────────────── */
.taginput {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 7px 9px; border: 1.5px solid var(--sb-line); border-radius: 10px; background: #fff;
}
.taginput:focus-within { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(28, 160, 166, .15); }
.taginput__chips { display: contents; }
.field .taginput__new {
  flex: 1; min-width: 140px; width: auto;
  border: 0; outline: none; font: inherit; padding: 4px 2px; background: transparent;
}
.field .taginput__new:focus { box-shadow: none; }
.chip--tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--brand-tint); color: #14323B; border: 1px solid #bfe4e4;
  border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 13px; font-weight: 600;
}
.chip__x {
  border: 0; background: rgba(20, 50, 59, .12); color: #14323B;
  width: 18px; height: 18px; border-radius: 50%; line-height: 1; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.chip__x:hover { background: rgba(20, 50, 59, .24); }

/* ─── Inline "add address" on the listing form ──────────────────────────── */
.addr-inline {
  margin-top: 8px; padding: 12px; border: 1px dashed var(--sb-line); border-radius: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.addr-inline[hidden] { display: none; }
.field input.addr-inline__in {
  width: 100%; font: inherit; line-height: 1.3; color: var(--brand-silhouette);
  padding: 9px 12px; border: 1.5px solid var(--sb-line); border-radius: 9px; background: #fff;
}
.addr-inline__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ─── File uploader ("+" tile + previews) ───────────────────────────────── */
.uploader.is-enhanced .uploader__input { display: none; }
.uploader__grid { display: none; flex-wrap: wrap; gap: 10px; }
.uploader.is-enhanced .uploader__grid { display: flex; }
.uploader__tile {
  position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--sb-line); background: var(--brand-tint);
}
.uploader__tile img, .uploader__tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.uploader__tile-x {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(12, 30, 36, .66); color: #fff;
  font-size: 13px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.uploader__tile-x:hover { background: rgba(12, 30, 36, .85); }
.uploader__add {
  width: 92px; height: 92px; padding: 0; border-radius: 10px; cursor: pointer;
  border: 1.5px dashed var(--sb-line); background: var(--brand-tint); color: var(--brand-body);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font: inherit; font-size: 12px; font-weight: 600;
}
.uploader__add svg { width: 22px; height: 22px; }
.uploader__add:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.uploader__add[hidden] { display: none; }
.uploader__existing { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px; }
.uploader__existing img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 1px solid var(--sb-line); }

/* ─── Media thumbs on the listing form ───────────────────────────────────── */
.thumbstrip { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; }
.thumbstrip img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 1px solid var(--sb-line); }

/* ─── Stat tiles ─────────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 0 0 22px; }
.tile { border: 1px solid var(--sb-line); border-radius: 12px; padding: 14px 16px; }
.tile b { font-family: var(--font-display); font-size: 24px; color: var(--brand-silhouette); display: block; }
.tile span { font-size: 12.5px; color: var(--brand-body); }

/* ─── Simple footer ──────────────────────────────────────────────────────── */
.appfoot { border-top: 1px solid var(--sb-line); padding: 22px clamp(16px, 5vw, 40px); text-align: center; color: var(--brand-body); font-size: 13px; }
.appfoot a { color: var(--brand-body); text-decoration: underline; margin: 0 8px; }

/* ─── Install button (PWA) ──────────────────────────────────────────────── */
.js-install-btn[hidden] { display: none; }

/* ─── Bottom tab bar (mobile app chrome) ───────────────────────────────────
   In the DOM for every signed-in page; only shown at phone widths, where it
   replaces the top-bar nav. */
.botnav { display: none; }
.botnav__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px 7px;
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  color: var(--brand-body); text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.botnav__item svg { width: 23px; height: 23px; display: block; }
.botnav__item.is-active { color: var(--brand-primary); }
.botnav__item--primary { color: var(--brand-secondary); }
.botnav__item--primary svg { width: 27px; height: 27px; }

@media (max-width: 760px) {
  .detail { grid-template-columns: 1fr; }
  .appbar__link { padding: 8px 9px; }
  /* Phones navigate the lightbox by swiping. */
  .lightbox__nav { display: none; }

  .botnav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    background: #fff;
    border-top: 1px solid var(--sb-line);
    box-shadow: 0 -6px 20px rgba(12, 30, 36, .06);
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* Keep content clear of the fixed bar, and drop the redundant text footer. */
  body:has(.botnav) { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  body:has(.botnav) .appfoot { display: none; }
  /* On mobile the tabs carry navigation, so collapse the top bar to just the brand. */
  body:has(.botnav) .appbar__nav { display: none; }
}
