/* TradeLaunch Digital — Operator Chat
   Mobile-first, brand-consistent, no external assets. */

:root {
  --tl-ink: #0d1b2a;
  --tl-ink-soft: #3d4f63;
  --tl-muted: #6b7c8f;
  --tl-line: #dfe6ee;
  --tl-bg: #f4f7fb;
  --tl-surface: #ffffff;
  --tl-brand: #0b6e4f;
  --tl-brand-dark: #08543c;
  --tl-brand-soft: #e6f4ee;
  --tl-accent: #c8964f;
  --tl-danger: #b3261e;
  --tl-danger-soft: #fdeceb;
  --tl-radius: 14px;
  --tl-shadow: 0 1px 2px rgba(13, 27, 42, 0.06), 0 8px 24px rgba(13, 27, 42, 0.06);
  --tl-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--tl-font);
  background: var(--tl-bg);
  color: var(--tl-ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--tl-brand); }

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

/* ---------- Auth pages ---------- */

.auth-shell {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--tl-surface);
  border: 1px solid var(--tl-line);
  border-radius: var(--tl-radius);
  box-shadow: var(--tl-shadow);
  padding: 28px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--tl-brand), var(--tl-brand-dark));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px; letter-spacing: -0.5px;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -0.2px; }
.brand-sub { font-size: 12.5px; color: var(--tl-muted); }

.auth-title { font-size: 21px; font-weight: 650; margin: 0 0 6px; letter-spacing: -0.4px; }
.auth-note { font-size: 13.5px; color: var(--tl-muted); margin: 0 0 20px; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--tl-ink-soft); }

.field input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--tl-line);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  border-color: var(--tl-brand);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.14);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--tl-brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: var(--tl-brand-dark); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--tl-ink); border-color: var(--tl-line); }
.btn-secondary:hover:not(:disabled) { background: var(--tl-bg); }

/* An anchor styled as a button must not inherit the global link colour. */
a.btn { color: #fff; text-decoration: none; }
a.btn-secondary { color: var(--tl-ink); }

/* The `hidden` attribute must always win, even over later layout rules. */
[hidden] { display: none !important; }

.alert {
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: var(--tl-danger-soft); border-color: #f3c9c5; color: #8c1d18; }
.alert-info { background: var(--tl-brand-soft); border-color: #bfe3d4; color: #075840; }
.alert[hidden] { display: none; }

.hint { font-size: 12.5px; color: var(--tl-muted); margin-top: 14px; }
.pw-meter { height: 4px; border-radius: 3px; background: var(--tl-line); margin-top: 8px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; background: var(--tl-danger); transition: width 0.2s, background 0.2s; }

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

.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  background: var(--tl-surface);
  border-left: 1px solid var(--tl-line);
  border-right: 1px solid var(--tl-line);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--tl-line);
  background: #fff;
  flex: 0 0 auto;
}

.chat-header .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-header .who strong { font-size: 15px; letter-spacing: -0.2px; }
.chat-header .who span { font-size: 12.5px; color: var(--tl-muted); }

.icon-btn {
  border: 1px solid var(--tl-line);
  background: #fff;
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tl-ink-soft);
  cursor: pointer;
}
.icon-btn:hover { background: var(--tl-bg); }

.chat-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.msg { display: flex; margin-bottom: 14px; }
.msg-user { justify-content: flex-end; }
.msg-assistant { justify-content: flex-start; }

.bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 15px;
  font-size: 14.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-user .bubble {
  background: var(--tl-brand);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg-assistant .bubble {
  background: var(--tl-bg);
  border: 1px solid var(--tl-line);
  border-bottom-left-radius: 5px;
}
.msg-error .bubble {
  background: var(--tl-danger-soft);
  border-color: #f3c9c5;
  color: #8c1d18;
}

.msg-meta {
  font-size: 11.5px;
  color: var(--tl-muted);
  margin-top: 5px;
  padding: 0 4px;
}
.msg-user .msg-meta { text-align: right; }

.draft-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff7e8;
  border: 1px solid #ecd6ad;
  color: #8a5d12;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--tl-muted); font-size: 13px; }
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tl-brand);
  animation: blink 1.2s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: 0.18s; }
.dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.quick-actions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 9px 14px;
  border-top: 1px solid var(--tl-line);
  background: #fff;
  flex: 0 0 auto;
  scrollbar-width: none;
}
.quick-actions::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--tl-line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--tl-ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover:not(:disabled) { background: var(--tl-brand-soft); border-color: #bfe3d4; color: var(--tl-brand-dark); }
.chip:disabled { opacity: 0.5; cursor: not-allowed; }

.composer {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--tl-line);
  background: #fff;
  flex: 0 0 auto;
}
.composer textarea {
  flex: 1 1 auto;
  resize: none;
  max-height: 132px;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--tl-line);
  border-radius: 12px;
  outline: none;
  font-size: 15px;
  line-height: 1.4;
  background: #fff;
}
.composer textarea:focus { border-color: var(--tl-brand); box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.13); }
.send-btn {
  flex: 0 0 auto;
  width: 46px; height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--tl-brand);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
}
.send-btn:hover:not(:disabled) { background: var(--tl-brand-dark); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.empty-state { text-align: center; color: var(--tl-muted); padding: 34px 16px; font-size: 14px; }
.empty-state h2 { font-size: 17px; color: var(--tl-ink); margin: 0 0 6px; }

.owner-panel { border-top: 1px solid var(--tl-line); background: var(--tl-bg); padding: 14px; flex: 0 0 auto; }
.owner-panel[hidden] { display: none; }
.owner-panel h3 { margin: 0 0 8px; font-size: 14px; }
.invite-row { display: flex; gap: 8px; margin-bottom: 10px; }
.invite-row input {
  flex: 1 1 auto; padding: 10px 12px;
  border: 1px solid var(--tl-line); border-radius: 9px; font-size: 14px;
}
.invite-row button { width: auto; flex: 0 0 auto; padding: 10px 14px; font-size: 13px; }
.invite-out {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: #fff;
  border: 1px dashed var(--tl-line);
  border-radius: 9px;
  padding: 9px 11px;
  overflow-wrap: anywhere;
  margin-top: 8px;
}
.invite-out[hidden] { display: none; }
