/* Team chat.
   Owned by public/js/team.js and loaded after /styles.css. Class names here belong to this module;
   a look shared by several modules goes in /styles.css (npm run check-styles enforces this). */

/* ---------- team chat ---------- */
.team { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0; height: calc(100dvh - var(--topbar-h, 68px) - 3.4rem); min-height: 420px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.team-side { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.team-side-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .8rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.team-side-head h1 { margin: 0; font-size: 1.2rem; }
.team-list { overflow-y: auto; padding: .4rem; display: grid; gap: .15rem; align-content: start; }
.team-list .more-group { margin: .6rem .4rem .2rem; }
/* A conversation in the list (GAKA 1.68.0, WhatsApp-like): picture, name and time, last message and the new count */
.team-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .7rem; padding: .6rem .6rem; border-radius: 10px; color: var(--text); }
.team-item:hover { background: var(--surface-2); text-decoration: none; }
.team-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.team-item-main { display: grid; gap: .1rem; min-width: 0; }
.team-item-top, .team-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; }
.team-item-top strong { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-item-time { flex: none; font-size: .74rem; color: var(--muted); }
.team-item-last { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; color: var(--muted); }
.team-item-by { color: var(--text); opacity: .85; }
.team-item.team-new strong { font-weight: 800; }
.team-item.team-new .team-item-time { color: var(--ok); font-weight: 700; }
.team-item.team-new .team-item-last { color: var(--text); }
.team-count { flex: none; min-width: 1.35rem; height: 1.35rem; padding: 0 .4rem; border-radius: 999px; background: var(--ok); color: #fff; font-size: .74rem; font-weight: 800; display: grid; place-items: center; }
/* Pictures: a person's initials in their colour; a channel is #; the whole-company channel is GAKA blue */
.team-avatar { position: relative; flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .9rem;
  color: #fff; background: hsl(var(--hue, 215) 55% 45%); }
.team-avatar.chan { background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); color: var(--accent); font-size: 1.1rem; }
.team-avatar.chan.all { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7c3aed)); color: #fff; }
.team-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.team-thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.team-head { display: flex; align-items: center; gap: .7rem; padding: .65rem .9rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.team-head-main strong { font-size: 1.02rem; }
.team-head .back { display: none; }
/* The conversation (GAKA 1.68.0, WhatsApp-like): a soft patterned wall, day pills, bubbles with a tail and the time inside */
.tmsgs { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .15rem;
  background-color: var(--bg); background-image: radial-gradient(color-mix(in srgb, var(--text) 6%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
.tday { align-self: center; margin: .8rem 0 .4rem; position: sticky; top: 0; z-index: 1; }
.tday span { display: inline-block; padding: .22rem .7rem; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: .76rem; font-weight: 600; color: var(--muted); box-shadow: var(--shadow-xs); }
.tmsg { display: flex; align-items: flex-end; gap: .45rem; max-width: min(680px, 82%); align-self: flex-start; }
.tmsg.mine { align-self: flex-end; }
.tmsg:not(.cont) { margin-top: .5rem; }
.tmsg-avatar { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; background: hsl(var(--hue) 55% 45%); }
.tmsg.cont .tmsg-avatar { background: none; }
.tmsg-bubble { position: relative; padding: .4rem .6rem .35rem .7rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 1px 1px rgba(0,0,0,.08); min-width: 4.5rem; }
.tmsg:not(.cont):not(.mine) .tmsg-bubble { border-bottom-left-radius: 3px; }
.tmsg.mine .tmsg-bubble { background: var(--accent); border-color: transparent; color: #fff; }
.tmsg.mine:not(.cont) .tmsg-bubble { border-bottom-right-radius: 3px; }
.tmsg-name { display: flex; align-items: baseline; gap: .4rem; font-size: .8rem; font-weight: 750; color: hsl(var(--hue) 65% 58%); margin-bottom: .1rem; }
.tmsg-role { font-size: .66rem; font-weight: 600; color: var(--muted); }
.tmsg-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.tmsg-time { float: right; margin: .35rem 0 -.1rem .7rem; font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tmsg.mine .tmsg-time { color: rgba(255,255,255,.8); }
.tmsg.mine .tmsg-body a { color: #fff; text-decoration: underline; }
/* The message bar: a rounded box that grows, and a round send button */
.team-compose { display: flex; gap: .55rem; padding: .65rem .8rem; border-top: 1px solid var(--border); align-items: flex-end; background: var(--surface); }
.team-compose textarea { flex: 1; resize: none; min-height: 2.75rem; max-height: 10rem; border-radius: 22px; padding: .65rem 1rem; line-height: 1.35; }
.team-send { flex: none; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; cursor: pointer; box-shadow: var(--shadow-xs); transition: transform .1s, filter .15s; }
.team-send:hover { filter: brightness(1.08); }
.team-send:active { transform: scale(.94); }
@media (max-width: 899px) {
  .team { grid-template-columns: 1fr; height: calc(100dvh - var(--nav-h) - 2rem); }
  .team.open .team-side { display: none; }
  .team:not(.open) .team-main { display: none; }
  .team-head .back { display: inline-flex; }
}

/* Channel header: name on the left, Members / Leave on the right */
.team-head-main { flex: 1; min-width: 0; }
.team-head-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
/* Choosing people for a channel: departments and colleagues as ticks */
.pick-people { max-height: 46vh; overflow-y: auto; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .2rem .8rem; }
.pick-row { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; cursor: pointer; }
/* A channel's members */
.member-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; max-height: 50vh; overflow-y: auto; }
.member-row { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.member-row > span:nth-child(2) { flex: 1; }
.form .pick-row { display: flex; flex-direction: row; justify-content: flex-start; text-align: left; }
.pick-row input { width: auto; flex: none; margin: 0; padding: 0; }
.pick-row small { display: inline; }
