/* chat.css — the participant-facing team chat (aiTeam.php).
   Shared tokens, avatars, message rows and typing bubbles come from app.css.
   Author: Marc Becker */

/* The participant chat keeps its previous colors (a deliberate choice): the
   studio's shared tokens are overridden here, the structure stays shared. */
:root {
  --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --faint: #94a3b8;
  --line: #e2e8f0; --line-soft: #eef2f7; --bg: #f2f5fa;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-soft: #eef2ff;
}
html, body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; background: var(--bg); }

/* ---- Header ---- */
.chat-top {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.team-info { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.team-text { min-width: 0; }
.team-stack { display: flex; }
.team-stack .avatar { width: 30px; height: 30px; font-size: 11px; border: 2px solid #fff; }
.team-stack .avatar + .avatar { margin-left: -8px; }
.team-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* One line: a large team or long names end in "…" (the full list is the tooltip) */
.team-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); vertical-align: 1px; margin-right: 1px; }
/* Phones: smaller pictures, up to four teammates in the stack, then the participant */
@media (max-width: 480px) {
  .chat-top { padding: 10px 14px; gap: 10px; }
  .team-stack .avatar { width: 26px; height: 26px; font-size: 10px; }
  .team-stack .avatar + .avatar { margin-left: -9px; }
  .team-stack .avatar:nth-child(n+5):not(:last-child) { display: none; }
}

/* ---- Session timer ---- */
.timer-pill {
  margin-left: auto; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 7px;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 6px 14px;
  transition: background .3s, color .3s;
}
.timer-pill.danger { background: var(--danger-soft); color: var(--danger); }
.timer-track { height: 3px; background: var(--line-soft); flex-shrink: 0; }
.timer-fill { height: 100%; width: 100%; background: var(--accent); transition: width .5s linear, background .3s; }
.timer-fill.danger { background: var(--danger); }

/* ---- Instructions above the chat (optional; project settings, Step 1) ----
   A box between the timer and the messages that stays in place while the chat
   scrolls. Its text is styled by .richtext in app.css. Long texts scroll
   inside the box, so the chat always keeps most of the window. */
.chat-instructions { flex-shrink: 0; padding: 12px 18px 4px; }
.chat-instructions-box {
  max-width: 744px; margin: 0 auto;
  max-height: 36vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 14px;
  /* White, with a soft shadow at the top or bottom edge while there is more
     text in that direction: the two white layers move with the text and cover
     the shadows once its start or end is reached. */
  background:
    linear-gradient(#fff 30%, rgba(255, 255, 255, 0)) top / 100% 32px no-repeat local,
    linear-gradient(rgba(255, 255, 255, 0), #fff 70%) bottom / 100% 32px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(15, 23, 42, .18), rgba(15, 23, 42, 0)) top / 100% 9px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(15, 23, 42, .18), rgba(15, 23, 42, 0)) bottom / 100% 9px no-repeat scroll,
    #fff;
}
@media (max-width: 640px) {
  .chat-instructions { padding: 10px 12px 4px; }
  .chat-instructions-box { padding: 10px 14px; max-height: 32vh; }
}

/* ---- Conversation ---- */
.chat-scroll { flex: 1; overflow-y: auto; padding: 8px 0 18px; }
.chat-col { max-width: 780px; margin: 0 auto; padding: 0 18px; }

/* ---- Composer ---- */
.composer-wrap {
  flex-shrink: 0;
  background: linear-gradient(to top, var(--bg) 65%, transparent);
  padding: 8px 0 16px;
}
.composer {
  max-width: 780px; margin: 0 auto; padding: 0 18px;
  display: flex; gap: 10px; align-items: flex-end;
}
.composer input {
  flex: 1;
  font: inherit; font-size: 16px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.composer input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .13); }
.composer input:disabled { background: var(--line-soft); color: var(--muted); }
.composer button {
  width: 46px; height: 46px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff;
  font-size: 17px; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, transform .06s;
}
.composer button:hover { background: var(--accent-hover); }
.composer button:active { transform: scale(.95); }
.composer button:disabled { background: var(--line); cursor: default; transform: none; }
.composer-note { max-width: 780px; margin: 6px auto 0; padding: 0 18px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* ---- Ready gate ---- */
.ready-card { text-align: center; }
.ready-team { display: flex; justify-content: center; margin: 8px 0 16px; }
.ready-team .avatar { width: 44px; height: 44px; font-size: 15px; border: 3px solid #fff; }
.ready-team .avatar + .avatar { margin-left: -10px; }
.ready-instructions {
  text-align: left; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; margin: 14px 0 4px;
  font-size: 14px; color: var(--ink-2); white-space: pre-wrap;
  max-height: 300px; overflow-y: auto;
}
.finding { display: none; padding: 18px 0 6px; }
.finding .spinner { width: 34px; height: 34px; border-width: 4px; margin-bottom: 14px; }

/* ---- Not-ready page (no script) ---- */
.notready { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.notready .card { max-width: 440px; text-align: center; }

/* ---- Debug panel (?debug=1) ---- */
#debugPanel {
  position: fixed; left: 12px; bottom: 86px; z-index: 90;
  width: 380px; max-height: 260px; overflow-y: auto;
  background: rgba(15, 23, 42, .92); color: #cbd5e1;
  font-family: var(--mono); font-size: 11px; line-height: 1.5;
  border-radius: 10px; padding: 10px 12px;
  display: none;
}
#debugPanel div { border-bottom: 1px solid rgba(255, 255, 255, .06); padding: 2px 0; word-break: break-all; }
