/**
 * TCHM Portal - main stylesheet.
 *
 * Branded to the Monkey & River (MnR) design system: Poppins + the MnR palette.
 * Plain, dependency-free CSS. Organised as: tokens, base, layout, components.
 * Everything is namespaced under `.tchm-` to avoid collisions.
 *
 * Colour roles (per MnR tokens):
 *   primary   (slate)  : top nav, headings, primary buttons
 *   secondary (blue)   : links, focus rings, secondary actions
 *   accent    (purple) : highlights, active states, MnR replies
 * Status/priority badges keep functional amber (in progress / high) and green
 * (done) for at-a-glance legibility, layered on top of the brand hues.
 */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ------------------------------------------------------------------ *
 * Design tokens
 * ------------------------------------------------------------------ */
:root {
	/* --- MnR design system tokens ------------------------------------ */
	--mnr-primary: #404A56;         /* dark slate: nav, headings, primary buttons */
	--mnr-secondary: #5E98E6;       /* blue: links, focus rings, secondary actions */
	--mnr-accent: #995BFC;          /* purple: badges, highlights, active states */
	--mnr-accent-light: #C49FFF;    /* purple light: hover states on accent */
	--mnr-secondary-light: #9AC5FF; /* blue light: hover states on secondary */
	--mnr-bg: #F5F6F8;              /* page background */
	--mnr-surface: #FFFFFF;         /* card/form background */
	--mnr-foreground: #1A1E24;      /* body text */
	--mnr-muted: #6B7280;           /* secondary text, placeholders */
	--mnr-border: #E5E7EB;          /* input borders, dividers */
	--mnr-danger: #EF4444;          /* errors, destructive actions */
	--mnr-sidebar: #404A56;         /* sidebar/nav background */
	--mnr-sidebar-fg: #F5F6F8;      /* sidebar text */
	--mnr-sidebar-accent: #4E5A68;  /* sidebar hover state */

	/* --- Derived tints used by components --------------------------- */
	--mnr-primary-dark: #333B45;    /* primary button hover */
	--mnr-secondary-soft: #E9F1FD;  /* blue tint background */
	--mnr-accent-soft: #F2EAFE;     /* purple tint background */
	--mnr-danger-soft: #FDECEC;     /* red tint background */
	--mnr-focus: rgba(94, 152, 230, .28); /* focus ring glow (secondary) */
	--mnr-warn-bg: #FFF4D6;         /* functional amber: in progress / high */
	--mnr-warn-fg: #9A6A00;
	--mnr-ok-bg: #E3F5EA;           /* functional green: done */
	--mnr-ok-fg: #1F8A4C;

	/* --- Legacy aliases -------------------------------------------------
	 * The templates were built against `--tchm-*` names. Re-point them at
	 * the MnR palette so every rule inherits the rebrand, then override the
	 * handful of components that need the primary/secondary/accent split. */
	--tchm-bg: var(--mnr-bg);
	--tchm-surface: var(--mnr-surface);
	--tchm-border: var(--mnr-border);
	--tchm-text: var(--mnr-foreground);
	--tchm-muted: var(--mnr-muted);
	--tchm-primary: var(--mnr-primary);
	--tchm-primary-dark: var(--mnr-primary-dark);
	--tchm-primary-soft: var(--mnr-secondary-soft);
	--tchm-danger: var(--mnr-danger);
	--tchm-danger-soft: var(--mnr-danger-soft);

	--tchm-radius: 10px;
	--tchm-radius-sm: 6px;
	--tchm-shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 8px 24px rgba(20, 30, 60, .06);
	--tchm-maxw: 1080px;
	--tchm-maxw-narrow: 760px;
	--tchm-font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ------------------------------------------------------------------ *
 * Base
 * ------------------------------------------------------------------ */
* { box-sizing: border-box; }

body.tchm-app,
body.tchm-bare {
	margin: 0;
	font-family: var(--tchm-font);
	color: var(--mnr-foreground);
	background: var(--mnr-bg);
	line-height: 1.55;
	font-weight: 400;
	-webkit-font-smoothing: antialiased;
}

a { color: var(--mnr-secondary); text-decoration: none; }
a:hover { color: var(--mnr-secondary); text-decoration: underline; }

h1, h2, h3, h4 {
	line-height: 1.2;
	margin: 0 0 .4em;
	font-weight: 600;
	color: var(--mnr-primary);
}

.tchm-main { display: block; }

/* Admin toolbar is hidden sitewide (see show_admin_bar filter in functions.php);
   neutralise the space core normally reserves for it. */
html { margin-top: 0 !important; }
#wpadminbar { display: none !important; }

/* ------------------------------------------------------------------ *
 * Top bar / footer
 * ------------------------------------------------------------------ */
.tchm-topbar {
	background: var(--mnr-sidebar);
	border-bottom: 1px solid var(--mnr-sidebar-accent);
	position: sticky;
	top: 0;
	z-index: 20;
}
.tchm-topbar__inner {
	max-width: var(--tchm-maxw);
	margin: 0 auto;
	padding: 0 24px;
	height: 62px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.tchm-brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; }
.tchm-brand:hover { text-decoration: none; }
.tchm-brand__mark {
	font-weight: 700;
	letter-spacing: .04em;
	color: var(--mnr-sidebar-fg);
	font-size: 20px;
}
.tchm-brand__sub { color: rgba(245, 246, 248, .6); font-size: 13px; }

/* Co-branded nav brand: MnR logo | "TCHM Portal". */
.tchm-nav-brand { display: flex; align-items: center; gap: 0; text-decoration: none; }
.tchm-nav-brand:hover { text-decoration: none; }
.tchm-nav-brand img { height: 32px; width: auto; display: block; }
.tchm-nav-brand-divider {
	width: 1px;
	height: 20px;
	background: rgba(245, 246, 248, 0.3);
	margin: 0 12px;
}
.tchm-nav-brand-name {
	font-family: "Poppins", sans-serif;
	font-weight: 600;
	font-size: 15px;
	color: #fff;
	letter-spacing: 0.01em;
}

.tchm-nav { display: flex; align-items: center; gap: 22px; }
.tchm-nav a { color: var(--mnr-sidebar-fg); font-size: 14px; font-weight: 500; }
.tchm-nav a:hover { color: var(--mnr-secondary-light); text-decoration: none; }
.tchm-nav__logout { color: rgba(245, 246, 248, .65) !important; }
.tchm-nav__logout:hover { color: var(--mnr-secondary-light) !important; }

.tchm-footer {
	border-top: 1px solid var(--mnr-border);
	margin-top: 48px;
	background: var(--mnr-surface);
}
.tchm-footer__inner {
	max-width: var(--tchm-maxw);
	margin: 0 auto;
	padding: 20px 24px;
	display: flex;
	justify-content: space-between;
	font-size: 13px;
	color: var(--mnr-muted);
}

/* ------------------------------------------------------------------ *
 * Layout containers
 * ------------------------------------------------------------------ */
.tchm-container {
	max-width: var(--tchm-maxw);
	margin: 0 auto;
	padding: 36px 24px;
}
.tchm-container--narrow { max-width: var(--tchm-maxw-narrow); }

.tchm-page-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 28px;
}
.tchm-page-head__title { font-size: 26px; margin: 0; }
.tchm-page-head__sub { color: var(--mnr-muted); margin: 4px 0 0; }

.tchm-section-title { font-size: 16px; margin: 0 0 12px; }
.tchm-muted { color: var(--mnr-muted); }
.tchm-back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 500;
	color: var(--mnr-muted);
	text-decoration: none;
	padding: 6px 12px;
	border-radius: 99px;
	background: #fff;
	border: 1px solid var(--mnr-border);
	transition: all 150ms ease;
	margin-bottom: 20px;
}
.tchm-back:hover {
	color: var(--mnr-primary);
	border-color: var(--mnr-primary);
	background: #fff;
	text-decoration: none;
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */
.tchm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 18px;
	border-radius: var(--tchm-radius-sm);
	border: 1px solid transparent;
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	text-decoration: none;
	transition: background .15s, border-color .15s, color .15s;
}
.tchm-btn:hover { text-decoration: none; }
.tchm-btn--primary { background: var(--mnr-primary); color: #fff; }
.tchm-btn--primary:hover { background: var(--mnr-primary-dark); color: #fff; }
.tchm-btn--ghost { background: transparent; color: var(--mnr-muted); border-color: var(--mnr-border); }
.tchm-btn--ghost:hover { color: var(--mnr-secondary); border-color: var(--mnr-secondary); }
.tchm-btn--block { width: 100%; }

/* ------------------------------------------------------------------ *
 * Cards / auth
 * ------------------------------------------------------------------ */
.tchm-card,
.tchm-form--card {
	background: var(--mnr-surface);
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius);
	box-shadow: var(--tchm-shadow);
	padding: 24px;
}
.tchm-card { margin-bottom: 24px; }

.tchm-auth {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}
.tchm-auth__card {
	width: 100%;
	max-width: 400px;
	background: var(--mnr-surface);
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius);
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07),
		0 10px 40px -8px rgba(64, 74, 86, 0.15);
	padding: 36px 32px;
}
.tchm-auth__brand { text-align: center; margin-bottom: 20px; }
.tchm-auth__mark { font-weight: 700; font-size: 26px; letter-spacing: .04em; color: var(--mnr-primary); }
.tchm-auth__tagline { color: var(--mnr-muted); font-size: 13px; margin: 2px 0 0; }
.tchm-auth__title { font-size: 22px; text-align: center; margin: 0 0 4px; }
.tchm-auth__lead { text-align: center; color: var(--mnr-muted); margin: 0 0 22px; font-size: 14px; }

/* Co-branding: TCHM logo hero + "Client Portal" label. */
.tchm-login-logo {
	display: block;
	margin: 0 auto 24px;
	max-width: 180px;
	height: auto;
}
.tchm-login-label {
	font-family: "Poppins", sans-serif;
	font-weight: 400;
	font-size: 13px;
	color: var(--mnr-muted);
	text-align: center;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	margin: 0 0 32px;
}

/* Quiet MnR footer credit on the login card. */
.tchm-login-powered {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	margin-top: 24px;
	padding-top: 20px;
	border-top: 1px solid var(--mnr-border);
}
.tchm-login-powered img {
	max-width: 100px;
	height: auto;
	opacity: 0.6;
}
.tchm-login-powered span {
	font-family: "Poppins", sans-serif;
	font-weight: 400;
	font-size: 11px;
	color: var(--mnr-muted);
	letter-spacing: 0.04em;
	text-align: center;
}

/* ------------------------------------------------------------------ *
 * Forms
 * ------------------------------------------------------------------ */
.tchm-field { margin-bottom: 16px; }
.tchm-field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--mnr-foreground); }
.tchm-field input[type="text"],
.tchm-field input[type="url"],
.tchm-field input[type="date"],
.tchm-field input[type="password"],
.tchm-field input[type="file"],
.tchm-field select,
.tchm-field textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius-sm);
	font-family: inherit;
	font-size: 14px;
	background: #fff;
	color: var(--mnr-foreground);
}
.tchm-field textarea { resize: vertical; }
.tchm-field input::placeholder,
.tchm-field textarea::placeholder { color: var(--mnr-muted); }
.tchm-field input:focus,
.tchm-field select:focus,
.tchm-field textarea:focus {
	outline: none;
	border-color: var(--mnr-secondary);
	box-shadow: 0 0 0 3px var(--mnr-focus);
}
.tchm-hint { font-size: 12px; color: var(--mnr-muted); margin: 6px 0 0; }

/* Styled file upload drop zone (page-submit.php). The real file input is laid
   over the whole zone at opacity 0, so clicking or dropping anywhere works. */
.tchm-upload-zone {
	position: relative;
	border: 2px dashed var(--mnr-secondary);
	border-radius: 8px;
	background: var(--mnr-bg);
	padding: 32px 24px;
	text-align: center;
	cursor: pointer;
	transition: border-color 150ms ease, background 150ms ease;
}
.tchm-upload-zone:hover {
	border-color: var(--mnr-accent);
	background: rgba(153, 91, 252, 0.04);
}
.tchm-upload-zone input[type="file"] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
}
.tchm-upload-icon { font-size: 28px; line-height: 1; color: var(--mnr-secondary); margin-bottom: 8px; }
.tchm-upload-label { font-size: 14px; font-weight: 600; color: var(--mnr-primary); margin: 0 0 4px; }
.tchm-upload-hint { font-size: 12px; color: var(--mnr-muted); margin: 0; }

/* Selected-file preview (populated by assets/js/main.js). */
.tchm-upload-preview {
	list-style: none;
	margin: 12px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.tchm-upload-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 10px;
	background: var(--mnr-bg);
	border: 1px solid var(--mnr-border);
	border-radius: 8px;
}
.tchm-upload-item__thumb {
	width: 40px;
	height: 40px;
	flex-shrink: 0;
	border-radius: 6px;
	border: 1px solid var(--mnr-border);
	background: #fff;
	object-fit: cover;
}
.tchm-upload-item__thumb--file {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
}
.tchm-upload-item__meta {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}
.tchm-upload-item__name {
	font-size: 13px;
	font-weight: 500;
	color: var(--mnr-foreground);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tchm-upload-item__size { font-size: 12px; color: var(--mnr-muted); }
.tchm-upload-item__size--over { color: var(--mnr-danger); font-weight: 600; }
.tchm-upload-item__remove {
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--mnr-muted);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	transition: background 150ms ease, color 150ms ease;
}
.tchm-upload-item__remove:hover { background: var(--mnr-danger-soft); color: var(--mnr-danger); }

/* ------------------------------------------------------------------ *
 * Form validation (submit form)
 * The field group wrapper is .tchm-field (the brief's ".tchm-form-group").
 * ------------------------------------------------------------------ */
.tchm-field--error {
	border-color: var(--mnr-danger) !important;
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}
.tchm-field--valid { border-color: #10B981 !important; } /* optional success state */
.tchm-field-error {
	display: block;
	min-height: 16px;
	margin-top: 4px;
	font-family: "Poppins", sans-serif;
	font-size: 12px;
	color: var(--mnr-danger);
}
.tchm-field.has-error label { color: var(--mnr-danger); }
/* The real file input is a transparent overlay, so flag the drop zone itself. */
.tchm-field.has-error .tchm-upload-zone { border-color: var(--mnr-danger); }

.tchm-form-error-summary {
	display: none;
	margin-bottom: 24px;
	padding: 16px 20px;
	background: #FEF2F2;
	border: 1px solid #FECACA;
	border-radius: 8px;
}
.tchm-form-error-summary.is-visible { display: block; }
.tchm-form-error-summary strong {
	font-family: "Poppins", sans-serif;
	font-size: 14px;
	color: #991B1B;
}
.tchm-error-list {
	margin: 8px 0 0 0;
	padding-left: 20px;
	font-family: "Poppins", sans-serif;
	font-size: 13px;
	color: #B91C1C;
}
.tchm-error-list li { margin-bottom: 4px; }

.tchm-priority-hint {
	margin-top: 6px;
	padding: 8px 12px;
	font-size: 12px;
	font-style: italic;
	color: var(--mnr-muted);
	background: var(--mnr-bg);
	border-radius: 6px;
	border-left: 3px solid var(--mnr-secondary);
	opacity: 0;
	transition: opacity 200ms ease;
}
.tchm-priority-hint.is-visible { opacity: 1; }
.tchm-req { color: var(--mnr-danger); }

.tchm-check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 18px; }
.tchm-check input { width: auto; accent-color: var(--mnr-secondary); }

.tchm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.tchm-fieldset {
	border: none;
	padding: 0 0 32px;
	margin: 0 0 32px;
	border-bottom: 1px solid var(--mnr-border);
}
.tchm-fieldset:last-of-type {
	padding-bottom: 0;
	margin-bottom: 0;
	border-bottom: none;
}
.tchm-fieldset legend {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--mnr-muted);
	padding: 0;
	margin: 0 0 12px;
	width: 100%;
}

.tchm-form__actions { display: flex; gap: 12px; margin-top: 24px; }

/* ------------------------------------------------------------------ *
 * Alerts
 * ------------------------------------------------------------------ */
.tchm-alert {
	padding: 12px 14px;
	border-radius: var(--tchm-radius-sm);
	font-size: 14px;
	margin-bottom: 18px;
}
.tchm-alert--error { background: var(--mnr-danger-soft); color: var(--mnr-danger); }

/* ------------------------------------------------------------------ *
 * Admin filter bar (dashboard, administrators only)
 * ------------------------------------------------------------------ */
.tchm-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 16px;
	padding: 16px 18px;
	margin-bottom: 20px;
	background: var(--mnr-surface);
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius);
	box-shadow: var(--tchm-shadow);
}
.tchm-filters__field { display: flex; flex-direction: column; gap: 6px; min-width: 180px; flex: 1 1 180px; }
.tchm-filters__field label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: var(--mnr-muted);
}
.tchm-filters__field select {
	padding: 9px 12px;
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius-sm);
	font-family: inherit;
	font-size: 14px;
	background: #fff;
	color: var(--mnr-foreground);
}
.tchm-filters__field select:focus {
	outline: none;
	border-color: var(--mnr-secondary);
	box-shadow: 0 0 0 3px var(--mnr-focus);
}
.tchm-filters__actions { display: flex; align-items: center; gap: 10px; }

/* Admin-only "Submitted By" cell. */
.tchm-row__user { color: var(--mnr-foreground); }

/* ------------------------------------------------------------------ *
 * Table (dashboard)
 * ------------------------------------------------------------------ */
.tchm-table-wrap {
	background: var(--mnr-surface);
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius);
	box-shadow: var(--tchm-shadow);
	overflow: hidden;
}
.tchm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tchm-table thead th {
	text-align: left;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .05em;
	font-weight: 600;
	color: var(--mnr-muted);
	padding: 14px 16px;
	background: var(--mnr-bg);
	border-bottom: 1px solid var(--mnr-border);
}
.tchm-table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--mnr-border); }
.tchm-table tbody tr:last-child td { border-bottom: none; }
.tchm-row { cursor: pointer; transition: background 150ms ease; }
.tchm-row:hover { background: rgba(94, 152, 230, 0.08); }
.tchm-row__ref { color: var(--mnr-muted); font-variant-numeric: tabular-nums; }
.tchm-row__title a { font-weight: 500; color: var(--mnr-foreground); }
.tchm-row__title a:hover { color: var(--mnr-secondary); }
.tchm-row__date { color: var(--mnr-muted); white-space: nowrap; }

/* ------------------------------------------------------------------ *
 * Badges + priority pills
 * ------------------------------------------------------------------ */
.tchm-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 500;
	background: #EEF0F3;
	color: var(--mnr-muted);
}
.tchm-badge--to-do { background: var(--mnr-secondary-soft); color: #2F6FD0; }
.tchm-badge--in-progress { background: var(--mnr-warn-bg); color: var(--mnr-warn-fg); }
.tchm-badge--complete { background: var(--mnr-ok-bg); color: var(--mnr-ok-fg); }
/* System "Deleted" status (ClickUp task removed). Markup renders the badge as
   .tchm-badge--<status-slug>, so the real class is .tchm-badge--deleted. */
.tchm-badge--deleted {
	background: #F3F4F6;
	color: #6B7280;
	font-family: "Poppins", sans-serif;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-decoration: line-through;
}

.tchm-prio {
	display: inline-block;
	padding: 3px 8px;
	border-radius: 99px;
	font-family: "Poppins", sans-serif;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	background: #EEF0F3;
	color: var(--mnr-muted);
}
.tchm-prio--p1 { background: #FEE2E2; color: #991B1B; } /* red: critical */
.tchm-prio--p2 { background: #FEF3C7; color: #92400E; } /* amber: high */
.tchm-prio--p3 { background: #DBEAFE; color: #1E40AF; } /* blue: medium */
.tchm-prio--p4 { background: #F3F4F6; color: #374151; } /* grey: low */

/* ------------------------------------------------------------------ *
 * Empty state
 * ------------------------------------------------------------------ */
.tchm-empty {
	background: var(--mnr-surface);
	border: 1px dashed var(--mnr-border);
	border-radius: var(--tchm-radius);
	padding: 48px 24px;
	text-align: center;
}
.tchm-empty h2 { font-size: 18px; }
.tchm-empty p { color: var(--mnr-muted); margin: 4px 0 20px; }

/* ------------------------------------------------------------------ *
 * Single ticket
 * ------------------------------------------------------------------ */
.tchm-ticket-head { margin-bottom: 20px; }
.tchm-ticket-head__ref { font-size: 13px; color: var(--mnr-muted); font-variant-numeric: tabular-nums; }
.tchm-ticket-head__title { font-size: 24px; margin: 4px 0 10px; }
.tchm-ticket-head__meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tchm-ticket-head__date { font-size: 13px; color: var(--mnr-muted); }

.tchm-details { margin: 0; display: grid; gap: 0; }
.tchm-detail { display: grid; grid-template-columns: 200px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--mnr-border); }
.tchm-detail:last-child { border-bottom: none; }
.tchm-detail dt { font-size: 13px; font-weight: 500; color: var(--mnr-muted); margin: 0; }
.tchm-detail dd { margin: 0; font-size: 14px; }
.tchm-detail__text { white-space: pre-wrap; }

.tchm-attachments { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--mnr-border); }
.tchm-attachments__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.tchm-attachments__list a { font-size: 14px; }

/* ------------------------------------------------------------------ *
 * Comments (chat-style thread)
 *
 * Two visually distinct bubbles:
 *   .tchm-comment--client (TCHM)   blue tint, right-aligned, plain author label
 *   .tchm-comment--mnr    (MnR)    purple tint + left border, left-aligned, badge
 * ------------------------------------------------------------------ */
.tchm-comments { margin-top: 8px; }
.tchm-comment-list { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-direction: column; gap: 16px; }

/* Row wrapper positions the bubble to one side of the thread. */
.tchm-comment { display: flex; }
.tchm-comment--client { justify-content: flex-end; }
.tchm-comment--mnr { justify-content: flex-start; }

.tchm-comment__bubble {
	max-width: 75%;
	padding: 12px 14px;
	border-radius: 12px;
}

/* TCHM: blue tint, right, radius pinched at bottom-right. */
.tchm-comment--client .tchm-comment__bubble {
	background: rgba(94, 152, 230, .15);   /* --mnr-secondary @ 15% */
	border-radius: 12px 12px 2px 12px;
}
/* MnR: purple tint + accent left border, left, radius pinched at bottom-left. */
.tchm-comment--mnr .tchm-comment__bubble {
	background: rgba(153, 91, 252, .10);   /* --mnr-accent @ 10% */
	border-left: 3px solid var(--mnr-accent);
	border-radius: 12px 12px 12px 2px;
}

/* Author / badge row, aligned to the bubble's side. */
.tchm-comment__head { display: flex; align-items: center; margin-bottom: 4px; }
.tchm-comment--client .tchm-comment__head { justify-content: flex-end; }
.tchm-comment--mnr .tchm-comment__head { justify-content: flex-start; }

/* TCHM author label: blue, Poppins 600 12px, top-right. */
.tchm-comment__author {
	font-family: "Poppins", sans-serif;
	font-weight: 600;
	font-size: 12px;
	color: var(--mnr-secondary);
}

/* MnR author: coloured pill badge, top-left. */
.tchm-comment__badge {
	display: inline-block;
	background: var(--mnr-accent);
	color: #fff;
	font-family: "Poppins", sans-serif;
	font-weight: 600;
	font-size: 10px;
	line-height: 1.4;
	padding: 2px 8px;
	border-radius: 99px;
}

.tchm-comment__body { font-size: 14px; color: var(--mnr-foreground); }

/* Timestamp: 11px muted, aligned to the same side as the author. */
.tchm-comment__date { display: block; font-size: 11px; color: var(--mnr-muted); margin-top: 6px; }
.tchm-comment--client .tchm-comment__date { text-align: right; }
.tchm-comment--mnr .tchm-comment__date { text-align: left; }

.tchm-comment-form {
	background: var(--mnr-surface);
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius);
	box-shadow: var(--tchm-shadow);
	padding: 20px;
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */
/* Tablet and down. Class names map to the real markup:
   .tchm-table = ticket table, .tchm-row = ticket row, .tchm-details = ticket
   detail list, .tchm-form--card = submit form card. */
@media (max-width: 768px) {

	/* 7. General mobile spacing */
	.tchm-container { padding: 16px; }
	.tchm-page-head { flex-direction: column; align-items: flex-start; }
	.tchm-page-head__title { font-size: 22px; }
	.tchm-section-title { font-size: 13px; }
	.tchm-grid-2 { grid-template-columns: 1fr; }

	/* 1. Navigation: stack into two rows (brand, then links centred) */
	.tchm-topbar__inner {
		flex-direction: column;
		align-items: stretch;
		height: auto;
		gap: 8px;
		padding: 8px 16px;
	}
	.tchm-nav-brand { justify-content: flex-start; }
	.tchm-nav-brand img { height: 24px; }
	.tchm-nav { justify-content: center; gap: 18px; }
	.tchm-nav a { font-size: 13px; white-space: normal; }

	/* 3. Dashboard filter bar: compact two-column grid.
	   Selectors use .tchm-filters__field (not a plain .tchm-filters descendant)
	   so they out-specify the base .tchm-filters__field rules; the Apply/Reset
	   actions span the full width below the grid. */
	.tchm-filters {
		display: grid;
		grid-template-columns: 1fr 1fr;
		align-items: start;
		gap: 8px;
		padding: 12px;
	}
	.tchm-filters__field { min-width: 0; gap: 4px; }
	.tchm-filters__field label {
		font-size: 10px;
		font-weight: 700;
		text-transform: uppercase;
		letter-spacing: 0.06em;
		color: var(--mnr-muted);
	}
	.tchm-filters__field select {
		width: 100%;
		font-size: 13px;
		padding: 8px 10px;
	}
	.tchm-filters__actions { grid-column: 1 / -1; flex-direction: column; gap: 8px; }
	.tchm-filters .tchm-btn,
	.tchm-filters button[type="submit"] {
		width: 100%;
		padding: 10px;
		font-size: 13px;
	}

	/* 4. Dashboard table -> stacked cards (labels come from td[data-label]) */
	.tchm-table-wrap { border: none; box-shadow: none; background: transparent; overflow: visible; }
	.tchm-table, .tchm-table tbody { display: block; width: 100%; }
	.tchm-table thead { display: none; }
	.tchm-row {
		display: block;
		padding: 16px;
		margin-bottom: 12px;
		border-radius: 8px;
		background: #fff;
		border: 1px solid var(--mnr-border);
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	}
	.tchm-row td {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 6px 0;
		border-bottom: 1px solid var(--mnr-border);
		font-size: 13px;
	}
	.tchm-row td:last-child { border-bottom: none; }
	.tchm-row td::before {
		content: attr(data-label);
		flex-shrink: 0;
		margin-right: 12px;
		font-size: 11px;
		font-weight: 600;
		text-transform: uppercase;
		letter-spacing: 0.04em;
		color: var(--mnr-muted);
	}

	/* 5. Submit form */
	.tchm-form--card { padding: 20px 16px; }
	.tchm-field input,
	.tchm-field select,
	.tchm-field textarea,
	.tchm-filters select { font-size: 16px; } /* 16px avoids iOS zoom-on-focus */
	.tchm-upload-zone { padding: 24px 16px; }

	/* 6. Ticket detail: stack label above value */
	.tchm-details { display: block; }
	.tchm-detail { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; }
	.tchm-detail dt {
		font-size: 11px;
		font-weight: 600;
		text-transform: uppercase;
		letter-spacing: 0.04em;
		color: var(--mnr-muted);
		padding-bottom: 2px;
	}
	/* Comment bubbles already read well on mobile; left as-is. */
}

/* Phone */
@media (max-width: 480px) {

	/* 1. Navigation: tighter link spacing, keep labels wrapping cleanly */
	.tchm-nav { gap: 12px; }
	.tchm-nav a { white-space: normal; }

	/* 2. Login page */
	.tchm-auth { padding: 16px; }
	.tchm-auth__card { padding: 24px 20px; border-radius: 12px; margin: 0; }
	.tchm-login-logo { max-width: 140px; }

	/* 3. Dashboard filter bar: tighter padding, keep the two-column grid */
	.tchm-filters { padding: 10px; gap: 6px; }
}

/* ------------------------------------------------------------------ *
 * Audit log (admin)
 * ------------------------------------------------------------------ */

/* Date inputs in filter bars, matched to the select styling. */
.tchm-filters__field input[type="date"] {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius-sm);
	font-family: inherit;
	font-size: 14px;
	background: #fff;
	color: var(--mnr-foreground);
}
.tchm-filters__field input[type="date"]:focus {
	outline: none;
	border-color: var(--mnr-secondary);
	box-shadow: 0 0 0 3px var(--mnr-focus);
}

.tchm-audit-count { margin: 0 0 12px; font-size: 13px; color: var(--mnr-muted); }
.tchm-audit-time { white-space: nowrap; font-size: 13px; color: var(--mnr-muted); }
.tchm-audit-event { font-size: 13px; font-weight: 600; color: var(--mnr-primary); }
.tchm-audit-detail { font-size: 13px; color: var(--mnr-muted); }

/* Role pills */
.tchm-role {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 99px;
	font-family: "Poppins", sans-serif;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	background: #F3F4F6;
	color: #6B7280;
}
.tchm-role--tchm_user { background: rgba(94, 152, 230, 0.15); color: #1E40AF; }
.tchm-role--administrator { background: rgba(64, 74, 86, 0.15); color: #1F2937; }
.tchm-role--mnr_team { background: rgba(153, 91, 252, 0.15); color: #5B21B6; }
.tchm-role--system { background: #F3F4F6; color: #6B7280; }

/* Pagination */
.tchm-pagination {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 24px;
}
.tchm-pagination-info { font-size: 13px; color: var(--mnr-muted); }
.tchm-pagination-btn--disabled {
	padding: 10px 18px;
	border: 1px solid var(--mnr-border);
	border-radius: var(--tchm-radius-sm);
	font-size: 14px;
	font-weight: 500;
	color: var(--mnr-muted);
	opacity: 0.5;
	cursor: default;
}

/* Audit table stacks into cards on mobile (reuses the dashboard pattern; the
   generic .tchm-table thead/wrap resets in the 768px block already apply). */
@media (max-width: 768px) {
	.tchm-audit-table tbody tr {
		display: block;
		padding: 16px;
		margin-bottom: 12px;
		border-radius: 8px;
		background: #fff;
		border: 1px solid var(--mnr-border);
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	}
	.tchm-audit-table tbody td {
		display: flex;
		justify-content: space-between;
		align-items: baseline;
		gap: 12px;
		padding: 6px 0;
		border-bottom: 1px solid var(--mnr-border);
		font-size: 13px;
	}
	.tchm-audit-table tbody td:last-child { border-bottom: none; }
	.tchm-audit-table tbody td::before {
		content: attr(data-label);
		flex-shrink: 0;
		font-size: 11px;
		font-weight: 600;
		text-transform: uppercase;
		letter-spacing: 0.04em;
		color: var(--mnr-muted);
	}
	.tchm-pagination { gap: 8px; }
}

/* ------------------------------------------------------------------ *
 * Ticket activity timeline
 * ------------------------------------------------------------------ */
.tchm-activity {
	margin: 32px 0;
	padding: 24px;
	background: #fff;
	border-radius: 12px;
	border: 1px solid var(--mnr-border);
}
.tchm-activity__heading {
	font-size: 16px;
	font-weight: 600;
	color: var(--mnr-primary);
	font-family: "Poppins", sans-serif;
	margin: 0 0 20px;
}
.tchm-activity__list {
	list-style: none;
	margin: 0;
	padding: 0;
	position: relative;
}
/* Vertical connecting line */
.tchm-activity__list::before {
	content: '';
	position: absolute;
	left: 11px;
	top: 4px;
	bottom: 4px;
	width: 2px;
	background: var(--mnr-border);
}
.tchm-activity__item {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	padding: 8px 0;
	position: relative;
}
.tchm-activity__icon {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--mnr-border);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	flex-shrink: 0;
	position: relative;
	z-index: 1;
}
/* Icon colours per event type */
.tchm-activity__item--ticket_created .tchm-activity__icon {
	border-color: var(--mnr-secondary);
	color: var(--mnr-secondary);
}
.tchm-activity__item--status_changed .tchm-activity__icon {
	border-color: var(--mnr-accent);
	color: var(--mnr-accent);
}
.tchm-activity__item--comment_added .tchm-activity__icon,
.tchm-activity__item--comment_from_mnr .tchm-activity__icon {
	border-color: var(--mnr-muted);
	color: var(--mnr-muted);
}
.tchm-activity__item--comment_from_mnr .tchm-activity__icon {
	border-color: var(--mnr-accent);
	color: var(--mnr-accent);
}
.tchm-activity__item--ticket_deleted .tchm-activity__icon {
	border-color: var(--mnr-danger);
	color: var(--mnr-danger);
}
.tchm-activity__body {
	flex: 1;
	padding-top: 2px;
}
.tchm-activity__detail {
	display: block;
	font-size: 13px;
	color: var(--mnr-foreground);
	font-family: "Poppins", sans-serif;
	line-height: 1.4;
}
.tchm-activity__meta {
	display: block;
	font-size: 11px;
	color: var(--mnr-muted);
	font-family: "Poppins", sans-serif;
	margin-top: 2px;
}
.tchm-activity__empty {
	font-size: 13px;
	color: var(--mnr-muted);
	font-style: italic;
	margin: 0;
}
@media (max-width: 480px) {
	.tchm-activity { padding: 16px; }
	.tchm-activity__detail { font-size: 12px; }
}

/* ------------------------------------------------------------------ *
 * Password reset
 * ------------------------------------------------------------------ */
.tchm-forgot-link {
	display: block;
	text-align: center;
	margin-top: 12px;
	font-family: "Poppins", sans-serif;
	font-size: 13px;
	color: var(--mnr-muted);
	text-decoration: none;
	transition: color 150ms ease;
}
.tchm-forgot-link:hover { color: var(--mnr-secondary); }

.tchm-reset-success {
	margin-bottom: 20px;
	padding: 16px 20px;
	background: #D1FAE5;
	border: 1px solid #6EE7B7;
	border-radius: 8px;
	font-family: "Poppins", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #065F46;
}
.tchm-reset-success a {
	color: #065F46;
	font-weight: 600;
	text-decoration: underline;
}

.tchm-reset-error {
	margin-bottom: 20px;
	padding: 16px 20px;
	background: #FEF2F2;
	border: 1px solid #FECACA;
	border-radius: 8px;
	font-family: "Poppins", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #991B1B;
}
.tchm-reset-error a {
	color: #991B1B;
	font-weight: 600;
	text-decoration: underline;
}
