/**
 * Group Room — chat surface for shared goals.
 * Uses project tokens (--fg, --fg-muted, --surface-1, --surface-2, --border,
 * --accent-cyan, --warning) with safe fallbacks.
 */

/* Prevent display:flex from overriding the HTML hidden attribute */
.group-room[hidden] { display: none !important; }

.group-room {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--surface-1, #1a1a1a);
  color: var(--fg, #f0f0f0);
}

.group-room__header {
  padding: 16px;
  border-bottom: 1px solid var(--border, #333);
}

.group-room__back {
  background: transparent;
  border: 1px solid var(--border, #333);
  color: var(--fg, #f0f0f0);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.group-room__back:hover {
  background: var(--surface-2, #2a2a2a);
}

.group-room__anchor {
  margin: 12px 0;
}

.group-room__goal-title {
  font-size: 18px;
  font-weight: 600;
}

.group-room__milestone {
  font-size: 13px;
  color: var(--fg-muted, #aaa);
  margin-top: 4px;
}

.group-room__tabs {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}

.group-room__tab {
  padding: 8px 16px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--fg, #f0f0f0);
  font-size: 14px;
}

.group-room__tab.is-active {
  background: var(--surface-2, #2a2a2a);
  border-color: var(--border, #444);
}

.group-room__body {
  flex: 1;
  overflow: hidden;
}

.group-room__pane {
  display: none;
  height: 100%;
  padding: 16px;
  overflow-y: auto;
}

.group-room__pane.is-active {
  display: flex;
  flex-direction: column;
}

.group-room__recap {
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface-2, #1f1f1f);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  color: var(--fg-muted, #aaa);
  font-size: 13px;
}

.group-room__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.group-room__msg {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2, #2a2a2a);
}

.group-room__msg--system {
  background: transparent;
  font-style: italic;
  color: var(--fg-muted, #aaa);
  text-align: center;
}

.group-room__msg--ispirit {
  border-left: 3px solid var(--accent-cyan, #4a90e2);
}

.group-room__msg-meta {
  font-size: 11px;
  color: var(--fg-muted, #aaa);
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.group-room__msg-time {
  font-weight: 400;
  white-space: nowrap;
  opacity: 0.85;
}

.group-room__state-bar {
  padding: 4px 0;
  font-size: 12px;
  color: var(--fg-muted, #aaa);
}

.group-room__composer {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #333);
}

.group-room__composer textarea {
  flex: 1;
  min-height: 64px;
  padding: 8px;
  background: var(--surface-2, #1f1f1f);
  border: 1px solid var(--border, #333);
  color: var(--fg, #f0f0f0);
  border-radius: 6px;
  font: inherit;
  resize: vertical;
}

.group-room__composer button {
  background: var(--accent-cyan, #4a90e2);
  color: #fff;
  border: 0;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

.group-room__composer button:hover {
  filter: brightness(1.1);
}

/* Phase 4: Action Proposal card — design-pack visuals (per pages-extra.jsx
   ChatPage proposal card). Same selectors as before; restyled to the
   tighter surface-2 card with gradient "Lumis proposes" pill on the type. */
.group-room__proposal-card {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-2, #1a1f2e);
  border: 1px solid var(--border-subtle, rgba(148, 121, 255, 0.22));
  position: relative;
}

.proposal-card__type {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--gradient-brand, linear-gradient(135deg, #4FACFE 0%, #9479FF 100%));
  color: white;
  margin-bottom: 10px;
}

.proposal-card__payload {
  font-size: 12px;
  color: var(--fg-muted, #94a3b8);
  margin: 0 0 8px;
  font-family: var(--font-mono, ui-monospace, "Courier New", monospace);
  padding: 8px 10px;
  background: var(--surface-flat, #0f172a);
  border-radius: 6px;
  border: 1px solid var(--border, #1f2937);
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
}

.proposal-card__rationale {
  font-size: 12px;
  color: var(--fg-muted, #94a3b8);
  margin: 0 0 12px;
  font-style: italic;
  line-height: 1.5;
}

.proposal-card__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.proposal-card__actions button {
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border, #1f2937);
  background: var(--surface-flat, #0f172a);
  color: var(--fg, #e6edf3);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.proposal-card__actions button:hover {
  border-color: var(--border-strong, rgba(255, 255, 255, 0.2));
  background: rgba(255, 255, 255, 0.04);
}
.proposal-card__actions button[data-action="approve"] {
  background: var(--gradient-brand, linear-gradient(135deg, #4FACFE 0%, #9479FF 100%));
  color: white;
  border-color: transparent;
}

.group-room__proposal-card.is-approved {
  opacity: 0.6;
}

.member-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.member-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #333);
}

.member-name {
  font-weight: 600;
}

.member-spirit {
  color: var(--fg-muted, #aaa);
  flex: 1;
}

.toggle-spirit-btn {
  background: transparent;
  color: var(--fg, #f0f0f0);
  border: 1px solid var(--border, #444);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.leave-mission-btn,
.remove-member-btn {
  background: transparent;
  color: var(--fg-muted, #aaa);
  border: 1px solid var(--border, #444);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.remove-member-btn {
  color: var(--accent-rose, #e5737a);
  border-color: color-mix(in srgb, var(--accent-rose, #e5737a) 45%, transparent);
}

.leave-mission-btn:hover,
.remove-member-btn:hover {
  border-color: currentColor;
}

.member-hint {
  font-size: 12px;
  flex-basis: 100%;
}

.member-hint--owner {
  color: var(--fg-muted, #aaa);
}

.member-hint--err {
  color: var(--accent-rose, #e5737a);
}

.rules-prompt {
  background: var(--surface-2, #1f1f1f);
  padding: 12px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

.rules-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.rules-actions button {
  background: var(--accent-cyan, #4a90e2);
  color: #fff;
  border: 0;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
}

.rules-readonly-note {
  color: var(--fg-muted, #aaa);
  font-style: italic;
}

/* Knowledge tab (shared journal) */
.knowledge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.knowledge-actions {
  display: flex;
  gap: 8px;
}

.knowledge-actions button {
  background: var(--accent-cyan, #4a90e2);
  color: #0b1220; /* white on the cyan fill was 2.42:1 (reviewer 2026-09-03) */
  border: 0;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.knowledge-search {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--surface-2, #1f1f1f);
  color: var(--fg, #f0f0f0);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
}

.knowledge-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.knowledge-entry {
  background: var(--surface-2, #1f1f1f);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  padding: 12px;
}

.knowledge-entry__title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.knowledge-entry__preview {
  margin: 0 0 8px;
  color: var(--fg-muted, #aaa);
  font-size: 13px;
}

.knowledge-entry__meta {
  font-size: 11px;
  color: var(--fg-muted, #aaa);
  margin-bottom: 8px;
}

.knowledge-entry__actions {
  display: flex;
  gap: 8px;
}

.knowledge-entry__actions button {
  background: transparent;
  color: var(--fg, #f0f0f0);
  border: 1px solid var(--border, #444);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.knowledge-empty {
  color: var(--fg-muted, #aaa);
  font-style: italic;
  text-align: center;
  padding: 24px;
}

/* ─── Empty-state notices (chat empty, room 404, etc.) ─────────────── */
.group-room__empty {
  padding: 24px;
  text-align: center;
  color: var(--fg-muted, #888);
}

/* ─── Inline confirmation row (replaces window.confirm()) ──────────── */
.inline-confirm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.inline-confirm button {
  font-size: 0.85em;
  padding: 2px 8px;
}

/* ─── Members tab: Invite-collaborator form (owner-only) ───────────── */
.member-invite {
  margin-top: 16px;
  padding: 12px;
  border-top: 1px solid var(--border, #333);
}
.member-invite h4 {
  margin: 0 0 8px;
  font-size: 1em;
}
.member-invite form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.member-invite input[type="email"] {
  flex: 1;
  min-width: 200px;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--border, #444);
  background: var(--surface-2, #222);
  color: var(--fg, #eee);
}
.member-invite button[type="submit"] {
  padding: 6px 14px;
}
.invite-status {
  margin-top: 8px;
  font-size: 0.9em;
  color: var(--fg-muted, #aaa);
  width: 100%;
}

/* ─── Composer state-bar (typing indicator) ────────────────────────── */
.group-room__state-bar {
  padding: 4px 16px;
  font-size: 0.85em;
  color: var(--fg-muted, #aaa);
  min-height: 1.5em;
}
.group-room__state--typing {
  font-style: italic;
}

/* Mission Connections tab */
.conn-intro { font-size: 13px; color: var(--fg-muted, #aaa); margin: 0 0 12px; line-height: 1.5; }
.conn-card { background: var(--surface-2, #1f1f1f); border: 1px solid var(--border, #333); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.conn-card__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.conn-card__label { color: var(--fg-muted, #aaa); }
.conn-card__target { font-size: 13px; margin: 6px 0 0; word-break: break-all; }
.conn-card__fp { font-size: 11px; color: var(--fg-muted, #888); margin-top: 4px; }
.conn-card__err { font-size: 12px; color: var(--accent-rose, #e57); margin-top: 4px; }
.conn-card__actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.conn-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border, #444); }
.conn-badge--ok { color: #6ee7b7; border-color: rgba(34,197,94,0.4); }
.conn-badge--error { color: #fca5a5; border-color: rgba(248,113,113,0.4); }
.conn-badge--unverified { color: var(--fg-muted, #aaa); }
.conn-btn { background: transparent; color: var(--fg, #f0f0f0); border: 1px solid var(--border, #444); padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.conn-btn--primary { background: var(--accent-cyan, #4a90e2); color: #fff; border: 0; }
.conn-add { margin-top: 16px; border-top: 1px solid var(--border, #333); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.conn-add label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.conn-add label span { color: var(--fg-muted, #aaa); font-size: 12px; }
.conn-add input, .conn-add select, .conn-add textarea { background: var(--surface-2, #2a2a2a); color: var(--fg, #f0f0f0); border: 1px solid var(--border, #333); border-radius: 6px; padding: 8px; font-family: inherit; font-size: 14px; }
.conn-add__guide { font-size: 12px; color: var(--fg-muted, #888); }
.conn-add__guide summary { cursor: pointer; color: rgba(148,197,254,0.9); font-weight: 600; }
.conn-add__guide ol { margin: 6px 0 0; padding-left: 18px; line-height: 1.5; }
.conn-add__result { font-size: 13px; color: var(--accent-rose, #e57); }

/* ─── Chat-style bubbles (owner request 2026-07-07: reuse the normal chat
   page's message format). Own messages right-aligned accent; iSpirit left
   with spirit tint; paragraphs/lists render as real blocks, not a flat
   wall. color-mix on tokens so cozy warms automatically. ─── */
.group-room__msg {
  max-width: 78%;
}
.group-room__msg--mine {
  margin-left: auto;
  background: color-mix(in srgb, var(--accent-purple, #9479ff) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-purple, #9479ff) 28%, transparent);
}
.group-room__msg--ispirit {
  background: color-mix(in srgb, var(--accent-cyan, #4facfe) 8%, var(--surface-2, #1b2436));
}
.group-room__msg--system {
  max-width: 100%;
}
.group-room__msg-text p {
  margin: 0 0 0.55em;
  line-height: 1.55;
}
.group-room__msg-text p:last-child { margin-bottom: 0; }
.group-room__msg-text ul {
  margin: 0.3em 0 0.55em 1.15em;
  padding: 0;
}
.group-room__msg-text li {
  margin: 0.22em 0;
  line-height: 1.5;
}
/* Chip style local to this page — chat's rule lives in styles.css, which
   spirit-baby.html does not load. */
.group-room__msg .wizard-launch-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.55rem;
  margin-right: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent-purple, #9479ff) 45%, transparent);
  background: color-mix(in srgb, var(--accent-purple, #9479ff) 12%, transparent);
  color: var(--fg, #e5e7eb);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.group-room__msg .wizard-launch-chip:hover {
  background: color-mix(in srgb, var(--accent-purple, #9479ff) 22%, transparent);
}


/* ── Room-scoped search banner (2026-08-02) ───────────────────────────────
   Shown when the AppShell topbar query is claimed by the mission room instead
   of navigating out to /search.html. */
.room-search-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  background: color-mix(in srgb, var(--accent-purple, #9479ff) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-purple, #9479ff) 28%, transparent);
  color: var(--fg, #e6edf3);
}
.room-search-clear {
  flex: none;
  background: none;
  border: 0;
  padding: 2px 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-purple, #9479ff);
}
.room-search-clear:hover { text-decoration: underline; }
.room-search-clear:focus-visible { outline: 2px solid var(--accent-purple, #9479ff); outline-offset: 2px; }

/* ── Knowledge results (2026-09-03 missions-room-redesign §5) ─────────── */
.knowledge-filter { display: flex; gap: 6px; margin: -4px 0 12px; }
#grp-pane-knowledge .knowledge-filter button { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border, #444);
  background: transparent; color: var(--fg-muted, #aaa); font: inherit; font-size: 12px; box-shadow: none; line-height: 1.2; }
#grp-pane-knowledge .knowledge-filter button::before { content: none; }
#grp-pane-knowledge .knowledge-filter button.is-active { background: var(--surface-2, #2a2a2a); color: var(--fg, #f0f0f0); border-color: var(--accent-cyan, #4a90e2); }
.knowledge-entry--result { border-left: 3px solid var(--accent-purple, #9479ff); }
.knowledge-badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; margin-right: 6px;
  border-radius: 999px; color: var(--fg, #f0f0f0); background: color-mix(in srgb, var(--accent-purple, #9479ff) 25%, transparent); vertical-align: middle; }
.knowledge-entry__chart-link { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 4px; border: 1px solid var(--border, #444);
  color: var(--fg, #f0f0f0); font-size: 12px; text-decoration: none; }
.knowledge-entry__chart-link:hover { border-color: var(--accent-purple, #9479ff); }
.knowledge-notice { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2, #1f1f1f); color: var(--fg-muted, #aaa); font-size: 13px; }
.knowledge-entry[hidden] { display: none; }
