/*
 * Synergates - styling for the parts of the app the pulled theme does not
 * cover: data tables, stat tiles, forms, modals, badges and the comment
 * thread. Everything here is built from the tokens declared in login.css
 * (--teal, --lime, --ink, --rule, --display, --ui) so it stays in step with
 * the theme. The pulled files are never edited; overrides live here.
 */

:root {
	--teal-tint: #edf5f3;
	--ink-3: #5f6e6a;
	--rule-2: #eef2f1;
	--paper-2: #f7faf9;
}

body {
	margin: 0;
	font-family: var(--ui);
	color: var(--ink);
	background: var(--paper);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------- */
/* sidebar bits the theme styles as links but we render as buttons        */
/* --------------------------------------------------------------------- */

button.nav-out {
	width: 100%;
	border: 0;
	background: none;
	font-family: inherit;
	text-align: left;
	cursor: pointer;
}

/* --------------------------------------------------------------------- */
/* page frame                                                             */
/*                                                                        */
/* account.css defines .page at 46rem for a record sheet; the list        */
/* screens need the full width, hence the modifier.                       */
/* --------------------------------------------------------------------- */

.page-wide { max-width: none; }

.page-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 1rem;
}

.page-head > div { min-width: 0; }

.spinner,
.empty {
	padding: 3rem 0;
	font-family: var(--display);
	font-variation-settings: "opsz" 18;
	font-size: 1.0625rem;
	color: var(--ink-3);
}

/* --------------------------------------------------------------------- */
/* buttons                                                                */
/* --------------------------------------------------------------------- */

.btn {
	padding: 0.55rem 1rem;
	border: 1px solid var(--rule);
	border-radius: 3px;
	background: var(--paper);
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--ink);
	cursor: pointer;
	transition: background-color 0.14s ease, border-color 0.14s ease;
}

.btn:hover:not(:disabled) { background: var(--paper-2); border-color: #c2ccc9; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn:focus-visible {
	outline: 2px solid var(--teal);
	outline-offset: 2px;
}

.btn-primary {
	border-color: var(--teal);
	background: var(--teal);
	color: var(--paper);
}

.btn-primary:hover:not(:disabled) { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-primary:active:not(:disabled) { background: var(--teal-darker); }

.btn-small { padding: 0.3rem 0.6rem; font-size: 0.8125rem; }

/* Row actions mix <button> with react-router <Link>. An anchor needs the
   button look spelled out, because the theme underlines and tints links. */
a.btn,
a.btn:hover {
	display: inline-block;
	text-decoration: none;
	color: var(--ink);
}

.btn-link {
	padding: 0;
	border: 0;
	background: none;
	font-family: inherit;
	font-size: inherit;
	color: var(--teal);
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.btn-link:hover { color: var(--teal-darker); }

.row-actions {
	display: flex;
	gap: 0.4rem;
	white-space: nowrap;
}

/* Square icon action. The label lives in title/aria-label, so the button has
   to stay big enough to hit comfortably without text to give it width. */
.btn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	color: var(--ink);
}

.btn-icon:hover:not(:disabled) { color: var(--teal-darker); }

a.btn-icon,
a.btn-icon:hover { display: inline-flex; }

/* A name in a table is a link to that person's profile; keep it quiet until
   hovered so a column of names does not read as a wall of blue. */
.data-table a {
	color: var(--ink);
	text-decoration: none;
	border-bottom: 1px solid transparent;
}

.data-table a:hover {
	color: var(--teal-darker);
	border-bottom-color: currentColor;
}

/* Said on somebody else's profile. */
.profile-readonly {
	margin: 0 0 1.5rem;
	font-size: 0.8125rem;
	color: #77857f;
}

/* --------------------------------------------------------------------- */
/* stat tiles                                                             */
/* --------------------------------------------------------------------- */

.stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
	gap: 1px;
	margin: 0 0 2.75rem;
	background: var(--rule-2);
	border: 1px solid var(--rule-2);
}

.stat-tile {
	padding: 1.1rem 1.25rem 1.25rem;
	background: var(--paper);
}

.stat-tile .value {
	font-family: var(--display);
	font-variation-settings: "opsz" 36;
	font-size: 2rem;
	font-weight: 400;
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--ink);
}

.stat-tile .label {
	margin-top: 0.4rem;
	font-size: 0.8125rem;
	line-height: 1.4;
	color: var(--ink-3);
}

/* A hairline above the number, in the tile's accent colour. Untoned tiles
   keep a neutral rule so the top edge of the band stays continuous. */
.stat-tile { border-top: 2px solid var(--rule); }
.stat-tile.green { border-top-color: var(--lime); }
.stat-tile.blue  { border-top-color: var(--teal); }
.stat-tile.grey  { border-top-color: #cfd8d5; }

.progress-bar {
	min-width: 5rem;
	height: 4px;
	border-radius: 2px;
	background: var(--rule-2);
	overflow: hidden;
}

.progress-bar > span {
	display: block;
	height: 100%;
	background: var(--teal);
}

/* --------------------------------------------------------------------- */
/* section headings, matching .rec h2 from account.css                    */
/* --------------------------------------------------------------------- */

.section-title {
	margin: 0 0 1rem;
	font-size: 0.875rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--teal-field);
}

/* --------------------------------------------------------------------- */
/* tables                                                                 */
/*                                                                        */
/* Hairline rules rather than a filled header bar, to match the record     */
/* sheets in account.css.                                                  */
/* --------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.data-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9375rem;
	text-align: left;
}

.data-table th {
	padding: 0 0.75rem 0.6rem;
	border-bottom: 1px solid var(--rule);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ink-3);
	white-space: nowrap;
}

.data-table td {
	padding: 0.7rem 0.75rem;
	border-bottom: 1px solid var(--rule-2);
	vertical-align: middle;
	line-height: 1.45;
}

.data-table th:first-child,
.data-table td:first-child { padding-left: 0; }

.data-table th:last-child,
.data-table td:last-child { padding-right: 0; }

.data-table tbody tr:hover { background: var(--paper-2); }

.data-table .num {
	font-variant-numeric: tabular-nums;
	color: var(--ink-3);
}

/* --------------------------------------------------------------------- */
/* status + colour marking                                                */
/* --------------------------------------------------------------------- */

.status-badge {
	display: inline-block;
	padding: 0.15rem 0.55rem;
	border-radius: 2px;
	font-size: 0.75rem;
	font-weight: 500;
	line-height: 1.5;
	white-space: nowrap;
}

.status-PENDING      { background: var(--rule-2); color: var(--ink-3); }
.status-IN_PROGRESS  { background: #fdf6ee; color: #7f4a11; }
.status-COMPLETED    { background: var(--teal-tint); color: #0a4a41; }
.status-NON_RESPONSE { background: #f4f1e6; color: #6b6320; }
.status-REFUSED      { background: #fdf1f0; color: #8c1d18; }
.status-CANCELLED    { background: var(--rule-2); color: #9aa5a2; text-decoration: line-through; }

/* The colour flag a user puts on a row: data, not chrome, so these keep
   their own hues rather than following the teal palette. */
.color-dot {
	display: inline-block;
	width: 0.85rem;
	height: 0.85rem;
	padding: 0;
	border: 1px solid rgba(27, 34, 32, 0.18);
	border-radius: 50%;
	vertical-align: middle;
}

.color-GREY   { background: #9aa5a2; }
.color-GREEN  { background: #4f9d5d; }
.color-YELLOW { background: #d8c02e; }
.color-ORANGE { background: #d98324; }
.color-RED    { background: #b3261e; }
.color-BLUE   { background: #2f6fa8; }

.color-picker {
	display: flex;
	gap: 0.3rem;
	align-items: center;
}

.color-picker button {
	cursor: pointer;
	transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.color-picker button:hover:not(:disabled) { transform: scale(1.15); }

.color-picker button.selected {
	box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--ink);
}

.color-picker button:focus-visible {
	outline: 2px solid var(--teal);
	outline-offset: 2px;
}

/* --------------------------------------------------------------------- */
/* forms - underlined fields, matching the login screen                   */
/* --------------------------------------------------------------------- */

.form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
	gap: 1.5rem 1.75rem;
}

.form-field label {
	display: block;
	margin-bottom: 0.4rem;
	font-size: 0.8125rem;
	font-weight: 500;
	color: var(--ink);
}

.form-field input,
.form-field select,
.form-field textarea {
	width: 100%;
	padding: 0.4rem 2px 0.5rem;
	border: 0;
	border-bottom: 1px solid var(--rule);
	border-radius: 0;
	background: transparent;
	font-family: inherit;
	font-size: 0.9375rem;
	color: var(--ink);
	transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.form-field textarea {
	padding: 0.5rem 0.6rem;
	border: 1px solid var(--rule);
	border-radius: 3px;
	line-height: 1.5;
	resize: vertical;
}

.form-field input::placeholder,
.form-field textarea::placeholder { color: #9aa5a2; }

.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover { border-color: #c2ccc9; }

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
	outline: 0;
	border-color: var(--teal);
	box-shadow: 0 1px 0 0 var(--teal);
}

.form-field textarea:focus { box-shadow: 0 0 0 1px var(--teal); }

.form-field input[type="checkbox"] {
	width: auto;
	padding: 0;
	accent-color: var(--teal);
}

/* Explanatory line under an input, e.g. what the LimeSurvey code is for. */
.field-hint {
	margin: 0.35rem 0 0;
	font-size: 0.75rem;
	line-height: 1.45;
	color: #77857f;
}

/* Compact select used inline in a table cell. */
.cell-select {
	padding: 0.2rem 0.1rem 0.25rem;
	border: 0;
	border-bottom: 1px solid var(--rule);
	border-radius: 0;
	background: transparent;
	font-family: inherit;
	font-size: 0.8125rem;
	color: var(--ink);
}

.cell-select:focus {
	outline: 0;
	border-bottom-color: var(--teal);
	box-shadow: 0 1px 0 0 var(--teal);
}

.form-actions {
	display: flex;
	gap: 0.75rem;
	margin-top: 2rem;
}

/* "back to the unfiltered list" link above a narrowed table */
.filter-back {
	margin: 0 0 1.75rem;
	font-size: 0.875rem;
}

.filters {
	display: flex;
	gap: 1.25rem;
	flex-wrap: wrap;
	align-items: flex-end;
	padding-bottom: 1.75rem;
	margin-bottom: 1.75rem;
	border-bottom: 1px solid var(--rule);
}

.filters .form-field { min-width: 11rem; }

/* --------------------------------------------------------------------- */
/* notices - .notice/.notice-* come from login.css, these are the extras  */
/* --------------------------------------------------------------------- */

.notice-success {
	border-color: #4f9d5d;
	background: #f0f7f1;
	color: #2f6b34;
}

/* --------------------------------------------------------------------- */
/* modal                                                                  */
/* --------------------------------------------------------------------- */

.modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 3rem 1rem;
	overflow-y: auto;
	background: rgba(11, 34, 29, 0.42);
}

.modal {
	width: 100%;
	max-width: 46rem;
	background: var(--paper);
	border-radius: 4px;
	box-shadow: 0 12px 48px rgba(11, 34, 29, 0.28);
}

.modal-header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.5rem 2rem 1.25rem;
	border-bottom: 1px solid var(--rule);
}

.modal-header h3 {
	margin: 0;
	font-family: var(--display);
	font-variation-settings: "opsz" 24;
	font-size: 1.375rem;
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: -0.015em;
	color: var(--ink);
}

.modal-close {
	flex: none;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	border-radius: 3px;
	background: transparent;
	font-size: 1.5rem;
	line-height: 1;
	color: var(--ink-2);
	cursor: pointer;
}

.modal-close:hover { background: var(--rule-2); color: var(--ink); }

.modal-close:focus-visible {
	outline: 2px solid var(--teal);
	outline-offset: 2px;
}

.modal-body { padding: 1.75rem 2rem 2rem; }

/* --------------------------------------------------------------------- */
/* comment thread                                                         */
/* --------------------------------------------------------------------- */

.comment-thread {
	max-height: 24rem;
	overflow-y: auto;
	margin-bottom: 2rem;
}

.comment {
	padding: 0.85rem 0 0.9rem 0.9rem;
	border-top: 1px solid var(--rule-2);
	border-left: 2px solid transparent;
}

.comment:first-child { border-top: 0; }

/* The signed-in user's own messages, so a thread reads like a conversation. */
.comment.own { border-left-color: var(--lime); background: #fcfdf7; }

.comment .meta {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 0.3rem;
	font-size: 0.75rem;
	color: var(--ink-2);
}

.comment .meta .author { font-weight: 500; color: var(--ink-3); }

.comment {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.comment-content {
	flex: 1;
	min-width: 0;
}

/* A bare icon, centred on the whole comment rather than boxed like a button. */
.comment-delete {
	display: inline-flex;
	flex: none;
	padding: 0.25rem;
	border: 0;
	background: none;
	color: var(--ink-2);
	cursor: pointer;
}

.comment-delete:hover { color: var(--teal-darker); }

.comment-delete:focus-visible {
	outline: 2px solid var(--teal);
	outline-offset: 2px;
}

.comment .body {
	font-size: 0.9375rem;
	line-height: 1.5;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

@media (max-width: 760px) {
	.modal-header { padding: 1.25rem 1.5rem 1rem; }
	.modal-body { padding: 1.5rem; }
	.filters { gap: 1rem; }
}

/* --------------------------------------------------------------------- */
/* collapsible block inside a .rec section                                */
/*                                                                        */
/* A native <details>; the browser's marker is replaced by a chevron so it */
/* sits at the weight of the row-action icons.                            */
/* --------------------------------------------------------------------- */

.collapsible { margin-top: 1.5rem; }

.collapsible > summary {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	cursor: pointer;
	list-style: none;
	font-size: 0.875rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--teal-field);
}

.collapsible > summary::-webkit-details-marker { display: none; }

.collapsible > summary:focus-visible {
	outline: 2px solid var(--teal);
	outline-offset: 2px;
}

.collapsible-chevron { transition: transform 0.15s ease; }

.collapsible[open] .collapsible-chevron { transform: rotate(90deg); }

.collapsible > .stat-grid,
.collapsible > .table-wrap,
.collapsible > .collapsible-empty { margin-top: 1rem; }

/* An empty result is a passing remark here, not the page-sized .notfound. */
.collapsible-empty {
	margin-bottom: 0;
	font-size: 0.875rem;
	color: #7d8a87;
}

/* --------------------------------------------------------------------- */
/* sync spinner beside a survey's section title                           */
/* --------------------------------------------------------------------- */

.survey-title {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.sync-spinner {
	display: inline-flex;
	color: var(--teal);
	animation: sync-spin 0.9s linear infinite;
}

@keyframes sync-spin {
	to { transform: rotate(360deg); }
}

/* Still shown, just not spinning, for anyone who has asked for less motion. */
@media (prefers-reduced-motion: reduce) {
	.sync-spinner { animation: none; }
}

/* --------------------------------------------------------------------- */
/* contact log                                                            */
/* --------------------------------------------------------------------- */

.contact-code {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	font-variant-numeric: tabular-nums;
}

.contact-lock {
	display: inline-flex;
	color: var(--teal);
}

.contact-log > .form-actions,
.contact-form { margin-top: 1.25rem; }

/* The fields stack with no gap of their own, which left the code's label
   pressed against the date input above it. */
.contact-form .form-field + .form-field { margin-top: 1.25rem; }

.contact-form .form-field label {
	margin-bottom: 0.5rem;
	font-size: 0.9375rem;
}

/* A short log read at a glance, so no rules between rows and a larger type
   than the main tables; the date gets room to stand apart from its code. */
.contact-log .data-table { font-size: 1.0625rem; }

.contact-log .data-table th { font-size: 0.8125rem; }

.contact-log .data-table th,
.contact-log .data-table td { border-bottom: 0; }

.contact-log .data-table tbody tr:hover { background: none; }

.contact-log .data-table td:first-child,
.contact-log .data-table th:first-child { padding-right: 2rem; white-space: nowrap; }

/* A contact's own note, under the code's description it qualifies. */
.contact-comment {
	margin-top: 0.25rem;
	font-size: 0.9375rem;
	color: var(--ink-3);
	white-space: pre-wrap;
}

/* --------------------------------------------------------------------- */
/* participation details popup: record | contacts and comments            */
/* --------------------------------------------------------------------- */

.detail-layout {
	display: grid;
	/* minmax(0, …) and min-width: 0 pin the split at 2:3. With plain fr
	   tracks a long contact log claimed width from the record column; now it
	   scrolls inside its own .table-wrap instead. */
	grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
	gap: 2.5rem;
	align-items: start;
}

.detail-layout > * { min-width: 0; }

/* Beside the record the log reads at the record's size, not the larger type
   the contacts popup gives it. */
.detail-layout .contact-log .data-table { font-size: 0.9375rem; }

.detail-layout .contact-log .data-table th { font-size: 0.75rem; }

/* The record is a narrow column here; the theme's label column is sized
   for a full-width sheet. */
.detail-layout .rec dl { grid-template-columns: 9.5rem 1fr; }

@media (max-width: 960px) {
	.detail-layout { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------- */
/* status dots                                                            */
/*                                                                        */
/* Saturated versions of the status badge hues, so a dot and a badge for   */
/* the same status read as the same thing - except NON_RESPONSE, blue by   */
/* request so it does not sit between in-progress orange and refused red.  */
/* --------------------------------------------------------------------- */

.status-dot {
	display: inline-block;
	flex: none;
	width: 0.7rem;
	height: 0.7rem;
	border-radius: 50%;
}

.status-dot-PENDING      { background: #a9b3b0; }
.status-dot-IN_PROGRESS  { background: #e0952f; }
.status-dot-COMPLETED    { background: #2e9e6a; }
.status-dot-NON_RESPONSE { background: #2f6fbf; }
.status-dot-REFUSED      { background: #c8372d; }
.status-dot-CANCELLED    { background: #3d4744; }

.status-cell {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
}

/* The latest contact's description, cut short beside its code. One line,
   left-aligned: a narrow table must not wrap it under the code or centre the
   code in the cell. */
.last-contact {
	display: inline-flex;
	align-items: center;
	white-space: nowrap;
	text-align: left;
}

.contact-summary {
	margin-left: 0.5rem;
	white-space: nowrap;
}

/* Completed in LimeSurvey: a tick in the completed status's green. */
.ls-done {
	display: inline-flex;
	color: #2e9e6a;
}
