/* ============================================================
   Praça 21 — mercado nocturno
   fundo slate profundo · dourado-sat · price tags de feira
   ============================================================ */
:root {
  --bg: #131820;
  --surface: #1b222d;
  --surface-2: #222b38;
  --line: #2c3745;
  --text: #e9edf3;
  --muted: #8b98a9;
  --gold: #f2a93b;
  --gold-deep: #c9820f;
  --blue: #7fa6c9;
  --green: #5fbf7a;
  --red: #e06a5e;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
a { color: var(--gold); text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Topo ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1rem .6rem;
}
.brand {
  color: var(--text); font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em;
}
.brand em { font-style: normal; color: var(--gold); }
.brand-mark {
  display: inline-block; background: var(--gold); color: #17110a;
  width: 1.5em; height: 1.5em; line-height: 1.5em; text-align: center;
  border-radius: 6px; font-size: .85em; margin-right: .25rem;
  transform: rotate(-6deg);
}
.hello { color: var(--muted); font-size: .85rem; }

/* ---------- Navegação ---------- */
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.navtoggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.4rem; height: 2.4rem; font-size: 1.25rem; line-height: 1;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; cursor: pointer;
}
/* Mobile: menu escondido, aberto pelo hambúrguer (coluna) */
.mainnav {
  display: none; flex-direction: column; gap: .15rem;
  padding: .4rem .75rem .6rem; border-bottom: 1px solid var(--line); background: var(--bg);
}
.mainnav.open { display: flex; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  color: var(--muted); padding: .6rem .8rem; border-radius: 10px;
  font-size: .98rem; display: flex; align-items: center; gap: .5rem;
}
.mainnav a.on { background: var(--surface-2); color: var(--text); }

/* Desktop: menu horizontal fixo, sem hambúrguer */
@media (min-width: 640px) {
  .navtoggle { display: none; }
  .mainnav {
    display: flex; flex-direction: row; gap: .25rem; overflow-x: auto;
    padding: 0 .75rem .5rem; position: sticky; top: 0; z-index: 20;
  }
  .mainnav a { border-radius: 999px; padding: .5rem .8rem; white-space: nowrap; font-size: .95rem; }
}
.mainnav .ico { opacity: .8; }
.badge {
  background: var(--gold); color: #17110a; font-size: .72rem; font-weight: 700;
  border-radius: 999px; padding: 0 .45em; min-width: 1.5em; text-align: center;
}

/* ---------- Layout ---------- */
.wrap { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 1rem; }
.foot {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between;
  color: var(--muted); font-size: .78rem; padding: 1rem; border-top: 1px solid var(--line);
  max-width: 860px; margin: 0 auto; width: 100%;
}
.btc-ticker { color: var(--gold); }
.page-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: .8rem; }
.sub-title { font-size: 1.05rem; font-weight: 700; margin: 1.4rem 0 .6rem; color: var(--blue); }

.flash {
  background: color-mix(in srgb, var(--green) 15%, var(--surface));
  border: 1px solid var(--green); color: var(--text);
  padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .92rem;
}
.flash.err { background: color-mix(in srgb, var(--red) 15%, var(--surface)); border-color: var(--red); }

/* ---------- Cartões e formulários ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
}
.form label { display: block; margin-bottom: .9rem; font-size: .88rem; color: var(--muted); }
.form input, .form select, .form textarea, .filters input, .filters select,
.manage-row input, .manage-row select {
  width: 100%; margin-top: .3rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: .65rem .8rem; color: var(--text);
}
.form textarea { resize: vertical; }
.form input:focus, .form textarea:focus, .form select:focus,
.filters input:focus, .chat-form textarea:focus {
  outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent;
}
.hint { display: block; color: var(--muted); font-size: .8rem; margin: .2rem 0 .8rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: .6rem 1rem; cursor: pointer; font-weight: 600; font-size: .95rem;
}
.btn.primary { background: var(--gold); border-color: var(--gold-deep); color: #17110a; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.tiny { padding: .25rem .6rem; font-size: .8rem; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn:active { transform: translateY(1px); }

/* Segmentado aluguer/serviço */
.seg { display: flex; gap: .5rem; margin-bottom: 1rem; }
.seg-opt { flex: 1; }
.seg-opt input { position: absolute; opacity: 0; }
.seg-opt span {
  display: block; text-align: center; padding: .55rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-weight: 600;
}
.seg-opt input:checked + span { background: var(--gold); color: #17110a; border-color: var(--gold-deep); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--gold); }

.price-set { border: 1px dashed var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: 1rem; }
.price-set legend { padding: 0 .4rem; color: var(--muted); font-size: .85rem; }
.price-inputs { display: grid; grid-template-columns: 1fr auto 1.3fr; gap: .5rem; align-items: center; }
.price-inputs input, .price-inputs select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .6rem; color: var(--text); width: 100%;
}
/* Preço sempre em euros (mostra €); a unidade só aparece em aluguer/serviço */
.eur-tag { align-self: center; color: var(--gold); font-weight: 800; font-size: 1.25rem; }
.price-set.venda .price-inputs { grid-template-columns: 1fr auto; }
.price-set.venda .unit-wrap { display: none; }

/* Aviso do admin na página de anúncios */
.aviso {
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  border: 1px solid var(--gold-deep); border-left-width: 4px;
  border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem;
  color: var(--text); font-size: .92rem;
}

/* ---------- Filtros ---------- */
.filters { margin-bottom: 1rem; }
.filters input[type=search] { margin-bottom: .5rem; }
/* Mobile: filtros empilhados na vertical (texto legível) */
.filter-row { display: flex; flex-direction: column; gap: .5rem; }
.filter-row select { width: 100%; }
@media (min-width: 640px) {
  .filter-row { flex-direction: row; }
  .filter-row select { flex: 1; }
}

/* ---------- Grelha de anúncios ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; color: var(--text); display: flex; flex-direction: column;
  transition: border-color .15s;
}
.tile:hover { border-color: var(--gold); }
.tile-img { aspect-ratio: 4/3; background: var(--surface-2); position: relative; display: grid; place-items: center; }
.tile-img img { width: 100%; height: 100%; object-fit: cover; }
.noimg { font-size: 2.2rem; opacity: .5; }
.is-reservado .tile-img img { filter: grayscale(.7) brightness(.7); }
.ribbon {
  position: absolute; top: .5rem; left: -.4rem; background: var(--blue); color: #0e1520;
  font-size: .7rem; font-weight: 700; padding: .15rem .6rem; border-radius: 0 6px 6px 0;
}
.tile-body { padding: .6rem .7rem .7rem; display: flex; flex-direction: column; gap: .3rem; }
.tile-body h3 { font-size: .92rem; font-weight: 600; line-height: 1.3; }
.owner { color: var(--muted); font-size: .76rem; }

.chip {
  display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: .12rem .5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); width: fit-content;
}
.chip-aluguer { background: color-mix(in srgb, var(--blue) 22%, transparent); color: var(--blue); }
.chip-servico { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.chip-estado, .chip-reservado { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }
.chip-ativo { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.chip-concluido { background: var(--surface-2); color: var(--muted); }

/* Price tag — etiqueta de feira */
.price-tag {
  font-weight: 800; color: var(--gold); font-size: .98rem;
  display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap;
}
.price-tag.big { font-size: 1.5rem; margin: .3rem 0 .8rem; }
.btc-eq { color: var(--muted); font-weight: 500; font-size: .74em; }
.btc-eq:not(:empty)::before { content: "≈ "; }

/* ---------- Detalhe ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin-bottom: .9rem; }
.gallery img { width: 100%; height: 160px; border-radius: var(--radius); object-fit: cover; cursor: zoom-in; }
/* Se só houver uma foto, ocupa a largura toda e mais alta */
.gallery img:only-child { height: 300px; grid-column: 1 / -1; }

/* Lightbox — ver imagem em grande */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: none; align-items: center; justify-content: center; padding: 1rem; z-index: 50; cursor: zoom-out; }
.lightbox.on { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius); object-fit: contain; }

/* Admin — membros */
#memberSearch {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem;
}
#memberSearch:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.member-toggle { cursor: pointer; display: inline-block; user-select: none; }
.member-toggle:hover strong { color: var(--gold); }
.member-toggle .caret { color: var(--muted); font-size: .8em; }
tbody.member.inactive { opacity: .55; }
.member-detail td { color: var(--muted); background: var(--bg); font-size: .85rem; }
.member-detail strong { color: var(--text); }
.detail-head { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .5rem; }
.detail-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: .3rem; }
.descr { white-space: pre-line; color: #c6cedb; margin-bottom: 1rem; }

.owner-card { display: flex; flex-direction: column; gap: .8rem; }
.owner-info { display: flex; align-items: center; gap: .7rem; }
.owner-info small { display: block; color: var(--muted); font-size: .78rem; }
.owner-avatar {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--surface-2);
  color: var(--gold); font-weight: 800; display: grid; place-items: center; flex-shrink: 0;
  border: 1px solid var(--line);
}
.owner-avatar.xl { width: 3.4rem; height: 3.4rem; font-size: 1.3rem; }

.pay summary { cursor: pointer; font-weight: 700; color: var(--gold); padding: .3rem 0; }
.pay-body { display: flex; flex-direction: column; gap: 1rem; padding-top: .8rem; }
.pay-block { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; }
.pay-block small { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .7rem; }
.qr { background: #fff; padding: 10px; border-radius: 12px; }
.qr img, .qr canvas { width: 180px !important; height: 180px !important; }
.addr {
  font-size: .72rem; word-break: break-all; background: var(--bg);
  padding: .4rem .6rem; border-radius: 8px; border: 1px solid var(--line); max-width: 100%;
}

.pw-reset { border-color: var(--gold); }
.pw-reset strong { display: block; margin-bottom: .5rem; }
.pw-reset-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.pw-reset .addr { font-size: 1rem; letter-spacing: .04em; font-weight: 700; color: var(--gold); }

.video-wrap { position: relative; margin: 1rem 0; aspect-ratio: 16 / 9; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 12px; background: #000; }
.draft-note { border-color: var(--gold); display: flex; flex-direction: column; gap: .6rem; }
.draft-note strong { color: var(--gold); }
.chip-rascunho { background: transparent; border: 1px dashed var(--line); color: var(--muted); }

.manage strong { display: block; margin-bottom: .6rem; }
.manage-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.manage-row select { width: auto; flex: 1; min-width: 8rem; }

/* ---------- Mensagens ---------- */
.thread-list { display: flex; flex-direction: column; gap: .5rem; }
.thread {
  display: flex; align-items: center; gap: .7rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; color: var(--text);
}
.thread.unread { border-color: var(--gold); }
.thread-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-title { color: var(--blue); font-size: .78rem; }
.thread-last { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.chat-head .back { font-size: 1.6rem; line-height: 1; color: var(--muted); padding: .2rem .5rem; }
.chat-listing { display: block; font-size: .8rem; }
.chat { display: flex; flex-direction: column; gap: .5rem; padding-bottom: 1rem; min-height: 40vh; }
.msg { max-width: 82%; padding: .55rem .8rem; border-radius: 14px; font-size: .95rem; }
.msg p { white-space: pre-line; }
.msg time { display: block; font-size: .66rem; color: var(--muted); margin-top: .2rem; }
.msg.me { align-self: flex-end; background: color-mix(in srgb, var(--gold) 26%, var(--surface)); border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.empty-chat { color: var(--muted); font-size: .88rem; text-align: center; margin: auto; }
.chat-form {
  display: flex; gap: .5rem; position: sticky; bottom: 0; background: var(--bg);
  padding: .6rem 0 calc(.6rem + env(safe-area-inset-bottom));
}
.chat-form textarea {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: .6rem 1rem; resize: none; max-height: 6rem;
}
.chat-form .btn { border-radius: 50%; width: 2.9rem; height: 2.9rem; padding: 0; flex-shrink: 0; }

/* ---------- Perfil / admin ---------- */
.profile-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.profile-head .page-title { margin-bottom: 0; }
.mine { display: flex; flex-direction: column; gap: .5rem; }
.mine-row {
  display: flex; align-items: center; gap: .7rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .7rem; color: var(--text);
}
.mine-thumb { width: 3rem; height: 3rem; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; }
.mine-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mine-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mine-mid small { color: var(--gold); font-size: .8rem; }
.logout-row { margin-top: 1.5rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; text-align: center; }
.stat strong { display: block; font-size: 1.5rem; color: var(--gold); }
.stat small { color: var(--muted); font-size: .76rem; }
.tbl { width: 100%; border-collapse: collapse; margin-top: .6rem; }
.tbl td { padding: .5rem .3rem; border-top: 1px solid var(--line); vertical-align: middle; font-size: .9rem; }
.tbl tr.inactive { opacity: .45; }
.ta-r { text-align: right; }
.thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .9rem; }
.thumb { position: relative; }
.thumb img { width: 4.5rem; height: 4.5rem; object-fit: cover; border-radius: 10px; }
.thumb-x {
  position: absolute; top: -6px; right: -6px; width: 1.4rem; height: 1.4rem;
  border-radius: 50%; background: var(--red); color: #fff; border: none; cursor: pointer; line-height: 1;
}

/* ---------- Auth ---------- */
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; margin-bottom: 1.2rem; }
.auth-title .accent { color: var(--gold); }
.auth-alt { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 1rem; }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; display: flex; flex-direction: column; gap: 1rem; align-items: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .gallery img { height: 320px; }
}

/* ---------- Localização ---------- */
.chip-loc { background: color-mix(in srgb, var(--gold) 14%, transparent); color: var(--gold); text-transform: none; letter-spacing: 0; }
.loc-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 480px) { .loc-row { grid-template-columns: 1fr; } }

/* ---------- Seleção para colagem ---------- */
.thumb-sel { position: absolute; top: 4px; left: 4px; cursor: pointer; }
.thumb-sel input { position: absolute; opacity: 0; }
.thumb-sel span {
  display: grid; place-items: center; width: 1.4rem; height: 1.4rem;
  border-radius: 6px; background: rgba(19,24,32,.75); border: 1px solid var(--line);
  color: transparent; font-size: .8rem; font-weight: 800;
}
.thumb-sel input:checked + span { background: var(--gold); border-color: var(--gold-deep); color: #17110a; }
.thumb-sel input:focus-visible + span { outline: 2px solid var(--gold); }

/* ---------- Vendas e convites de membros ---------- */
.chip-venda { background: color-mix(in srgb, #b48ce0 22%, transparent); color: #b48ce0; }
.mini-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .5rem; }
.inv-row { display: inline-flex; gap: .3rem; align-items: center; margin-bottom: .3rem; }
.inv-row input { width: 3.6rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .25rem .4rem; color: var(--text); text-align: center; }
