/* Wheelers Websites — customer portal (login, set-password, dashboard, request).
   Shares the marketing token block verbatim: minimal, matte, metallic.
   Portal controls are crisp (10px radius) rather than pill-shaped — the app
   surface reads as precise, the marketing surface as expressive.
   Every class name here is referenced by the portal JS/HTML; none renamed. */

:root {
  color-scheme: light;

  --bg: #e7e9ec;
  --bg-top: #f1f2f4;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --surface-3: #edeff2;

  --ink: #191c21;
  --ink-2: #3b4149;
  --muted: #6d727a;

  --line: rgba(22, 26, 31, 0.10);
  --line-2: rgba(22, 26, 31, 0.16);
  --sheen: rgba(255, 255, 255, 0.85);

  --metal: #3a424d;
  --metal-hi: #4d5762;
  --metal-lo: #2a313a;
  --metal-ink: #f4f6f8;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 28, 0.05);
  --shadow: 0 12px 34px rgba(20, 23, 28, 0.07);

  --ok: #4f7a5e;
  --warn: #a8763a;
  --err: #a5453d;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body.portal-body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(120% 55% at 50% -10%, rgba(255, 255, 255, 0.9), transparent 60%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin-top: 0; }

/* ---- Shell ------------------------------------------------------------- */

.portal-shell {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.portal-shell.narrow { width: min(440px, calc(100% - 28px)); padding-top: 88px; }
.portal-shell.request-shell { width: min(1200px, calc(100% - 32px)); }

.portal-hero { display: grid; gap: 14px; margin-bottom: 28px; }

.portal-eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.portal-hero h1 {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.portal-copy, .portal-small { color: var(--muted); line-height: 1.65; }
.portal-small { font-size: 0.85rem; }

/* ---- Buttons ----------------------------------------------------------- */

.portal-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.portal-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
  box-shadow: inset 0 1px 0 var(--sheen), var(--shadow-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.portal-button:hover { transform: translateY(-1px); }

.portal-button.primary {
  color: var(--metal-ink);
  border-color: var(--metal-lo);
  background: linear-gradient(180deg, var(--metal-hi) 0%, var(--metal) 55%, var(--metal-lo) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), var(--shadow-sm);
}

.portal-button.primary:hover {
  background: linear-gradient(180deg, #56606b 0%, #3f4853 55%, var(--metal-lo) 100%);
}

.portal-button:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

.portal-link-button {
  width: fit-content;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-2);
}

.portal-link-button:hover { color: var(--ink); }
.portal-link-button.danger { color: var(--err); }

/* ---- Cards & fields ---------------------------------------------------- */

.portal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.portal-card {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
  box-shadow: inset 0 1px 0 var(--sheen), var(--shadow);
}

.portal-card h1 {
  margin: 6px 0 10px;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.portal-card h2 {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

/* Wordmark above the auth cards */
.auth-brand {
  display: block;
  margin: 0 0 18px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #565f6a, #2c333c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.portal-field {
  display: grid;
  gap: 7px;
  margin: 14px 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-2);
}

.portal-field input,
.portal-field select,
.portal-field textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(20, 23, 28, 0.04);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.portal-field input:focus,
.portal-field select:focus,
.portal-field textarea:focus {
  outline: none;
  border-color: var(--metal);
  box-shadow: 0 0 0 3px rgba(58, 66, 77, 0.14);
}

.portal-field textarea { min-height: 150px; resize: vertical; }

/* ---- Lists (sites, requests) ------------------------------------------- */

.portal-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }

.portal-list li {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  line-height: 1.55;
}

.portal-list li strong { font-weight: 650; letter-spacing: -0.005em; }
.portal-list a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.portal-list a:hover { color: var(--ink); }
.portal-list .portal-small { margin-top: 6px; }

/* ---- Status ------------------------------------------------------------ */

.portal-status { min-height: 1.2rem; font-size: 0.88rem; font-weight: 600; }

.portal-status.success,
.portal-status.error {
  margin-top: 16px;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.portal-status.success { color: var(--ok); border-color: rgba(79, 122, 94, 0.4); }
.portal-status.error { color: var(--err); border-color: rgba(165, 69, 61, 0.4); }

/* ---- Dashboard --------------------------------------------------------- */

.dash-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.dash-brand {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #565f6a, #2c333c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.dash-top-actions { display: flex; gap: 10px; }

.dash-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

#profile p { margin: 0; }
#profile strong {
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
#profile .portal-small { margin-top: 4px; }

.dash-stats { display: flex; gap: 14px; flex-wrap: wrap; }

.stat {
  min-width: 132px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  box-shadow: inset 0 1px 0 var(--sheen);
}

.stat-label {
  margin: 0 0 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat p { margin: 0; }
.stat strong { font-size: 1.05rem; font-weight: 650; }

.dash-section { margin-top: 18px; }

/* Dashboard site list — one clean card per site, links to its own page. */
.site-cards { display: grid; gap: 10px; }

.site-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff, var(--surface-2));
  box-shadow: inset 0 1px 0 var(--sheen), var(--shadow-sm);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.site-card:hover { transform: translateY(-1px); border-color: var(--line-2); }
.site-card-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.site-card-name { font-weight: 650; letter-spacing: -0.01em; }

.site-card-role {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-card-chevron { color: var(--muted); font-size: 1.5rem; line-height: 1; }

/* Per-site page */
.site-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.site-hero h1 { margin: 6px 0 0; font-size: clamp(1.6rem, 3.5vw, 2.4rem); letter-spacing: -0.025em; }
.site-links { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.site-links a { color: var(--ink-2); font-size: 0.9rem; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.site-links a:hover { color: var(--ink); }

.site-danger h2 { color: var(--err); }
.danger-button { border-color: rgba(165, 69, 61, 0.4); color: var(--err); }
.danger-button:hover { background: #fff0ef; }

/* ---- Request console --------------------------------------------------- */

.request-console {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
  min-height: 78vh;
}

.request-sidebar {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 22px 20px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
}

.request-sidebar h2 { margin: 0; font-size: 1.02rem; }

/* Site switcher — the clear "which website am I working in" control. */
.site-switcher {
  padding: 13px 14px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: inset 0 1px 0 var(--sheen), var(--shadow-sm);
}

.site-switcher-label {
  display: block;
  margin: 0 0 7px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-switcher select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 11px 34px 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background-color: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5 6 6.5 11 1.5' stroke='%236d727a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 13px center;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.site-switcher select:focus {
  outline: none;
  border-color: var(--metal);
  box-shadow: 0 0 0 3px rgba(58, 66, 77, 0.14);
}

/* When locked to the current conversation's site, still read clearly. */
.site-switcher select:disabled {
  opacity: 1;
  cursor: default;
  color: var(--ink);
  background-color: var(--surface-2);
}

.conversation-list { display: grid; gap: 8px; }

.conversation-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.conversation-item:hover { border-color: var(--line-2); }
.conversation-item strong { font-weight: 600; letter-spacing: -0.005em; }
.conversation-item span { display: flex; align-items: center; font-size: 0.78rem; color: var(--muted); }

.conversation-item.active {
  border-color: var(--metal);
  background: #fff;
  box-shadow: 0 0 0 1px var(--metal);
}

.request-main {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto auto;
  gap: 14px;
  min-width: 0;
  padding: 24px;
}

.request-header h1 { margin: 0 0 6px; font-size: clamp(1.35rem, 2.2vw, 1.9rem); letter-spacing: -0.02em; }

/* ---- Chat -------------------------------------------------------------- */

.portal-chat {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
  max-height: 340px;
  overflow: auto;
}

.portal-chat.console { max-height: none; }

.portal-chat-message {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.94rem;
  line-height: 1.5;
  max-width: 82%;
}

.portal-chat-message > p { margin: 0; white-space: pre-wrap; }
.portal-chat-message + .portal-chat-message { margin-top: 12px; }

.portal-chat-message.user {
  margin-left: auto;
  color: var(--metal-ink);
  border: 1px solid var(--metal-lo);
  background: linear-gradient(180deg, var(--metal-hi), var(--metal));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.portal-chat-message.assistant {
  margin-right: auto;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, var(--surface-2));
  box-shadow: inset 0 1px 0 var(--sheen), var(--shadow-sm);
}

.portal-chat-reasoning {
  margin: 10px 0 0;
  padding: 9px 12px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.83rem;
}

.portal-chat-reasoning summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.portal-chat-reasoning p { margin: 8px 0 0; white-space: pre-wrap; }

.request-compose { display: grid; gap: 10px; }

.request-compose textarea {
  width: 100%;
  min-height: 96px;
  padding: 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(20, 23, 28, 0.04);
  color: inherit;
  font: inherit;
  resize: vertical;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.request-compose textarea:focus {
  outline: none;
  border-color: var(--metal);
  box-shadow: 0 0 0 3px rgba(58, 66, 77, 0.14);
}

/* ---- Receipts ---------------------------------------------------------- */

.chat-receipts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.chat-receipts-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chat-receipts-label::before { content: "\21A9"; margin-right: 4px; }

.chat-receipt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 0.77rem;
}

.chat-receipt-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 30ch;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.chat-receipt.linked .chat-receipt-text { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.chat-receipt.linked:hover { border-color: var(--metal); }
.chat-receipt.forgotten { opacity: 0.5; text-decoration: line-through; }

.chat-receipt-forget { padding: 0 2px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font: inherit; line-height: 1; }
.chat-receipt-forget:hover { color: var(--err); }
.chat-receipt-forget:disabled { cursor: wait; opacity: 0.5; }

/* ---- Threads ----------------------------------------------------------- */

.thread-group {
  margin: 4px 0 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.thread-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.thread-status-dot.designing { background: #6b7f96; }
.thread-status-dot.submitted { background: #5f8069; }
.thread-status-dot.revising { background: #b07d3c; }
.thread-status-dot.delivered { background: #9aa0a8; }

.thread-delivered { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.thread-delivered summary { cursor: pointer; color: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; }

.thread-search {
  width: 100%;
  margin: 10px 0;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
}

.thread-search:focus { outline: none; border-color: var(--metal); box-shadow: 0 0 0 3px rgba(58, 66, 77, 0.14); }

/* ---- Revision ---------------------------------------------------------- */

.request-actions { margin-top: 12px; }
.revise-panel { display: grid; gap: 8px; margin-top: 12px; }

.revise-note {
  width: 100%;
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  color: inherit;
  font: inherit;
  resize: vertical;
}

.revise-note:focus { outline: none; border-color: var(--metal); box-shadow: 0 0 0 3px rgba(58, 66, 77, 0.14); }

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 980px) {
  .request-console { grid-template-columns: 1fr; min-height: unset; }
  .request-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .portal-shell { width: min(100% - 24px, 1080px); padding-top: 28px; }
  .portal-grid { grid-template-columns: 1fr; }
  .dash-identity { flex-direction: column; align-items: flex-start; }
  .portal-chat-message { max-width: 92%; }
}

/* ---- Mobile chat: clean, texting-app feel ------------------------------ */
/* On phones the build + edit chats drop the "card in a card" chrome and read
   like an iMessage thread: full-bleed bubbles, tight spacing, a compact
   pill composer that stays in view, and no distracting side copy. */
@media (max-width: 760px) {
  .portal-shell.request-shell { width: 100%; padding: 14px 0 0; }
  .request-shell .dash-top { padding: 0 14px 10px; }

  .request-console { display: block; border-radius: 0; border-left: 0; border-right: 0; min-height: unset; }

  /* Website switcher becomes a slim strip so the conversation owns the screen. */
  .request-sidebar { padding: 12px 14px; gap: 8px; max-height: 146px; overflow: auto; }
  .request-sidebar .portal-link-button { display: none; }

  .request-main { padding: 0; gap: 0; grid-template-rows: auto 1fr auto auto; }
  .request-header { padding: 12px 16px 4px; }
  .request-header .portal-copy { display: none; }
  .request-header h1 { font-size: 1.14rem; }

  /* Seamless, scrollable message thread. */
  .portal-chat.console {
    border: 0;
    background: transparent;
    padding: 8px 12px 4px;
    max-height: 58vh;
    min-height: 40vh;
  }

  .portal-chat-message {
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.4;
  }
  .portal-chat-message + .portal-chat-message { margin-top: 6px; }
  .portal-chat-message.user { border-bottom-right-radius: 6px; }
  .portal-chat-message.assistant { border-bottom-left-radius: 6px; }

  /* Compact pill composer, like a texting app. Works for both the build chat
     and the edit chat (which have different button sets), so the send/CTA
     controls sit in a full-width row of pills under a rounded input. */
  .request-compose {
    gap: 8px;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: var(--surface-2);
  }
  .request-compose textarea {
    min-height: 44px;
    max-height: 38vh;
    padding: 11px 15px;
    border-radius: 20px;
    resize: none;
  }
  .request-compose .portal-actions { gap: 8px; }
  .request-compose .portal-button { flex: 1 1 auto; height: 42px; border-radius: 21px; }
}
