/* =============================================================================
   27 — FIRM · TEAM MESSAGING  (template-parts/firm/view-team.php re-skin)
   -----------------------------------------------------------------------------
   Visual target: "21 Team Messaging.dc.html" — a polished, INTERNAL (client-
   invisible) two-pane channel: a hard "Internal — clients never see this" banner,
   a toggleable "New team message" composer card, a Conversations list and an
   active conversation with participant chips + left/right bubbles + pinned reply.

   RE-SKIN ONLY. Every rule is compound-scoped to `.portal-shell.firm-shell` and,
   inside that, to team-only wrappers (.ft-team / .ft-grid / .ft-compose-card)
   so the SHARED components reused here (.msg-item/.msg-list/.msg-name/.msg-time/
   .msg-preview/.unread-dot/.bubble/.msg-thread/.msg-compose/.firm-form/.firm-field)
   are refined, never redefined, and the CLIENT messaging shell
   (.portal-shell.portal-dash-body) is untouched.

   Composer toggle is CSS-only: a hidden checkbox (#ftComposeToggle) swaps the
   inbox card for the composer card. The compose <form> + its nonce stay in the
   DOM and work without JavaScript. No sample data, no dead controls.

   Tokens only: --red #d81f26, --red-dark, --blue #26408d, --blue-ink #15224d,
   --blue-pale #eef1f8, --grey-50 #f5f6fa, --grey-100 #eef0f6, --hair #e5e7eb,
   --mid, --ink, --r-lg 16px, --r-pill, --sh-1.
   ============================================================================= */

/* --- Header row: eyebrow + Playfair title (shared) + red "New message" ------ */
.portal-shell.firm-shell .ft-team .ft-head{
	align-items:flex-start;
	margin-bottom:14px;
}
.portal-shell.firm-shell .ft-team .ft-title{
	margin-bottom:0;
}
.portal-shell.firm-shell .ft-team .ft-new-btn{
	display:inline-flex;
	align-items:center;
	gap:6px;
	border-radius:7px;
	padding:11px 20px;
	font-size:13.5px;
	cursor:pointer;
}
.portal-shell.firm-shell .ft-team .ft-plus{flex-shrink:0}

/* --- Internal banner -------------------------------------------------------- */
/* Blue-ink lock pill on the grey-100 wash — the client/firm boundary made loud. */
.portal-shell.firm-shell .ft-banner{
	display:flex;
	align-items:center;
	gap:10px;
	flex-wrap:wrap;
	background:var(--grey-100);
	border-radius:10px;
	padding:11px 18px;
	margin-bottom:18px;
}
.portal-shell.firm-shell .ft-banner-ic{
	display:inline-flex;
	color:var(--blue-ink);
	flex-shrink:0;
}
.portal-shell.firm-shell .ft-banner strong{
	font-size:13px;
	font-weight:600;
	color:var(--blue-ink);
}
.portal-shell.firm-shell .ft-banner .ft-banner-sub{
	font-size:12.5px;
	color:var(--mid);
}

/* --- Compose toggle (CSS-only) --------------------------------------------- */
/* Default: inbox visible, composer hidden. Checked: composer visible, inbox out.
   The form stays in the DOM either way; PHP checks the box on a validation error
   so the composer re-opens with the message shown. */
.portal-shell.firm-shell .ft-team .ft-compose-cb{
	position:absolute;
	width:1px;height:1px;
	overflow:hidden;clip:rect(0 0 0 0);
	white-space:nowrap;border:0;padding:0;margin:-1px;
}
.portal-shell.firm-shell .ft-team .ft-compose-card{display:none}
.portal-shell.firm-shell .ft-team .ft-compose-cb:checked ~ .ft-compose-card{display:block}
.portal-shell.firm-shell .ft-team .ft-compose-cb:checked ~ .ft-grid{display:none}
/* Keyboard focus on the toggling labels reads as a focus ring on the button. */
.portal-shell.firm-shell .ft-team .ft-compose-cb:focus-visible ~ .ft-head .ft-new-open{
	outline:2px solid var(--blue);
	outline-offset:2px;
}

/* --- Compose card ----------------------------------------------------------- */
.portal-shell.firm-shell .ft-compose-card{
	background:#fff;
	border:1px solid var(--hair);
	border-radius:var(--r-lg);
	box-shadow:var(--sh-1);
	padding:24px;
	max-width:640px;
}
.portal-shell.firm-shell .ft-compose-head{
	display:flex;
	justify-content:space-between;
	align-items:center;
	gap:12px;
	margin-bottom:18px;
}
.portal-shell.firm-shell .ft-compose-title{
	font-family:'Playfair Display',Georgia,serif;
	font-size:18px;
	font-weight:700;
	color:var(--blue-ink);
	margin:0;
}
.portal-shell.firm-shell .ft-compose-cancel{
	background:transparent;
	border:1px solid var(--hair);
	border-radius:7px;
	padding:8px 14px;
	font-size:12.5px;
	font-weight:600;
	color:var(--blue-ink);
	cursor:pointer;
}
.portal-shell.firm-shell .ft-compose-cancel:hover{background:var(--blue-pale)}
.portal-shell.firm-shell .ft-compose-form{margin:0}
.portal-shell.firm-shell .ft-compose-form .ft-req{color:var(--red)}
/* The native <select multiple name="recipients[]"> stays the submitted control. */
.portal-shell.firm-shell .ft-compose-form #team_recipients{
	min-height:120px;
	padding:6px;
	border-radius:var(--r-sm);
}
.portal-shell.firm-shell .ft-compose-form #team_recipients option{
	padding:6px 8px;
	border-radius:5px;
}
.portal-shell.firm-shell .ft-compose-actions{justify-content:flex-start}
.portal-shell.firm-shell .ft-compose-actions .btn-red{
	display:inline-flex;
	align-items:center;
	gap:8px;
	border-radius:7px;
}

/* --- Two-pane inbox card ---------------------------------------------------- */
.portal-shell.firm-shell .ft-grid{
	display:grid;
	grid-template-columns:340px 1fr;
	background:#fff;
	border:1px solid var(--hair);
	border-radius:var(--r-lg);
	box-shadow:var(--sh-1);
	min-height:520px;
	overflow:hidden;
}
.portal-shell.firm-shell .ft-grid .ft-pane-list{
	display:flex;
	flex-direction:column;
	min-height:0;
	border-right:1px solid var(--hair);
}
.portal-shell.firm-shell .ft-grid .ft-pane-thread{
	display:flex;
	flex-direction:column;
	min-height:0;
}
.portal-shell.firm-shell .ft-grid .ft-pane-head{
	padding:16px 18px;
	border-bottom:1px solid var(--hair);
	font-size:15px;
	font-weight:700;
	color:var(--blue-ink);
}

/* --- Conversation list rows ------------------------------------------------- */
.portal-shell.firm-shell .ft-thread-list{
	flex:1;
	overflow-y:auto;
	margin:0;
	padding:0;
	list-style:none;
}
.portal-shell.firm-shell .ft-thread-list li{margin:0}
.portal-shell.firm-shell .ft-thread{
	display:block;
	padding:13px 18px;
	border-left:3px solid transparent;
	border-bottom:1px solid var(--grey-50);
	text-decoration:none;
}
.portal-shell.firm-shell .ft-thread:hover{background:var(--grey-50)}
.portal-shell.firm-shell .ft-thread.is-active{
	background:var(--blue-pale);
	border-left-color:var(--blue);
}
.portal-shell.firm-shell .ft-thread-top{
	display:flex;
	justify-content:space-between;
	align-items:baseline;
	gap:8px;
}
.portal-shell.firm-shell .ft-thread .ft-thread-subject{
	font-size:14px;
	font-weight:500;
	color:var(--ink);
	overflow:hidden;
	text-overflow:ellipsis;
	white-space:nowrap;
}
.portal-shell.firm-shell .ft-thread.unread .ft-thread-subject{font-weight:700}
.portal-shell.firm-shell .ft-thread .ft-thread-time{
	flex-shrink:0;
	font-size:11.5px;
	color:var(--mid);
}
.portal-shell.firm-shell .ft-thread .ft-thread-parts{
	margin-top:2px;
	font-size:12px;
	color:var(--mid);
	white-space:nowrap;
	overflow:hidden;
	text-overflow:ellipsis;
}
.portal-shell.firm-shell .ft-thread-bottom{
	display:flex;
	justify-content:space-between;
	align-items:center;
	gap:6px;
	margin-top:3px;
}
.portal-shell.firm-shell .ft-thread .ft-thread-snippet{
	flex:1;
	font-size:12.5px;
	color:var(--mid);
	white-space:nowrap;
	overflow:hidden;
	text-overflow:ellipsis;
}
/* Unread dot — refine the shared .unread-dot back to a plain red dot here
   (the client shell repaints it into a count pill; keep firm scope local). */
.portal-shell.firm-shell .ft-thread .ft-dot{
	flex-shrink:0;
	width:8px;height:8px;
	min-width:0;
	margin:0 0 0 6px;
	padding:0;
	border-radius:50%;
	background:var(--red);
}
.portal-shell.firm-shell .ft-list-empty{padding:40px 18px}

/* --- Conversation header + participant chips -------------------------------- */
.portal-shell.firm-shell .ft-convo-head{
	padding:16px 22px;
	border-bottom:1px solid var(--hair);
}
.portal-shell.firm-shell .ft-convo-subject{
	font-family:'Playfair Display',Georgia,serif;
	font-size:16px;
	font-weight:700;
	color:var(--blue-ink);
	margin:0 0 8px;
}
.portal-shell.firm-shell .ft-chips{
	display:flex;
	gap:6px;
	flex-wrap:wrap;
}
.portal-shell.firm-shell .ft-chip{
	display:inline-flex;
	align-items:center;
	gap:6px;
	background:var(--blue-pale);
	border-radius:var(--r-pill);
	padding:3px 10px 3px 3px;
	font-size:12px;
	font-weight:600;
	color:var(--blue-ink);
}
.portal-shell.firm-shell .ft-chip-av{
	display:inline-flex;
	align-items:center;
	justify-content:center;
	width:20px;height:20px;
	border-radius:50%;
	background:var(--blue-ink);
	color:#fff;
	font-size:9.5px;
	font-weight:700;
}

/* --- Bubbles ---------------------------------------------------------------- */
/* Keep the wired class logic: own message = .client (right), colleague = .firm
   (left). For the internal channel both sides read as blue-wash / white cards. */
.portal-shell.firm-shell .ft-log{
	flex:1;
	overflow-y:auto;
	padding:20px 22px;
	gap:14px;
	background:var(--grey-50);
}
.portal-shell.firm-shell .ft-log .ft-bubble{
	max-width:70%;
	padding:12px 14px;
	font-size:14px;
	line-height:1.5;
	color:var(--ink);
}
.portal-shell.firm-shell .ft-log .ft-bubble p{margin:0}
.portal-shell.firm-shell .ft-log .ft-bubble p + p{margin-top:8px}
.portal-shell.firm-shell .ft-log .ft-bubble.firm{
	align-self:flex-start;
	background:#fff;
	border:1px solid var(--hair);
	border-radius:16px 16px 16px 6px;
}
.portal-shell.firm-shell .ft-log .ft-bubble.client{
	align-self:flex-end;
	background:var(--blue-pale);
	border:none;
	border-radius:16px 16px 6px 16px;
}
.portal-shell.firm-shell .ft-log .ft-bubble .bmeta{
	margin-top:5px;
	font-size:11.5px;
	color:var(--mid);
}
.portal-shell.firm-shell .ft-log .ft-bubble.client .bmeta{text-align:right}

/* --- Reply composer (pinned bottom) ---------------------------------------- */
.portal-shell.firm-shell .ft-reply{
	display:flex;
	align-items:flex-end;
	gap:10px;
	padding:16px 22px;
	border-top:1px solid var(--hair);
}
.portal-shell.firm-shell .ft-reply textarea{
	flex:1;
	min-height:46px;
	padding:10px 12px;
	border:1px solid var(--hair);
	border-radius:8px;
	font-size:14px;
	resize:vertical;
}
.portal-shell.firm-shell .ft-reply textarea:focus{
	border-color:var(--blue);
	box-shadow:0 0 0 3px rgba(38,64,141,.35);
	outline:none;
}
.portal-shell.firm-shell .ft-reply button[type="submit"]{
	display:inline-flex;
	align-items:center;
	gap:8px;
	flex-shrink:0;
	background:var(--red);
	color:#fff;
	border:none;
	border-radius:7px;
	padding:10px 18px;
	font-size:13.5px;
	font-weight:600;
	cursor:pointer;
}
.portal-shell.firm-shell .ft-reply button[type="submit"]:hover{background:var(--red-dark)}

/* --- Empty state ------------------------------------------------------------ */
.portal-shell.firm-shell .ft-pane-thread .ft-empty{
	flex:1;
	display:flex;
	flex-direction:column;
	align-items:center;
	justify-content:center;
	text-align:center;
	padding:40px;
	color:var(--mid);
}
.portal-shell.firm-shell .ft-pane-thread .ft-empty svg{color:var(--blue-pale)}
.portal-shell.firm-shell .ft-pane-thread .ft-empty p{margin:12px 0 0;max-width:280px}

/* --- Responsive: stack the two panes on narrow viewports -------------------- */
@media(max-width:820px){
	.portal-shell.firm-shell .ft-grid{
		grid-template-columns:1fr;
		min-height:0;
	}
	.portal-shell.firm-shell .ft-grid .ft-pane-list{
		border-right:none;
		border-bottom:1px solid var(--hair);
		max-height:320px;
	}
	/* When a thread is open, prioritise the conversation on small screens. */
	.portal-shell.firm-shell .ft-grid.ft-has-active .ft-pane-list{max-height:220px}
	.portal-shell.firm-shell .ft-log{max-height:60vh}
}
