/* The "Report a problem" dialog (issue 237; Figma 42:81 desktop, 43:759 phone). One stylesheet, linked from App.razor, shared
   by the Blazor dialog (FeedbackDialog.razor, whose own shell lives in FeedbackDialog.razor.css) and by the JS-only fallback
   dialog that works when the circuit is dead (feedback-fallback.js, part B2), so the two look the same. Everything is an
   fb- class, and every colour, radius and shadow comes from the app.css tokens (never redeclared here).

   Phone tier: 576px and below, the dialog is a full-screen sheet with a sticky footer. The body is the one scroll
   container. Breakpoints can't use custom properties, so 576px is written out (see app.css). */

.fb-panel {
	display: flex;
	flex-direction: column;
	min-height: 0;
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	background: var(--surface);
	color: var(--ink);
	border-radius: 14px;
	box-shadow: var(--shadow-lg);
	overflow: hidden;
	font-size: 13.5px;
}

.fb-panel:focus {
	outline: none;
}

/* Header ------------------------------------------------------------------------------------------------------------ */
.fb-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 18px 20px 14px;
	flex-shrink: 0;
}

.fb-tile {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	border-radius: 9px;
	background: var(--danger-soft);
	color: var(--danger-ink);
}

.fb-tile {
	font-size: 18px;
}

.fb-heading {
	flex: 1 1 auto;
	min-width: 0;
}

.fb-title {
	margin: 0;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--ink);
}

.fb-subtitle {
	margin: 2px 0 0;
	font-size: 12.5px;
	line-height: 1.2;
	color: var(--ink-soft);
}

.fb-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-md);
	background: transparent;
	color: var(--ink-soft);
	cursor: pointer;
}

.fb-close:hover:not(:disabled) {
	background: var(--line-soft);
	color: var(--ink);
}

.fb-close:disabled {
	opacity: .5;
	cursor: not-allowed;
}

/* Context strip: where, which error, when, who ------------------------------------------------------------------------ */
.fb-context {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 10px 20px;
	background: var(--surface-muted);
	font-size: 12.5px;
	color: var(--ink-soft);
	flex-shrink: 0;
}

.fb-context-area {
	font-weight: 700;
	color: var(--ink);
}

.fb-chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 9px;
	border-radius: var(--radius-pill);
	font-size: 11.5px;
	font-weight: 700;
	line-height: 1.1;
}

.fb-chip-danger {
	background: var(--danger-soft);
	color: var(--danger-ink);
}

.fb-chip-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

/* Body: the one scroll container ------------------------------------------------------------------------------------- */
.fb-body {
	display: flex;
	flex-direction: column;
	gap: 16px;
	flex: 1 1 auto;
	min-height: 0;
	padding: 18px 20px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* The body scrolls, its children never shrink: a section with overflow hidden (the steps card) has no automatic minimum height,
   so in a short window it would be squeezed to a few rows with the rest cut off and no scrollbar to reach it. */
.fb-body > * {
	flex-shrink: 0;
}

.fb-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.fb-note-head {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 26px;
}

.fb-label {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	font-size: 11.5px;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--ink-soft);
}

.fb-optional {
	margin-left: .35em;
}

.fb-textarea {
	display: block;
	width: 100%;
	min-height: 84px;
	padding: 9px 12px;
	border: 1px solid var(--line-strong);
	border-radius: 6px;
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	font-size: 13.5px;
	line-height: 1.5;
	resize: vertical;
}

.fb-textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-ring);
}

.fb-textarea.is-invalid {
	border-color: var(--danger-ink);
}

.fb-hint {
	margin: 0;
	font-size: 12px;
	color: var(--ink-faint);
}

.fb-error {
	margin: 0;
	font-size: 12.5px;
	font-weight: 700;
	color: var(--danger-ink);
}

.fb-disabled {
	margin: 0;
	padding: 12px 14px;
	border: 1px solid var(--warning-line);
	border-radius: var(--radius-md);
	background: var(--warning-soft);
	color: var(--warning-ink);
}

/* Images ------------------------------------------------------------------------------------------------------------- */
.fb-thumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.fb-thumb {
	position: relative;
	width: 96px;
	height: 68px;
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
	background: var(--line-soft);
	overflow: hidden;
}

.fb-thumb-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.fb-thumb-remove,
.fb-step-remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	color: var(--ink-soft);
	cursor: pointer;
}

.fb-thumb-remove {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--surface);
	box-shadow: var(--shadow-sm);
}

.fb-thumb-remove:hover:not(:disabled),
.fb-step-remove:hover:not(:disabled) {
	color: var(--danger-ink);
}

/* Touch: the two 22 px remove buttons keep their look, their tap area grows to 44 px (an ::after that is not drawn).
   The thumbnail's area is anchored to the tile's corner (its overflow is clipped, so one centred on the button would lose 7 px
   beyond the tile and be 37 px), the step's is centred on the button and the row gets the 44 px of height that stops the areas
   of two neighbouring rows from overlapping (a tap between two rows must remove the row it is on). */
@media (pointer: coarse) {
	.fb-thumb-remove::after {
		content: "";
		position: absolute;
		top: -4px;
		right: -4px;
		width: 44px;
		height: 44px;
	}

	.fb-step-remove {
		position: relative;
	}

	.fb-step-remove::after {
		content: "";
		position: absolute;
		inset: -11px;
	}

	.fb-step {
		min-height: 44px;
	}
}

.fb-thumb-remove:disabled,
.fb-step-remove:disabled {
	opacity: .5;
	cursor: not-allowed;
}

.fb-add {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	width: 96px;
	height: 68px;
	margin: 0;
	border: 1px dashed var(--line-strong);
	border-radius: var(--radius-md);
	color: var(--accent);
	font-size: 12px;
	cursor: pointer;
}

.fb-add:hover {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.fb-add:focus-within {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-ring);
}

.fb-add.is-full {
	display: none;
}

/* The real file input covers the tile, invisible: a click on the tile is a click on the input. */
.fb-add-input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.fb-add-icon {
	display: inline-flex;
	font-size: 15px;
}

.fb-add-icon-mobile,
.fb-add-text-mobile {
	display: none;
}

/* What will be sent ------------------------------------------------------------------------------------------------- */
.fb-steps {
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	overflow: hidden;
}

.fb-steps-head {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 10px 12px;
	border: 0;
	background: var(--surface-muted);
	color: var(--ink);
	font-size: 13px;
	font-weight: 700;
	line-height: 15px;
	text-align: left;
	cursor: pointer;
}

.fb-steps-chevron {
	display: inline-flex;
	color: var(--ink-soft);
}

.fb-steps-title-mobile {
	display: none;
}

.fb-steps-hint {
	margin-left: auto;
	font-size: 12px;
	font-weight: 400;
	color: var(--ink-soft);
}

.fb-step-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.fb-step {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 3px 12px;
	border-top: 1px solid var(--line-soft);
	font-size: 12.5px;
	color: var(--ink);
}

.fb-step-time {
	flex-shrink: 0;
	min-width: 47px;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	color: var(--ink-faint);
}

.fb-step-glyph {
	font-size: 12px;
	display: inline-flex;
	flex-shrink: 0;
	width: 14px;
	color: var(--ink-soft);
}

.fb-step-text {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
}

.fb-step-remove {
	flex-shrink: 0;
	width: 22px;
	height: 22px;
	border-radius: var(--radius-sm);
	background: transparent;
}

.fb-step.is-error {
	color: var(--danger-ink);
	font-weight: 700;
}

.fb-step.is-error .fb-step-glyph {
	color: var(--danger-ink);
}

.fb-steps-empty,
.fb-steps-more {
	margin: 0;
	padding: 7px 12px 9px;
	border-top: 1px solid var(--line-soft);
	font-size: 12px;
	color: var(--ink-soft);
}

.fb-earlier {
	display: inline;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--accent-strong);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.fb-earlier:hover {
	text-decoration: underline;
}

/* Privacy line and footer -------------------------------------------------------------------------------------------- */
.fb-privacy {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	font-size: 12px;
	color: var(--ink-soft);
}

.fb-privacy svg {
	flex-shrink: 0;
	font-size: 14px;
	color: var(--success-ink);
}

.fb-privacy-body {
	display: none;
}

.fb-footer {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
	padding: 14px 20px 16px;
	border-top: 1px solid var(--line);
	background: var(--surface);
}

.fb-privacy-footer {
	flex: 1 1 auto;
	min-width: 0;
}

.fb-actions {
	display: flex;
	gap: 10px;
	margin-left: auto;
}

.fb-actions .btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font-size: 13.5px;
}

/* Cancel is the quiet button: the ink on the surface with the strong line (Figma 42:81), not Bootstrap's grey secondary. The
   selectors carry .fb-actions so they win over .btn's own states. */
.fb-actions .fb-cancel {
	border: 1px solid var(--line-strong);
	background: var(--surface);
	color: var(--ink);
}

.fb-actions .fb-cancel:hover:not(:disabled),
.fb-actions .fb-cancel:focus-visible {
	border-color: var(--line-strong);
	background: var(--surface-muted);
	color: var(--ink);
}

.fb-actions .fb-cancel:disabled {
	border-color: var(--line-strong);
	background: var(--surface);
	color: var(--ink);
	opacity: .5;
}

/* Touch (a landscape phone is wider than the phone tier): the footer buttons are 44 px tall. */
@media (pointer: coarse) {
	.fb-actions .btn {
		min-height: 44px;
	}
}

/* The toast text (the Toast molecule's message slot) ------------------------------------------------------------------ */
.fb-toast-title {
	display: block;
	font-size: 13px;
	font-weight: 700;
	color: var(--ink);
}

.fb-toast-body {
	display: block;
	margin-top: 3px;
	font-size: 12.5px;
	color: var(--ink-soft);
}

/* The JS-only fallback dialog (feedback-fallback.js) ---------------------------------------------------------------------
   A native <dialog> opened with showModal(): the top layer puts it above Blazor's reconnect dialog. The element is only the
   frame; the panel inside is the same .fb-panel as the live dialog. */
dialog.fb-native {
	width: min(700px, calc(100vw - 32px));
	max-width: none;
	max-height: none;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--ink);
	overflow: visible;
}

dialog.fb-native::backdrop {
	background: var(--modal-backdrop, rgba(0, 0, 0, 0.5));
}

/* The fallback toggles messages with the hidden attribute; the fb- rules above would otherwise show them. */
dialog.fb-native [hidden] {
	display: none !important;
}

/* The fallback's toast: a manual popover (top layer, above any dialog) shaped like the Toast molecule. */
.fb-toast {
	position: fixed;
	inset: auto auto 16px 50%;
	transform: translateX(-50%);
	z-index: 1090;
	display: flex;
	align-items: flex-start;
	gap: 8px;
	width: max-content;
	max-width: min(480px, calc(100vw - 32px));
	margin: 0;
	padding: 10px 12px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-left: 4px solid var(--fb-toast-ink, var(--info-ink));
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-md);
	color: var(--ink);
	font-size: 13px;
	overflow: visible;
}

.fb-toast.tone-success {
	--fb-toast-ink: var(--success-ink);
}

.fb-toast.tone-warning {
	--fb-toast-ink: var(--warning-ink);
}

.fb-toast.tone-info {
	--fb-toast-ink: var(--info-ink);
}

.fb-toast.tone-error {
	--fb-toast-ink: var(--danger-ink);
}

.fb-toast-glyph {
	display: inline-flex;
	flex: none;
	padding-top: 2px;
	color: var(--fb-toast-ink, var(--info-ink));
}

.fb-toast-message {
	min-width: 0;
	overflow-wrap: anywhere;
}

.fb-toast-close {
	position: relative;
	flex: none;
	width: 20px;
	height: 20px;
	padding: 0;
	background-size: 10px;
}

/* Touch: the 20 px button keeps its look, its tap area grows to 44 px (the toast doesn't get taller). */
@media (pointer: coarse), (max-width: 576px) {
	.fb-toast-close::after {
		content: "";
		position: absolute;
		inset: -12px;
	}
}

/* Narrow desktop windows: the hint line would crowd the title. */
@media (max-width: 760px) {
	.fb-steps-hint {
		display: none;
	}
}

/* Phone: a full-screen sheet with a sticky footer (Figma 43:759). Its shell (position, size) is the host's: the Blazor shell
   in FeedbackDialog.razor.css, the native <dialog> of the fallback in its own rules. This is the content. */
@media (max-width: 576px) {
	.fb-panel {
		max-height: none;
		border-radius: 0;
		box-shadow: none;
	}

	/* Figma 43:759: the header is 55 px (14 + 28 tile + 12 + the line), the title 16 px. */
	.fb-header {
		padding: 14px 16px 12px;
		border-bottom: 1px solid var(--line);
	}

	.fb-title {
		font-size: 16px;
		line-height: 18px;
	}

	/* The close button comes first, the bug tile last. It is as tall as the tile (28 px, so the header is the 55 px of the frame);
	   its tap target is still 44 px, from the ::after. */
	.fb-close {
		position: relative;
		order: -1;
		width: 28px;
		height: 28px;
		margin-left: -6px;
	}

	.fb-close::after {
		content: "";
		position: absolute;
		inset: -8px;
	}

	.fb-tile {
		order: 3;
		width: 28px;
		height: 28px;
		border-radius: 7px;
		font-size: 15px;
	}

	.fb-subtitle {
		display: none;
	}

	.fb-context {
		padding: 12px 16px 0;
		background: var(--surface);
	}

	.fb-context-meta {
		display: none;
	}

	.fb-body {
		gap: 14px;
		padding: 14px 16px;
	}

	.fb-optional,
	.fb-images-label,
	.fb-note-hint,
	.fb-steps-hint,
	.fb-also,
	.fb-also-sep,
	.fb-step-glyph,
	.fb-step-seconds,
	.fb-privacy-footer {
		display: none;
	}

	/* Figma 43:759: the note box is 90 px, with no "type or dictate" line under it. */
	.fb-textarea {
		min-height: 90px;
	}

	/* The add tile becomes a wide dashed button under the thumbnails. */
	.fb-thumbs {
		gap: 8px;
	}

	.fb-add {
		flex: 1 0 100%;
		flex-direction: row;
		justify-content: flex-start;
		gap: 8px;
		width: auto;
		height: auto;
		min-height: 44px;
		padding: 9px 12px;
		border-radius: var(--radius-md);
	}

	.fb-add-icon-desktop,
	.fb-add-text-desktop {
		display: none;
	}

	.fb-add-icon-mobile {
		display: inline-flex;
	}

	.fb-add-text-mobile {
		display: inline;
		font-size: 13px;
	}

	/* Nothing but the attachments line left: no empty bar under the last step. */
	.fb-steps-more:not(:has(.fb-earlier)) {
		display: none;
	}

	.fb-steps-title-desktop {
		display: none;
	}

	.fb-steps-title-mobile {
		display: inline;
	}

	.fb-step-time {
		min-width: 0;
		font-size: 11.5px;
	}

	.fb-privacy-body {
		display: flex;
	}

	/* The fallback's <dialog> is the full-screen sheet itself. */
	dialog.fb-native {
		width: 100%;
		height: 100vh;
		height: 100dvh;
		margin: 0;
	}

	dialog.fb-native > .fb-panel {
		height: 100%;
	}

	/* As the Toast molecule on a phone: at the top, below the hamburger. */
	.fb-toast {
		inset: calc(54px + env(safe-area-inset-top)) auto auto 50%;
	}

	/* Sticky footer: Cancel and Send split the width. */
	.fb-footer {
		padding: 12px 16px;
	}

	.fb-actions {
		flex: 1 1 auto;
		margin-left: 0;
	}

	.fb-actions .btn {
		flex: 1 1 0;
		min-height: 44px;
	}
}
