/* Store team: the Team & roles page, the right rail (teammates, presence, unread) and the team chat
   panel (views/team.js, views/chat.js). Console tokens from app.css. */

/* ---------- shared pieces ---------- */
.team-av { position: relative; }
.team-av .dot {
  position: absolute; inset-inline-end: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--line-strong); border: 2px solid var(--surface);
}
.team-av .dot.on { background: var(--good); }
.team-av.is-off { opacity: .5; }
.team-badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--crit); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}
.team-badge.static { box-shadow: none; }
.team-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; max-width: 100%;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 12px; white-space: nowrap;
}
.team-chip > span { overflow: hidden; text-overflow: ellipsis; }
.team-chip i { font-size: 11px; color: var(--muted); }
.team-chip.sm { padding: 0 7px; font-size: 11.5px; }
.team-chip.plain { background: transparent; }
.team-chip.removable { cursor: pointer; font: inherit; font-size: 12px; }
.team-chip.removable:hover { border-color: var(--crit); color: var(--crit-ink); }
.team-chips { gap: 6px; }

/* ---------- Team & roles page ---------- */
.team-intro { max-width: 70ch; }
.team-tabs { margin-bottom: 0; flex: none; }  /* a scrolling flex item would shrink in the content column */
.team-tabs button i { font-size: 13px; }
.team-person { gap: 10px; min-width: 0; }
.team-person .cell-title { gap: 6px; flex-wrap: wrap; }
.team-person .stack { min-width: 0; }
.team-person .cell-sub { overflow-wrap: anywhere; }
.team-role-name { gap: 6px; font-weight: 550; }
.team-role-name i { color: var(--muted); font-size: 13px; }
.team-tbl tr.is-off td:not(:last-child) { opacity: .6; }
.team-tbl td { vertical-align: middle; }
.team-sm { display: none !important; }
.team-roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.team-role .wc-head { margin-bottom: 2px; }
.team-perms-sum { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; font-size: 12.5px; }
.team-perms-sum li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--line); padding-bottom: 3px; }
.team-role .team-chips { margin-top: 6px; }
.team-secret { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.team-secret code { padding: 6px 8px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); overflow-wrap: anywhere; }

/* role editor */
.team-checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.team-group { margin: 0; padding: 6px 12px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; }
.team-group legend { padding: 0 4px; }
.team-group legend .row { gap: 8px; cursor: pointer; }
.team-check { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; cursor: pointer; min-width: 0; }
.team-check input { margin-top: 3px; flex: none; accent-color: var(--accent); }
.team-check .stack { gap: 1px; min-width: 0; }
.team-check .mono { font-size: 11px; }
.team-group input[type="checkbox"], .team-limits input[type="checkbox"], .team-w input { accent-color: var(--accent); }
.team-limits { gap: 6px; }
.team-limits .field > span i { color: var(--muted); }
.team-wpick { gap: 8px; }
.team-wpick .input { height: 32px; }
.team-wilayas {
  max-height: 220px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.team-w { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 3px 0; cursor: pointer; min-width: 0; }
.team-w span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- right rail ---------- */
.team-rail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 16px; }
.tr-btn {
  position: relative; width: 36px; height: 36px; flex: none; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 16px;
}
.tr-btn:hover { background: var(--surface-2); color: var(--ink); }
.tr-btn.is-open, .tr-btn.is-cur { background: var(--accent-soft); color: var(--accent); }
.tr-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tr-btn .team-badge { position: absolute; top: -3px; inset-inline-end: -4px; }
.tr-btn .avatar { width: 30px; height: 30px; font-size: 11.5px; }
.tr-sep { width: 24px; height: 1px; background: var(--line); margin: 4px 0; flex: none; }
.topbar-rail { display: none; }
.team-top-btn { position: relative; }
.team-top-btn .team-badge { position: absolute; top: -2px; inset-inline-end: -2px; }

/* ---------- chat panel ---------- */
.chat-panel {
  position: fixed; top: 0; bottom: 0; inset-inline-end: var(--side-right); z-index: 26; width: min(400px, calc(100vw - var(--side-right)));
  display: flex; flex-direction: column; background: var(--surface); border-inline-start: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: slide .18s ease-out;
}
/* RTL: the rail is on the left, so the panel opens from the left */
.chat-panel:dir(rtl) { animation-name: slide-rtl; }
.chat-h { display: flex; align-items: center; gap: 8px; padding-block: 12px; padding-inline: 14px 12px; min-height: 61px; border-bottom: 1px solid var(--line); }
.chat-h-t { min-width: 0; gap: 1px; }
.chat-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-b { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px 16px; display: flex; flex-direction: column; }
.chat-f { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; }
.chat-input { flex: 1; min-height: 36px; height: 36px; max-height: 140px; resize: none; padding: 7px 10px; line-height: 1.4; }
.chat-count { align-self: flex-end; font-variant-numeric: tabular-nums; }
.chat-count.over { color: var(--crit-ink); font-weight: 600; }

.chat-list { display: flex; flex-direction: column; gap: 2px; }
.chat-list .section-t { margin: 10px 6px 6px; }
.chat-list .section-t:first-child { margin-top: 0; }
.chat-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer;
}
.chat-row:hover { background: var(--surface-2); }
.chat-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chat-row .avatar { width: 32px; height: 32px; }
.chat-ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink-2); font-size: 14px; }
.chat-row-t { min-width: 0; gap: 1px; }
.chat-row-top { justify-content: space-between; gap: 8px; }
.chat-row-top b { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.is-unread .chat-row-top b { font-weight: 700; }
.chat-row.is-unread .chat-preview { color: var(--ink-2); }
.chat-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-msgs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 86%; margin-top: 10px; }
.chat-msg.grouped { margin-top: 0; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-who { display: flex; gap: 6px; align-items: baseline; margin: 0 4px 2px; }
.chat-who b { font-weight: 600; }
.chat-bubble {
  padding: 7px 11px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.45; max-width: 100%;
}
.chat-msg:not(.mine) .chat-bubble { border-start-start-radius: 6px; }
.chat-msg.mine .chat-bubble { background: var(--accent-soft); border-color: transparent; border-start-end-radius: 6px; }
.chat-msg.grouped:not(.mine) .chat-bubble { border-start-start-radius: 14px; }
.chat-msg.grouped.mine .chat-bubble { border-start-end-radius: 14px; }
.chat-day { align-self: center; margin: 14px 0 2px; }
.chat-day span { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 10px; border-radius: 999px; }
.chat-more { align-self: center; margin-bottom: 4px; }
.chat-empty { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 24px 12px; }
.chat-empty-ico { font-size: 26px; color: var(--muted); margin-bottom: 4px; }

@media (max-width: 1180px) {
  .team-checklist { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 880px) {
  .topbar-rail { display: flex; order: 2; }
  .chat-panel { inset-inline-end: 0; width: 100vw; z-index: 36; border-inline-start: 0; }
  .team-perms-sum { grid-template-columns: minmax(0, 1fr); }
  /* members: one block per person (name, email, role under it; actions on the side) */
  .team-tbl thead { display: none; }
  .team-tbl, .team-tbl tbody { display: block; }
  .team-tbl tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .team-tbl tr:last-child { border-bottom: 0; }
  .team-tbl td { display: block; padding: 0; border: 0; min-width: 0; }
  .team-tbl td:nth-child(2) { grid-column: 1; grid-row: 2; padding-inline-start: 40px; }
  .team-tbl td:last-child { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .team-sm { display: inline-flex !important; }
  .team-roles { grid-template-columns: minmax(0, 1fr); }
  .team-secret { grid-template-columns: minmax(0, 1fr) auto; }
  .team-secret > span { grid-column: 1 / -1; }
}
