/*
 * RecLite Headless — Attendance
 *
 * Uses ONLY the theme's --reclite-color-primary and --reclite-color-secondary
 * for every accent, tint, and status color. Neutrals come from the shared
 * plugin token vars (--rl-border, --rl-muted, etc.) that reclite-headless.css
 * declares. No hard-coded hues.
 *
 * The four attendance statuses (present/late/excused/absent) are
 * disambiguated by fill-vs-outline + short letter badge + label text, not
 * by hue — WCAG 1.4.1 still holds because color is not the sole channel.
 */

/* Local aliases — makes the file readable and lets us swap the whole
 * palette in one place if the token names change. Fall back to sensible
 * defaults so the CSS still renders in a themeless install (tests). */
.rl-att-section,
.rl-coach-section,
.rl-att-children,
[data-rl="attendance-children-state"] {
	--_p:  var(--reclite-color-primary, #1f6feb);
	--_s:  var(--reclite-color-secondary, #5b6472);
	--_p10: color-mix(in srgb, var(--_p) 10%, transparent);
	--_p18: color-mix(in srgb, var(--_p) 18%, transparent);
	--_p35: color-mix(in srgb, var(--_p) 35%, transparent);
	--_s10: color-mix(in srgb, var(--_s) 10%, transparent);
	--_s18: color-mix(in srgb, var(--_s) 18%, transparent);
	--_s35: color-mix(in srgb, var(--_s) 35%, transparent);
}

/* --------------------------------------------------------------
 * Attendance tab layout
 * -------------------------------------------------------------- */

.rl-att-section { display: grid; gap: 24px; }

.rl-att-embedded {
	background: var(--rl-surface-alt, #f7f8fb);
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 10px;
	padding: 16px;
}

.rl-att-children-head,
.rl-att-history-head,
.rl-coach-roster-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 12px 0;
	flex-wrap: wrap;
}
.rl-att-children-head h4,
.rl-att-history-head h4,
.rl-coach-roster-head h4 {
	margin: 0;
	font-size: 1.05rem;
	line-height: 1.3;
}

/* --------------------------------------------------------------
 * Children cards
 * -------------------------------------------------------------- */

.rl-att-children-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 12px;
}

.rl-att-child {
	position: relative;
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 10px;
	padding: 14px 16px;
	background: var(--rl-surface, #fff);
}
.rl-att-child::before {
	content: "";
	position: absolute;
	left: 0; top: 0; bottom: 0;
	width: 4px;
	border-radius: 10px 0 0 10px;
	background: var(--rl-border, #d8dde7);
}
.rl-att-child.rl-att-child-in::before  { background: var(--_p); }
.rl-att-child.rl-att-child-out::before { background: var(--_s35); }

.rl-att-child-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin: 0 0 8px 0;
}
.rl-att-child-name { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.25; }
.rl-att-child-body { display: grid; gap: 4px; font-size: 0.92rem; }
.rl-att-child-line { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.rl-att-child-lbl {
	color: var(--rl-muted, #5b6472);
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: .02em;
}

/* --------------------------------------------------------------
 * History filters + table
 * -------------------------------------------------------------- */

.rl-att-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: flex-end;
	margin: 0 0 14px 0;
	padding: 12px;
	background: var(--rl-surface-alt, #f7f8fb);
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 8px;
}
.rl-att-filters .rl-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 160px;
	margin: 0;
}
.rl-att-filters .rl-field label {
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--rl-muted, #5b6472);
}
.rl-att-filters .rl-field:last-of-type {
	flex-direction: row;
	gap: 8px;
	align-items: flex-end;
}

.rl-att-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 8px;
	background: var(--rl-surface, #fff);
}
.rl-att-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.rl-att-table caption { text-align: left; padding: 8px 12px; }
.rl-att-table th,
.rl-att-table td {
	padding: 10px 12px;
	border-bottom: 1px solid var(--rl-border, #d8dde7);
	text-align: left;
	vertical-align: middle;
}
.rl-att-table tbody tr:last-child td { border-bottom: 0; }
.rl-att-table tbody tr:hover { background: var(--_p10); }
.rl-att-table th {
	background: var(--rl-surface-alt, #f7f8fb);
	font-weight: 600;
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--rl-muted, #5b6472);
	position: sticky;
	top: 0;
	z-index: 1;
}
.rl-att-table .rl-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --------------------------------------------------------------
 * Status pills — primary/secondary fill vs outline. Text label is
 * the semantic channel; color is decorative.
 * -------------------------------------------------------------- */

.rl-badge {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.4;
	text-transform: capitalize;
	white-space: nowrap;
	border: 1px solid transparent;
}
/* Present — primary FILLED */
.rl-badge.rl-badge-present {
	background: var(--_p);
	color: #fff;
	border-color: var(--_p);
}
/* Late — secondary FILLED */
.rl-badge.rl-badge-late {
	background: var(--_s);
	color: #fff;
	border-color: var(--_s);
}
/* Excused — primary OUTLINE */
.rl-badge.rl-badge-excused {
	background: var(--_p10);
	color: var(--_p);
	border-color: var(--_p);
}
/* Absent — secondary OUTLINE */
.rl-badge.rl-badge-absent {
	background: var(--_s10);
	color: var(--_s);
	border-color: var(--_s);
}
.rl-badge.rl-badge-neutral {
	background: var(--rl-surface-alt, #f7f8fb);
	color: var(--rl-muted, #5b6472);
	border-color: var(--rl-border, #d8dde7);
}

/* --------------------------------------------------------------
 * Coach panel — activity link-cards
 * -------------------------------------------------------------- */

.rl-coach-assignments { margin-bottom: 20px; }
.rl-coach-assignments-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 10px;
}
.rl-coach-assignments-list li { margin: 0; }

.rl-coach-assignment {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 14px;
	width: 100%;
	padding: 14px 16px;
	background: var(--rl-surface, #fff);
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 10px;
	cursor: pointer;
	transition: border-color .12s ease, box-shadow .12s ease, background .12s ease, transform .08s ease;
	user-select: none;
}
.rl-coach-assignment:hover {
	border-color: var(--_p);
	background: var(--_p10);
	box-shadow: 0 2px 8px var(--_p18);
}
.rl-coach-assignment:active { transform: translateY(1px); }
.rl-coach-assignment.is-active {
	border-color: var(--_p);
	background: var(--_p10);
	box-shadow: 0 0 0 3px var(--_p18);
}
.rl-coach-assignment:focus-visible {
	outline: 3px solid var(--_p);
	outline-offset: 2px;
}
.rl-coach-assignment-icon {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--_p10);
	color: var(--_p);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.rl-coach-assignment.is-active .rl-coach-assignment-icon,
.rl-coach-assignment:hover  .rl-coach-assignment-icon {
	background: var(--_p);
	color: #fff;
}
.rl-coach-assignment-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rl-coach-assignment-name {
	font-weight: 600;
	font-size: 1rem;
	line-height: 1.3;
	color: var(--rl-text, #1c222e);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.rl-coach-assignment-hint { font-size: 0.82rem; color: var(--rl-muted, #5b6472); }
.rl-coach-assignment-arrow {
	color: var(--rl-muted, #5b6472);
	display: flex;
	align-items: center;
	transition: transform .12s ease, color .12s ease;
}
.rl-coach-assignment:hover .rl-coach-assignment-arrow,
.rl-coach-assignment.is-active .rl-coach-assignment-arrow {
	color: var(--_p);
	transform: translateX(3px);
}

/* --------------------------------------------------------------
 * Roster host
 * -------------------------------------------------------------- */

.rl-coach-roster-host {
	background: var(--rl-surface, #fff);
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 10px;
	padding: 16px;
}
.rl-coach-roster-host:focus { outline: none; }
.rl-coach-roster-host:focus-visible {
	outline: 3px solid var(--_p);
	outline-offset: 2px;
}

/* --------------------------------------------------------------
 * Segmented radio control (seated / waitlisted / lottery)
 * -------------------------------------------------------------- */

.rl-cr-tabs {
	display: inline-flex;
	gap: 2px;
	padding: 4px;
	margin: 0 0 14px 0;
	background: var(--rl-surface-alt, #f7f8fb);
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 999px;
	max-width: 100%;
	overflow-x: auto;
}
.rl-segment {
	position: relative;
	display: inline-block;
	padding: 6px 16px;
	border-radius: 999px;
	font-size: 0.9rem;
	font-weight: 500;
	color: var(--rl-muted, #5b6472);
	cursor: pointer;
	white-space: nowrap;
	user-select: none;
	transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.rl-segment input[type="radio"] {
	position: absolute;
	opacity: 0;
	pointer-events: none;
	width: 1px; height: 1px;
	margin: 0;
}
.rl-segment:hover {
	color: var(--rl-text, #1c222e);
	background: var(--_p10);
}
.rl-segment.is-active {
	background: var(--_p);
	color: #fff;
	font-weight: 600;
	box-shadow: 0 1px 3px var(--_p35);
}
.rl-segment:has(input:focus-visible) {
	outline: 3px solid var(--_p);
	outline-offset: 2px;
	border-radius: 999px;
}

/* --------------------------------------------------------------
 * Close chip
 * -------------------------------------------------------------- */

.rl-coach-close {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border-radius: 999px;
	background: transparent;
	color: var(--rl-muted, #5b6472);
	text-decoration: none;
	font-size: 0.88rem;
	line-height: 1;
	transition: background .12s ease, color .12s ease;
}
.rl-coach-close:hover {
	background: var(--_s10);
	color: var(--_s);
	text-decoration: none;
}
.rl-coach-close:focus-visible {
	outline: 3px solid var(--_p);
	outline-offset: 2px;
}

/* --------------------------------------------------------------
 * Occurrence input
 * -------------------------------------------------------------- */

.rl-coach-occurrence {
	background: var(--_s10);
	border: 1px solid var(--_s35);
	border-radius: 8px;
	padding: 12px 14px;
	margin: 0 0 14px 0;
}
.rl-coach-occurrence label {
	display: block;
	font-weight: 600;
	font-size: 0.95rem;
	margin-bottom: 6px;
	color: var(--_s);
}
.rl-coach-occurrence input {
	width: 100%;
	max-width: 100%;
	padding: 8px 10px;
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 6px;
	font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
	font-size: 0.92rem;
	background: #fff;
}
.rl-coach-occurrence input:focus-visible {
	outline: 3px solid var(--_p);
	outline-offset: 1px;
}
.rl-coach-occurrence .rl-field-help {
	margin: 6px 0 0 0;
	font-size: 0.82rem;
	color: var(--_s);
	opacity: .85;
}
/* The occurrence picker is a <select> now (Flow G), not a monospace UUID field. */
.rl-coach-occurrence select {
	width: 100%;
	max-width: 100%;
	padding: 8px 10px;
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 6px;
	font-size: 0.95rem;
	background: #fff;
}
.rl-coach-occurrence select:focus-visible {
	outline: 3px solid var(--_p);
	outline-offset: 1px;
}

/* Coach grid controls row: session picker + bulk-mark + summary (Flow G). */
.rl-coach-grid-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 12px 20px;
}
.rl-coach-grid-controls .rl-coach-occurrence {
	flex: 1 1 240px;
	margin-bottom: 0;
}
.rl-coach-bulk {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	padding-bottom: 2px;
}
.rl-coach-bulk-lbl {
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--_s);
}
.rl-coach-grid-summary {
	margin: 10px 0 14px;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--_s);
}
.rl-coach-part-name { font-weight: 600; }
.rl-badge-risk {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 8px;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
	vertical-align: middle;
}
.rl-badge-risk-urgent  { background: #fde5e5; color: #8a1c1c; box-shadow: inset 0 0 0 1px #e0a3a3; }
.rl-badge-risk-chronic { background: #fdeede; color: #8a4b12; box-shadow: inset 0 0 0 1px #e6bf8e; }
@media (forced-colors: active) {
	.rl-badge-risk { border: 1px solid CanvasText; }
}

/* --------------------------------------------------------------
 * Roster table
 * -------------------------------------------------------------- */

.rl-cr-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--rl-border, #d8dde7);
	border-radius: 8px;
}
.rl-cr-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.rl-cr-table th,
.rl-cr-table td {
	padding: 10px 12px;
	border-bottom: 1px solid var(--rl-border, #d8dde7);
	text-align: left;
	vertical-align: middle;
}
.rl-cr-table tbody tr:last-child td { border-bottom: 0; }
.rl-cr-table tbody tr:hover { background: var(--_p10); }
.rl-cr-table th {
	background: var(--rl-surface-alt, #f7f8fb);
	font-weight: 600;
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--rl-muted, #5b6472);
}

/* --------------------------------------------------------------
 * Mark-as pills (four instant actions per row)
 *
 * Two-color palette scheme:
 *   Present → primary FILLED       (positive, strong)
 *   Late    → secondary FILLED     (neutral, still there)
 *   Excused → primary OUTLINE      (acknowledged, softer)
 *   Absent  → secondary OUTLINE    (recorded absence)
 *
 * The letter badge + label are the true semantic channel.
 * -------------------------------------------------------------- */

.rl-mark-pills {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
}
.rl-mark-pills.is-busy { opacity: .55; pointer-events: none; }

.rl-mark-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px 4px 6px;
	border-radius: 999px;
	border: 1px solid var(--rl-border, #d8dde7);
	background: var(--rl-surface, #fff);
	color: var(--rl-text, #1c222e);
	font-size: 0.85rem;
	font-weight: 500;
	line-height: 1.35;
	cursor: pointer;
	user-select: none;
	transition: background .12s ease, border-color .12s ease, color .12s ease, transform .08s ease, box-shadow .12s ease;
}
.rl-mark-pill:hover { border-color: var(--_p); background: var(--_p10); }
.rl-mark-pill:active { transform: translateY(1px); }
.rl-mark-pill:focus-visible {
	outline: 3px solid var(--_p);
	outline-offset: 2px;
}
.rl-mark-pill-short {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--rl-surface-alt, #f7f8fb);
	font-weight: 700;
	font-size: 0.78rem;
	color: var(--rl-muted, #5b6472);
	flex-shrink: 0;
	transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.rl-mark-pill-label { line-height: 1; }

/* Letter-badge only — restore per-status semantic colors so P/L/E/A are
 * instantly distinguishable at a glance. The pill body itself still
 * uses only primary/secondary; this is a small decorative accent on a
 * 22px circle, not the primary visual channel. */
.rl-mark-pill-present  .rl-mark-pill-short { background: #dcf5e3; color: #114a20; box-shadow: inset 0 0 0 1px #4fa06b; }
.rl-mark-pill-late     .rl-mark-pill-short { background: #fdf2c9; color: #6b4c0f; box-shadow: inset 0 0 0 1px #c29a2c; }
.rl-mark-pill-excused  .rl-mark-pill-short { background: #e2ebfa; color: #1c3a72; box-shadow: inset 0 0 0 1px #4a72b7; }
.rl-mark-pill-absent   .rl-mark-pill-short { background: #fde3e3; color: #7a1414; box-shadow: inset 0 0 0 1px #b73a3a; }

/* Current-state — pill body uses primary/secondary. Letter badges are
 * NOT re-tinted here on purpose: the per-status colors above stay
 * fixed so P/L/E/A remain instantly recognisable at a glance. */
.rl-mark-pill-present.is-current {
	background: var(--_p);
	border-color: var(--_p);
	color: #fff;
	box-shadow: 0 0 0 2px var(--_p18);
}
.rl-mark-pill-late.is-current {
	background: var(--_s);
	border-color: var(--_s);
	color: #fff;
	box-shadow: 0 0 0 2px var(--_s18);
}
.rl-mark-pill-excused.is-current {
	background: var(--_p10);
	border-color: var(--_p);
	color: var(--_p);
	box-shadow: inset 0 0 0 1px var(--_p);
}
.rl-mark-pill-absent.is-current {
	background: var(--_s10);
	border-color: var(--_s);
	color: var(--_s);
	box-shadow: inset 0 0 0 1px var(--_s);
}

.rl-mark-pill.is-pending {
	position: relative;
	color: transparent;
}
.rl-mark-pill.is-pending .rl-mark-pill-short,
.rl-mark-pill.is-pending .rl-mark-pill-label { visibility: hidden; }
.rl-mark-pill.is-pending::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 14px; height: 14px;
	border-radius: 50%;
	border: 2px solid var(--_p);
	border-top-color: transparent;
	animation: rl-mp-spin .7s linear infinite;
}
@keyframes rl-mp-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------
 * Empty / pagination
 * -------------------------------------------------------------- */

.rl-att-empty {
	text-align: center;
	padding: 32px 16px;
	color: var(--rl-muted, #5b6472);
	background: var(--rl-surface, #fff);
	border: 1px dashed var(--rl-border, #d8dde7);
	border-radius: 8px;
}
.rl-att-empty svg { display: block; margin: 0 auto 8px; opacity: .55; color: var(--_p); }

/* --------------------------------------------------------------
 * Responsive
 * -------------------------------------------------------------- */

@media (max-width: 720px) {
	.rl-att-filters { padding: 10px; }
	.rl-att-filters .rl-field { flex: 1 1 100%; min-width: 0; }
	.rl-att-filters .rl-field:last-of-type { justify-content: flex-end; }

	.rl-att-table thead { display: none; }
	.rl-att-table, .rl-att-table tbody, .rl-att-table tr, .rl-att-table td { display: block; width: 100%; }
	.rl-att-table tr { padding: 12px; border-bottom: 1px solid var(--rl-border, #d8dde7); }
	.rl-att-table td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; }
	.rl-att-table td::before {
		content: attr(data-lbl);
		font-size: 0.82rem;
		text-transform: uppercase;
		color: var(--rl-muted, #5b6472);
		flex: 0 0 auto;
	}

	.rl-cr-table thead { display: none; }
	.rl-cr-table, .rl-cr-table tbody, .rl-cr-table tr, .rl-cr-table td { display: block; width: 100%; }
	.rl-cr-table tr { padding: 12px; border-bottom: 1px solid var(--rl-border, #d8dde7); }
	.rl-cr-table td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
	.rl-cr-table td::before {
		content: attr(data-lbl);
		font-size: 0.82rem;
		text-transform: uppercase;
		color: var(--rl-muted, #5b6472);
		flex: 0 0 auto;
	}
	.rl-mark-pills { justify-content: flex-end; }
}

/* --------------------------------------------------------------
 * High-contrast forced-colors fallback
 * -------------------------------------------------------------- */

@media (forced-colors: active) {
	.rl-att-child,
	.rl-att-embedded,
	.rl-att-table-wrap,
	.rl-cr-table-wrap,
	.rl-coach-roster-host,
	.rl-coach-assignment,
	.rl-coach-occurrence,
	.rl-mark-pill { border-color: CanvasText; }
	.rl-badge { border-color: CanvasText; }
	.rl-att-child::before { background: CanvasText; }
}
