/* public/css/tenants-chat.css
 *
 * Self-contained styles for the Tenants Together letter assistant standalone
 * page (public/tenants-together.html). No shared classes with "Matt's AI".
 * Mobile-first; light + dark via prefers-color-scheme.
 */

:root {
  --tt-blue: #1c5aa6;
  --tt-blue-dark: #16487f;
  --tt-gold: #c68a1e;
  --tt-bg: #f4f6f9;
  --tt-surface: #ffffff;
  --tt-surface-2: #eef2f7;
  --tt-border: #d3dbe6;
  --tt-text: #1a2330;
  --tt-text-soft: #55606f;
  --tt-ai-bubble: #eef3fa;
  --tt-user-bubble: var(--tt-blue);
  --tt-user-text: #ffffff;
  --tt-ok: #1f7a44;
  --tt-warn: #9a5b00;
  --tt-radius: 12px;
  --tt-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tt-blue: #4f8fd6;
    --tt-blue-dark: #3b78bd;
    --tt-gold: #e0a63f;
    --tt-bg: #12161c;
    --tt-surface: #1b2129;
    --tt-surface-2: #232b35;
    --tt-border: #333d49;
    --tt-text: #e7ecf2;
    --tt-text-soft: #9aa7b5;
    --tt-ai-bubble: #232c38;
    --tt-user-bubble: #3b78bd;
    --tt-user-text: #ffffff;
    --tt-ok: #56c07f;
    --tt-warn: #e0a63f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--tt-bg);
  color: var(--tt-text);
  font-family: var(--tt-font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#ttRoot {
  max-width: 1040px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}
@media (min-width: 860px) {
  /* Lock the whole app to the viewport on desktop: the chat panel scrolls
     internally, nothing else does, so there's no dead page-level scrollbar
     and no leftover whitespace under a short conversation. */
  #ttRoot { height: 100dvh; min-height: 0; overflow: hidden; }
}

/* ---- header ---- */
#ttHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
}
.tt-brand { display: flex; align-items: center; gap: 12px; }
.tt-brand img { border-radius: 8px; flex: none; }
.tt-brand strong { display: block; font-size: 17px; letter-spacing: -0.01em; }
.tt-brand span { display: block; font-size: 12.5px; color: var(--tt-text-soft); }
.tt-header-actions { display: flex; gap: 8px; flex: none; }
.tt-restart {
  border: 1px solid var(--tt-border);
  background: var(--tt-surface);
  color: var(--tt-text-soft);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.tt-restart:hover { color: var(--tt-text); border-color: var(--tt-text-soft); }
.tt-restart.tt-clear { color: var(--tt-warn); border-color: var(--tt-warn); }

/* ---- disclaimer ---- */
.tt-disclaimer {
  margin: 0;
  padding: 10px 14px;
  background: var(--tt-surface-2);
  border: 1px solid var(--tt-border);
  border-left: 4px solid var(--tt-gold);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--tt-text-soft);
  flex: none;
}
.tt-disclaimer a { color: var(--tt-blue); }

/* ---- privacy note ---- */
.tt-privacy-note {
  margin: 0;
  padding: 10px 14px;
  background: var(--tt-surface-2);
  border: 1px solid var(--tt-border);
  border-left: 4px solid var(--tt-ok);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--tt-text-soft);
  flex: none;
}
.tt-privacy-note a { color: var(--tt-blue); }

/* ---- cleared state ---- */
.tt-cleared {
  padding: 16px;
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  text-align: center;
  flex: none;
}
.tt-cleared p { margin: 0 0 12px; font-size: 14px; color: var(--tt-text); }
.tt-cleared button {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--tt-blue);
  color: #fff;
}

/* ---- layout ---- */
#ttMain {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  min-height: 0;
}
@media (min-width: 860px) {
  #ttMain {
    grid-template-columns: 1fr 340px;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }
}
#ttMain[hidden] { display: none; }

/* ---- chat ---- */
#ttChat {
  display: flex;
  flex-direction: column;
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  overflow: hidden;
  min-height: 420px;
}
@media (min-width: 860px) {
  /* Fill whatever height #ttMain actually has (the viewport minus the real
     header/disclaimer/notes above it) instead of guessing a fixed offset. */
  #ttChat { height: 100%; min-height: 0; }
}

#ttMessages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
}

.tt-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.tt-msg.ai {
  align-self: flex-start;
  background: var(--tt-ai-bubble);
  border-bottom-left-radius: 4px;
}
.tt-msg.user {
  align-self: flex-end;
  background: var(--tt-user-bubble);
  color: var(--tt-user-text);
  border-bottom-right-radius: 4px;
}
.tt-msg a { color: inherit; text-decoration: underline; }
.tt-msg.typing { color: var(--tt-text-soft); font-style: italic; }

.tt-openers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}
.tt-openers button {
  border: 1px solid var(--tt-border);
  background: var(--tt-surface);
  color: var(--tt-blue);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
}
.tt-openers button:hover { background: var(--tt-surface-2); }

#ttForm {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--tt-border);
  background: var(--tt-surface);
}
#ttInput {
  flex: 1;
  border: 1px solid var(--tt-border);
  border-radius: 999px;
  padding: 10px 15px;
  font: inherit;
  background: var(--tt-bg);
  color: var(--tt-text);
}
#ttInput:focus { outline: 2px solid var(--tt-blue); outline-offset: 1px; }
#ttForm button {
  border: none;
  background: var(--tt-blue);
  color: #fff;
  border-radius: 999px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#ttForm button:disabled { opacity: 0.55; cursor: default; }

/* ---- letter panel ---- */
.tt-letter {
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  padding: 16px;
}
@media (min-width: 860px) {
  /* If the checklist is long, scroll inside the sidebar instead of
     stretching the row past the locked viewport height. */
  .tt-letter { min-height: 0; overflow-y: auto; }
}
#ttLetterTitle { margin: 0 0 4px; font-size: 16px; }
.tt-letter-meta { margin: 0 0 12px; font-size: 12.5px; color: var(--tt-text-soft); }

.tt-checklist { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tt-checklist li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--tt-text-soft);
}
.tt-checklist li::before {
  content: "○";
  color: var(--tt-border);
  font-size: 14px;
  line-height: 1.4;
  flex: none;
}
.tt-checklist li.filled { color: var(--tt-text); }
.tt-checklist li.filled::before { content: "●"; color: var(--tt-ok); }
.tt-checklist li .tt-val { display: block; font-size: 12px; color: var(--tt-text-soft); }

.tt-letter-status { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--tt-warn); }
.tt-letter-status.ready { color: var(--tt-ok); }

.tt-letter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tt-letter-actions button {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--tt-blue);
  color: #fff;
}
.tt-letter-actions button.tt-secondary {
  background: transparent;
  color: var(--tt-blue);
  border: 1px solid var(--tt-border);
}
.tt-letter-actions button:disabled { opacity: 0.5; cursor: default; }

.tt-preview {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  background: var(--tt-bg);
  border: 1px solid var(--tt-border);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0 0;
  max-height: 320px;
  overflow: auto;
}
#ttPreviewWrap summary { cursor: pointer; font-size: 13px; margin-top: 12px; color: var(--tt-blue); }

.tt-email-form { margin-top: 14px; }
.tt-email-form > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.tt-email-row { display: flex; gap: 8px; }
.tt-email-row input {
  flex: 1;
  border: 1px solid var(--tt-border);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  background: var(--tt-bg);
  color: var(--tt-text);
}
.tt-email-row button {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--tt-blue);
  color: #fff;
}
.tt-email-note { display: block; font-size: 12px; color: var(--tt-text-soft); margin-top: 6px; }
.tt-email-note.err { color: #c0392b; }
.tt-email-note.ok { color: var(--tt-ok); }

.tt-delivery-note { font-size: 12px; color: var(--tt-text-soft); margin: 14px 0 0; }
.tt-source-link { font-size: 12px; margin: 8px 0 0; }
.tt-source-link a { color: var(--tt-blue); }

/* ---- footer ---- */
#ttFooter {
  font-size: 12px;
  color: var(--tt-text-soft);
  text-align: center;
  padding: 4px 0 8px;
}
#ttFooter a { color: var(--tt-blue); }

.tt-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
