/* F-0032 Chat UI styles. FACETS brand tokens, light + dark, mobile-first, a11y.
   navy #12161F, gold #D9A441, teal #3E8E7E; Space Grotesk (headings) + Inter (body). */

:root {
  --jg-navy: #12161F;
  --jg-gold: #D9A441;
  --jg-teal: #3E8E7E;

  /* Light theme (default). */
  --bg: #FFFFFF;
  --surface: #F4F5F7;
  --text: #12161F;
  --muted: #5A6472;
  --border: #E2E5EA;
  --bot-bubble: #EEF4F2;
  --user-bubble: #12161F;
  --user-text: #FFFFFF;
  --accent: #D9A441;
  --accent-text: #12161F;
  --focus: #3E8E7E;
}

:root[data-theme="dark"] {
  --bg: #12161F;
  --surface: #1B2029;
  --text: #F4F5F7;
  --muted: #9AA4B2;
  --border: #2A303B;
  --bot-bubble: #1F2A2A;
  --user-bubble: #D9A441;
  --user-text: #12161F;
  --accent: #D9A441;
  --accent-text: #12161F;
  --focus: #D9A441;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161F;
    --surface: #1B2029;
    --text: #F4F5F7;
    --muted: #9AA4B2;
    --border: #2A303B;
    --bot-bubble: #1F2A2A;
    --user-bubble: #D9A441;
    --user-text: #12161F;
    --accent: #D9A441;
    --accent-text: #12161F;
    --focus: #D9A441;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.jg-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
}

.jg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.jg-title {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.jg-title .jg-dot { color: var(--jg-gold); }

.jg-theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.jg-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.jg-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.jg-msg.bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  border-bottom-left-radius: 4px;
}

.jg-msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.jg-msg.error {
  align-self: flex-start;
  background: #fdecec;
  color: #9b1c1c;
  border: 1px solid #f5c2c2;
}

.jg-controls {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.jg-chip {
  border: 1px solid var(--jg-teal);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}

.jg-chip:hover { background: var(--bot-bubble); }

.jg-form { display: flex; flex-direction: column; gap: 8px; }

.jg-field { display: flex; flex-direction: column; gap: 4px; }

.jg-field label { font-size: 0.8rem; color: var(--muted); }

.jg-input {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
}

.jg-row { display: flex; gap: 8px; }
.jg-row .jg-input { flex: 1 1 auto; }

.jg-btn {
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}

.jg-btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.jg-cta {
  display: inline-block;
  margin-top: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  padding: 12px 18px;
  text-align: center;
}

.jg-badge-hot {
  display: inline-block;
  background: var(--jg-gold);
  color: var(--jg-navy);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  vertical-align: middle;
}

.jg-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bot-bubble);
  border-radius: 14px;
}
.jg-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: jg-bounce 1.2s infinite ease-in-out;
}
.jg-typing span:nth-child(2) { animation-delay: 0.15s; }
.jg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes jg-bounce { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Visible keyboard focus for a11y. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .jg-typing span { animation: none; }
}

@media (min-width: 480px) {
  .jg-msg { max-width: 78%; }
}
