/* OrgSense — styles. Vanilla CSS, no build step. Light-first, dark-aware. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e6ea;
  --text: #1a2027;
  --text-muted: #5b6773;
  --accent: #2f6f4f;      /* Northgate green */
  --accent-ink: #ffffff;
  --accent-soft: #e7f1eb;
  --danger: #b3261e;
  --chip-bg: #eef1f4;
  --chip-hover: #e2e7ec;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.06), 0 8px 24px rgba(16, 24, 32, 0.08);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #171d24;
    --surface-2: #1e262f;
    --border: #2a333d;
    --text: #e6ebf0;
    --text-muted: #9aa7b4;
    --accent: #4fae7d;
    --accent-ink: #06120b;
    --accent-soft: #16281f;
    --danger: #f2685f;
    --chip-bg: #222b34;
    --chip-hover: #2b3742;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 7px; border-radius: 999px; text-transform: uppercase;
}
.badge-poc { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.coverage { text-align: right; line-height: 1.15; margin-right: 4px; }
.coverage-num { font-weight: 700; font-size: 15px; color: var(--accent); }
.coverage-label { display: block; font-size: 11px; color: var(--text-muted); }
.whoami {
  font: inherit; font-size: 12px; color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); padding: 5px 12px; border-radius: 999px;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.whoami:hover { background: var(--chip-hover); color: var(--text); border-color: var(--accent); }

/* ===== Buttons ===== */
.btn {
  font: inherit; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid transparent; padding: 8px 14px; font-size: 14px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(179, 38, 30, 0.08); }

/* ===== Chat ===== */
.chat-wrap {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
.chat-scroll { flex: 1; overflow-y: auto; padding: 28px 20px 8px; }
.chat-inner { max-width: var(--maxw); margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg-avatar {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px; margin-top: 2px;
}
.msg-bot .msg-avatar { background: var(--accent-soft); }
.msg-user { flex-direction: row-reverse; }
.msg-user .msg-avatar { background: var(--surface-2); }
.msg-body { max-width: 88%; }
/* Cards with short content (e.g. the profile form) would otherwise shrink to
   fit — let them fill the row like the text bubbles. */
.msg-body.wide { flex: 1 1 auto; max-width: none; }
.msg-bubble {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 16px; box-shadow: var(--shadow); line-height: 1.5; font-size: 15px;
}
.msg-user .msg-bubble { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 700; }

/* Action chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  font: inherit; font-size: 13px; cursor: pointer;
  background: var(--chip-bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 13px; border-radius: 999px; transition: background 0.12s ease;
}
.chip:hover { background: var(--chip-hover); }
.chip-icon { margin-right: 6px; }

/* Result cards */
.result-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  margin-top: 10px; background: var(--surface-2);
}
.result-card:first-child { margin-top: 4px; }
.result-name { font-weight: 700; font-size: 15px; }
.result-role { color: var(--accent); font-weight: 600; font-size: 14px; margin-top: 1px; }
.result-meta { font-size: 13px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.result-meta .k { color: var(--text); font-weight: 600; }
.result-why {
  margin-top: 9px; font-size: 12px; color: var(--text-muted);
  border-top: 1px dashed var(--border); padding-top: 8px;
}
.match-tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 6px; padding: 1px 7px; margin: 2px 4px 0 0; font-size: 11px; font-weight: 600;
}
.detail-list { margin: 3px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--text); }
.detail-list li { margin: 2px 0; }
.detail-tags { margin-top: 5px; }
.contact-line { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; }
.contact-line a { color: var(--accent); text-decoration: none; }
.contact-line a:hover { text-decoration: underline; }

.empty-state {
  border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px 16px;
  background: var(--surface-2); font-size: 14px; color: var(--text-muted);
}

/* ===== Team API cards (Team Topologies) ===== */
.team-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  margin-top: 10px; background: var(--surface-2); border-left: 3px solid var(--accent);
}
.team-card:first-child { margin-top: 4px; }
.team-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.team-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap;
}
.team-badge--platform { color: #3b82f6; border-color: #3b82f6; background: rgba(59, 130, 246, 0.12); }
.team-badge--enabling { color: #8b5cf6; border-color: #8b5cf6; background: rgba(139, 92, 246, 0.12); }
.team-badge--stream-aligned { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.team-badge--complicated-subsystem { color: #d97706; border-color: #d97706; background: rgba(217, 119, 6, 0.12); }
.team-type-blurb { margin-top: 5px; }
.team-mission { font-size: 14px; margin-top: 8px; line-height: 1.5; }
.team-subhead {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-top: 13px; margin-bottom: 2px;
}
.provides-list { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
.provide-row { font-size: 13px; line-height: 1.45; }
.provide-mode {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; padding: 1px 7px; border-radius: 999px; margin-right: 8px;
  border: 1px solid var(--border); vertical-align: 1px;
}
.provide-mode--self-service { color: var(--accent); border-color: var(--accent); }
.provide-mode--request { color: #d97706; border-color: #d97706; }
.provide-mode--collaborate { color: #8b5cf6; border-color: #8b5cf6; }
.provide-what { font-weight: 600; }
.provide-detail { color: var(--text-muted); }
.team-members {
  font-size: 13px; color: var(--text-muted); margin-top: 11px;
  border-top: 1px dashed var(--border); padding-top: 9px; line-height: 1.5;
}
.team-members .k { color: var(--text); font-weight: 600; }

/* ===== Update profile card (inline in chat) ===== */
.profile-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 16px; box-shadow: var(--shadow);
}
.profile-card h4 { margin: 0 0 4px; font-size: 15px; }
.profile-card .step { margin-top: 14px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 10px 0 5px; }
.input, .describe-area {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.describe-area { resize: vertical; min-height: 120px; line-height: 1.5; }
.input:focus, .describe-area:focus, .chat-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; background: var(--chip-bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 10px; font-size: 12px;
}
.tag button { border: none; background: transparent; cursor: pointer; color: var(--text-muted); font-size: 13px; line-height: 1; padding: 0 2px; }
.tag button:hover { color: var(--danger); }
.tag-add { display: flex; gap: 6px; margin-top: 6px; }
.tag-add input { flex: 1; }
.card-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.parse-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ===== Composer ===== */
.composer { flex-shrink: 0; padding: 12px 20px 16px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer-form {
  max-width: var(--maxw); margin: 0 auto; display: flex; gap: 10px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 8px 8px 8px 16px; box-shadow: var(--shadow);
}
.chat-input {
  flex: 1; border: none; background: transparent; resize: none; font: inherit; font-size: 15px;
  color: var(--text); max-height: 160px; line-height: 1.5; padding: 6px 0;
}
.chat-input:focus { outline: none; }
.send-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; font-size: 20px;
  display: grid; place-items: center; padding: 0;
}
.composer-hint { max-width: var(--maxw); margin: 8px auto 0; font-size: 11px; color: var(--text-muted); text-align: center; }

/* ===== Overlays / modals ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 15, 20, 0.5);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; padding: 22px;
}
.modal-wide { max-width: 720px; }
.modal-login { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.close-x { padding: 4px 9px; font-size: 15px; }
.muted { color: var(--text-muted); }
.muted.small, .small { font-size: 12.5px; line-height: 1.5; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; }

.settings-section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 16px; }
.settings-section:first-of-type { border-top: none; padding-top: 0; margin-top: 12px; }
.settings-section h3 { margin: 0 0 8px; font-size: 14px; }
.switch-row { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.switch-row input { width: 16px; height: 16px; }
.real-ai-fields { margin-top: 8px; }
.settings-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.test-result { font-size: 12px; margin-left: 8px; }
.test-result.ok { color: var(--accent); }
.test-result.err { color: var(--danger); }

/* ===== Browse list ===== */
.browse-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.browse-group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 12px 0 2px; }
.browse-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.browse-row .bn { font-weight: 600; font-size: 14px; }
.browse-row .br { font-size: 13px; color: var(--text-muted); text-align: right; }
.browse-row.skeleton { opacity: 0.72; }
.browse-row.skeleton .br { font-style: italic; }
.browse-row.clickable { cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease; }
.browse-row.clickable:hover, .browse-row.clickable:focus-visible {
  border-color: var(--accent); background: var(--chip-hover); outline: none;
}
.pill-undescribed { font-size: 10px; font-weight: 700; color: var(--danger); border: 1px solid var(--danger); border-radius: 999px; padding: 1px 6px; margin-left: 6px; }

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

@media (max-width: 640px) {
  .coverage-label { display: none; }
  .whoami { max-width: 130px; }
  .msg-body { max-width: 100%; }
  .topbar { padding: 10px 14px; }
  .chat-scroll { padding: 18px 14px 4px; }
  .composer { padding: 10px 14px 14px; }
}
