/* Helpdesk styles shared by every page. Admin-only pieces live in admin.css. */

:root {
	--ink: #1f2933;
	--muted: #5f6b76;
	--line: #d9dee3;
	--page: #f4f6f8;
	--surface: #ffffff;
	--accent: #3e5c76;
	--submitted: #3e5c76;
	--progress: #a86412;
	--done: #2f7d4f;
	--error: #b42318;
	--radius: 8px;
	--font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--page);
	color: var(--ink);
	font-family: var(--font);
	font-size: 1rem;
	line-height: 1.55;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; font-weight: 650; }
p { margin: 0 0 1rem; }
a { color: var(--accent); }
code { font-size: .9em; background: #e9edf1; padding: .1em .35em; border-radius: 4px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__inner {
	max-width: 1120px;
	margin: 0 auto;
	padding: .9rem 1.25rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.topbar__user { display: flex; align-items: center; gap: .9rem; color: var(--muted); font-size: .95rem; }

/* ---------- Page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 2.25rem 1.25rem 4rem; }

.auth {
	max-width: 26rem;
	margin: 2rem auto;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 2rem;
}
.auth__alt { margin: 1.25rem 0 0; }

/* ---------- Forms ---------- */
.stack > * + * { margin-top: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field input,
.field textarea,
.field select,
.select {
	width: 100%;
	padding: .65rem .75rem;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	color: inherit;
	font: inherit;
}
.field textarea { resize: vertical; min-height: 7rem; }
.optional { font-weight: 400; color: var(--muted); margin-left: .35rem; }

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: .7rem 1.3rem;
	border: 0;
	border-radius: 6px;
	background: var(--ink);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.button:disabled { opacity: .6; cursor: wait; }
.button--quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.link-button {
	background: none;
	border: 0;
	padding: 0;
	color: var(--accent);
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

:is(input, textarea, select, button, a):focus-visible {
	outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
	outline-offset: 2px;
}

.form-msg { min-height: 1.5em; margin: .75rem 0 0; color: var(--muted); }
.form-msg.is-error { color: var(--error); }
.form-msg.is-ok { color: var(--done); }

/* ---------- Client portal ---------- */
.portal {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
	gap: 2.5rem;
	align-items: start;
}
@media (max-width: 800px) {
	.portal { grid-template-columns: 1fr; gap: 2rem; }
}
.portal__form {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 1.5rem;
}

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

.live { font-size: .875rem; color: var(--muted); display: inline-flex; align-items: center; gap: .45rem; }
.live::before {
	content: "";
	width: .5rem;
	height: .5rem;
	border-radius: 50%;
	background: var(--done);
	animation: pulse 2.4s ease-in-out infinite;
}
.live.is-offline { color: var(--error); }
.live.is-offline::before { background: var(--error); animation: none; }
@keyframes pulse { 50% { opacity: .25; } }

.tickets { list-style: none; margin: 0; padding: 0; }
.tickets__empty { color: var(--muted); padding: 1rem 0; }

.ticket {
	--state: var(--submitted);
	padding: 1.1rem 0 1.25rem;
	border-top: 1px solid var(--line);
}
.ticket:last-child { border-bottom: 1px solid var(--line); }
.ticket--in_progress, .state--in_progress { --state: var(--progress); }
.ticket--completed, .state--completed { --state: var(--done); }
.state--submitted { --state: var(--submitted); }

.ticket__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.ticket__title { font-size: 1.05rem; overflow-wrap: anywhere; }
.ticket__site { display: inline-block; font-size: .92rem; overflow-wrap: anywhere; }
.ticket__notes { margin: .5rem 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.ticket__meta { margin: .5rem 0 0; font-size: .82rem; color: var(--muted); }

.badge {
	flex-shrink: 0;
	display: inline-block;
	padding: .15rem .65rem;
	border-radius: 999px;
	font-size: .8rem;
	font-weight: 600;
	color: var(--state, var(--submitted));
	background: color-mix(in srgb, var(--state, var(--submitted)) 12%, transparent);
}

/* The status tracker: three segments that fill as the ticket moves along. */
.track {
	list-style: none;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: .35rem;
	margin: .85rem 0 .75rem;
	padding: 0;
	font-size: .75rem;
	color: var(--muted);
}
.track__step { position: relative; padding-top: .5rem; }
.track__step::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	border-radius: 2px;
	background: var(--line);
	transition: background-color .5s ease;
}
.track__step.is-done::before,
.track__step.is-current::before { background: var(--state); }
.track__step.is-current { color: var(--ink); font-weight: 600; }

/* One moment of motion: a ticket whose status just changed gets a brief highlight. */
.ticket.is-changed { animation: flash 2.5s ease-out; }
@keyframes flash {
	from { background: color-mix(in srgb, var(--state) 16%, transparent); }
	to { background: transparent; }
}

/* ---------- Toast ---------- */
.toast {
	position: fixed;
	left: 50%;
	bottom: 1.5rem;
	transform: translate(-50%, 1rem);
	max-width: min(90vw, 30rem);
	padding: .8rem 1.1rem;
	border-radius: var(--radius);
	background: var(--ink);
	color: #fff;
	opacity: 0;
	pointer-events: none;
	transition: opacity .25s ease, transform .25s ease;
	z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
	.live::before, .ticket.is-changed { animation: none; }
	.toast, .track__step::before { transition: none; }
}
