/* ============================================================================
   Customer account — the vendor portal's design language, applied to the
   renter's side. Poppins, warm paper instead of cold SaaS grey, ink-first
   headings, crisp 1px borders rather than diffuse shadows, uppercase
   micro-labels, tabular numerals on anything that is a number, and status
   shown as a dot + word so it never depends on colour alone.

   Scoped entirely under .ca so nothing here can reach the rest of the site.
   ========================================================================== */

.ca {
  --ca-font: 'Poppins', 'Inter', system-ui, -apple-system, sans-serif;
  --ca-bg: #f7f5f0;
  --ca-surface: #ffffff;
  --ca-ink: #17191c;
  --ca-soft: #40444b;
  --ca-muted: #767a82;
  --ca-faint: #a4a8b0;
  --ca-line: #e6e2d8;
  --ca-line2: #d7d2c3;
  --ca-brand: #16a34a;
  --ca-brand-ink: #0d6b34;
  --ca-amber: #c2660f;
  --ca-red: #c0341f;
  --ca-blue: #2251c9;

  font-family: var(--ca-font);
  color: var(--ca-ink);
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.ca-side {
  position: sticky;
  top: 88px;
  background: var(--ca-surface);
  border: 1px solid var(--ca-line);
  border-radius: 13px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ca-me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ca-avatar {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px;
  background: var(--ca-ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
}
.ca-me-txt { min-width: 0; display: flex; flex-direction: column; }
.ca-me-txt strong { font-size: .92rem; font-weight: 600; line-height: 1.2; }
.ca-me-txt span {
  font-size: .74rem; color: var(--ca-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ca-nav { display: flex; flex-direction: column; gap: 2px; }
.ca-nav-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: .84rem; font-weight: 500; color: var(--ca-soft);
  padding: 8px 10px; border-radius: 9px; text-align: left;
  transition: background .12s, color .12s;
}
.ca-nav-btn:hover { background: var(--ca-bg); color: var(--ca-ink); }
.ca-nav-btn.on { background: var(--ca-ink); color: #fff; font-weight: 600; }
.ca-nav-btn svg { flex: 0 0 auto; }
.ca-count {
  margin-left: auto; font-style: normal; font-size: .7rem; font-weight: 700;
  font-variant-numeric: tabular-nums; background: var(--ca-bg);
  color: var(--ca-muted); border-radius: 20px; padding: 1px 7px;
}
.ca-nav-btn.on .ca-count { background: rgba(255, 255, 255, .2); color: #fff; }

.ca-signout {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--ca-line); background: var(--ca-surface); cursor: pointer;
  font-family: inherit; font-size: .8rem; font-weight: 600; color: var(--ca-muted);
  padding: 8px; border-radius: 9px; transition: border-color .12s, color .12s;
}
.ca-signout:hover { border-color: var(--ca-ink); color: var(--ca-ink); }

/* ── Content ─────────────────────────────────────────────────────────────── */
.ca-main { min-width: 0; }
.ca-head { margin: 0 0 14px; }
.ca-head h2 {
  font-family: var(--ca-font); font-size: 1.25rem; font-weight: 700;
  color: var(--ca-ink); margin: 0 0 3px; letter-spacing: -.01em;
}
.ca-head p { font-size: .85rem; color: var(--ca-muted); margin: 0; }

.ca-lbl {
  display: block; font-size: .66rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ca-muted); margin: 0 0 8px;
}

/* Stat tiles — same shape as the portal's. */
.ca-stats {
  display: grid; gap: 10px; margin: 0 0 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
}
.ca-stat {
  background: var(--ca-surface); border: 1px solid var(--ca-line);
  border-radius: 12px; padding: 13px 15px;
}
.ca-stat-val {
  font-size: 1.35rem; font-weight: 700; line-height: 1.15;
  font-variant-numeric: tabular-nums; color: var(--ca-ink);
}
.ca-stat-label {
  font-size: .7rem; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ca-muted); margin-top: 3px;
}

/* ── Rows ────────────────────────────────────────────────────────────────── */
.ca-list { display: flex; flex-direction: column; gap: 8px; }
.ca-row {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: var(--ca-surface); border: 1px solid var(--ca-line);
  border-radius: 12px; padding: 11px 13px;
  font-family: inherit; color: inherit;
  transition: border-color .12s, transform .12s;
}
button.ca-row { cursor: pointer; }
.ca-row:hover { border-color: var(--ca-line2); transform: translateY(-1px); }
.ca-row-img {
  flex: 0 0 auto; width: 76px; height: 54px; object-fit: cover;
  border-radius: 9px; background: var(--ca-bg);
}
.ca-row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ca-row-title { font-size: .9rem; font-weight: 600; color: var(--ca-ink); margin: 0; line-height: 1.3; }
.ca-row-title a { color: inherit; text-decoration: none; }
.ca-row-title a:hover { text-decoration: underline; }
.ca-row-meta { font-size: .76rem; color: var(--ca-muted); line-height: 1.45; }
.ca-row-acts { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.ca-btn {
  border: 1.5px solid var(--ca-ink); background: var(--ca-surface); cursor: pointer;
  font-family: inherit; font-size: .76rem; font-weight: 600; color: var(--ca-ink);
  padding: 6px 11px; border-radius: 8px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px;
  transition: border-color .12s, color .12s, background .12s;
}
.ca-btn:hover { background: var(--ca-ink); color: #fff; text-decoration: none; }
.ca-btn.dark { background: var(--ca-brand); border-color: var(--ca-brand); color: #fff; }
.ca-btn.dark:hover { background: var(--ca-brand-ink); border-color: var(--ca-brand-ink); color: #fff; }
.ca-btn.on { border-color: var(--ca-brand); color: var(--ca-brand-ink); background: #f4f8f5; }

/* Status: a dot AND a word, never colour on its own. */
.ca-badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: .72rem; font-weight: 600; color: var(--ca-soft);
}
.ca-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ca-faint); }
.ca-badge.ok::before { background: var(--ca-brand); }
.ca-badge.wait::before { background: var(--ca-amber); }
.ca-badge.bad::before { background: var(--ca-red); }
.ca-badge.info::before { background: var(--ca-blue); }

/* ── Search ──────────────────────────────────────────────────────────────── */
.ca-search {
  display: flex; align-items: center; gap: 8px; margin: 0 0 12px;
  background: var(--ca-surface); border: 1px solid var(--ca-line);
  border-radius: 10px; padding: 8px 12px;
}
.ca-search svg { flex: 0 0 auto; color: var(--ca-faint); }
.ca-search input {
  flex: 1 1 auto; min-width: 0; border: none; outline: none; background: none;
  font-family: inherit; font-size: .86rem; color: var(--ca-ink);
}
.ca-search input::placeholder { color: var(--ca-faint); }
.ca-search-x {
  border: none; background: none; cursor: pointer; color: var(--ca-muted);
  font-size: 1.1rem; line-height: 1; padding: 0 3px;
}
.ca-search-n { font-size: .72rem; color: var(--ca-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── Taste profile ───────────────────────────────────────────────────────── */
.ca-profile {
  background: var(--ca-surface); border: 1px solid var(--ca-line);
  border-radius: 12px; padding: 14px 15px; margin: 0 0 14px;
}
.ca-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ca-chip {
  font-size: .74rem; font-weight: 600; border-radius: 20px; padding: 3px 10px;
  border: 1px solid var(--ca-line); background: var(--ca-bg); color: var(--ca-soft);
}
.ca-chip.brand { border-color: #bcd8c6; background: #f4f8f5; color: var(--ca-brand-ink); }
.ca-chip.money { font-variant-numeric: tabular-nums; }
.ca-note { font-size: .74rem; color: var(--ca-faint); margin: 9px 0 0; }

/* How a for-sale ad is doing. The .ca-note inside a figure must sit on the
   same line as the number, so the margin the standalone note carries is
   cleared here rather than by adding a second note class. */
.ca-perf {
  background: var(--ca-bg); border: 1px solid var(--ca-line2);
  border-radius: 10px; padding: 9px 12px; font-size: .8rem;
}
.ca-perf strong { font-size: .95rem; }
.ca-perf .ca-note { margin: 0; }
.ca-why { font-size: .74rem; color: var(--ca-brand-ink); font-weight: 600; }

/* ── Empty / loading ─────────────────────────────────────────────────────── */
.ca-empty {
  background: var(--ca-surface); border: 1px dashed var(--ca-line2);
  border-radius: 12px; padding: 26px 20px; text-align: center;
  font-size: .87rem; color: var(--ca-muted); line-height: 1.6;
}
.ca-empty strong { display: block; color: var(--ca-ink); font-size: .96rem; margin-bottom: 4px; }
.ca-empty a { color: var(--ca-brand-ink); font-weight: 600; }
.ca-loading { font-size: .85rem; color: var(--ca-muted); }

/* ── Forms (profile + password + sign-in) ────────────────────────────────── */
.ca-card {
  background: var(--ca-surface); border: 1px solid var(--ca-line);
  border-radius: 13px; padding: 18px; margin-bottom: 14px;
}
.ca-card h3 { font-size: 1rem; font-weight: 700; margin: 0 0 3px; color: var(--ca-ink); }
.ca-card > p { font-size: .82rem; color: var(--ca-muted); margin: 0 0 14px; }
.ca-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.ca-f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ca-f.full { grid-column: 1 / -1; }
.ca-f > span {
  font-size: .72rem; font-weight: 600; letter-spacing: .03em; color: var(--ca-muted);
}
.ca-f input {
  font-family: inherit; font-size: .88rem; color: var(--ca-ink);
  border: 1px solid var(--ca-line); border-radius: 9px; padding: 9px 11px;
  background: var(--ca-surface); width: 100%; box-sizing: border-box;
}
.ca-f input:focus { border-color: var(--ca-ink); outline: none; }
/* Actions live bottom-right of the card, primary button rightmost/last in
   markup — any hint text sits to its left, inside the same right-packed
   cluster (see the JSX: notes come before the button(s) they explain). */
.ca-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }

.ca-alert {
  border-radius: 10px; padding: 10px 13px; font-size: .84rem;
  margin-bottom: 12px; border: 1px solid;
}
.ca-alert.ok { background: #f4f8f5; border-color: #bcd8c6; color: var(--ca-brand-ink); }
.ca-alert.err { background: #fdf3f1; border-color: #f0c8c0; color: var(--ca-red); }

/* Sign-in card, centred on its own. */
.ca-auth { max-width: 420px; margin: 0 auto; }
.ca-seg {
  display: inline-flex; border: 1px solid var(--ca-line); border-radius: 10px;
  overflow: hidden; margin-bottom: 14px;
}
.ca-seg button {
  border: none; background: var(--ca-surface); cursor: pointer; font-family: inherit;
  font-size: .84rem; font-weight: 600; padding: 8px 18px; color: var(--ca-muted);
}
.ca-seg button.on { background: var(--ca-ink); color: #fff; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.ca-toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--ca-ink); color: #fff; font-family: var(--ca-font);
  font-size: .84rem; font-weight: 500; padding: 10px 18px; border-radius: 22px;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .45); z-index: 600;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .ca { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .ca-side { position: static; }
  /* The nav becomes a horizontal strip that scrolls in its own container. */
  .ca-nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .ca-nav-btn { flex: 0 0 auto; }
  .ca-row { flex-wrap: wrap; }
  .ca-row-acts { width: 100%; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .ca-row, .ca-btn, .ca-nav-btn, .ca-signout { transition: none; }
  .ca-row:hover { transform: none; }
}

/* ── Buyer conversations on a for-sale ad (SellerChats.tsx) ────────────────
   Reuses .ca-card / .ca-btn / .ca-alert; only the thread itself needs rules. */
.sc2-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sc2-list { display: grid; gap: 6px; max-height: 240px; overflow-y: auto; }
.sc2-row {
  font: inherit; text-align: left; cursor: pointer; display: grid; gap: 2px;
  padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff;
}
.sc2-row:hover { border-color: #cbd5e1; }
.sc2-row.on { border-color: #16a34a; background: rgba(22, 163, 74, .04); }
.sc2-row-top { display: flex; align-items: center; gap: 7px; font-size: .88rem; }
.sc2-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; flex: 0 0 auto; }
.sc2-row-car { font-size: .78rem; color: #6b7280; }
.sc2-row-last {
  font-size: .78rem; color: #374151;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sc2-row-when { font-size: .7rem; color: #9ca3af; }

.sc2-thread-wrap { margin-top: 14px; border-top: 1px solid #f3f4f6; padding-top: 14px; }
.sc2-buyer { font-size: .82rem; color: #6b7280; margin: 0 0 10px; }
.sc2-thread { max-height: 280px; overflow-y: auto; display: grid; gap: 8px; margin-bottom: 10px; }
.sc2-msg { max-width: 86%; padding: 9px 12px; border-radius: 12px; }
.sc2-msg p { margin: 0; font-size: .86rem; line-height: 1.45; white-space: pre-line; }
.sc2-msg time { display: block; margin-top: 4px; font-size: .68rem; opacity: .65; }
/* Seller's own messages right and green, buyer's left and grey — the layout
   every messaging app uses, so it needs no explaining. */
.sc2-msg.me { margin-left: auto; background: rgba(22, 163, 74, .1); }
.sc2-msg.them { margin-right: auto; background: #f3f4f6; }
.sc2-reply { display: grid; gap: 8px; }
.sc2-reply textarea {
  font: inherit; width: 100%; box-sizing: border-box; padding: 10px 12px;
  border: 1px solid #e5e7eb; border-radius: 9px; resize: vertical;
}
.sc2-reply textarea:focus { outline: none; border-color: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .12); }
