/* ============================================================================
   Composer & MailTemplateComposer shared styles.
   Loaded globally from App.razor so both components share a single source of
   truth. Selectors don't use Blazor scoping (no [b-xyz] attribute) since the
   global stylesheet applies regardless of which component rendered the DOM.
   ============================================================================ */

/* HTML rendering inside content blocks */
div.htmlcms p {
	margin: 1em 0;
	padding: 0;
}

/* ----------------------------------------------------------------------------
   Proofreader hover tooltip. The element is created by proofreaderTooltip JS
   and appended to document.body, so it must be styled globally — a scoped
   <style> in ProofreaderTab.razor disappears when the tab unmounts and would
   leave a stray, unstyled div visible at the bottom of the page.
   ---------------------------------------------------------------------------- */
.proofread-tooltip {
	position: fixed;
	pointer-events: none;
	background: rgba(33, 33, 33, 0.92);
	color: #fff;
	padding: 6px 10px;
	border-radius: 4px;
	font-size: 0.8rem;
	line-height: 1.3;
	max-width: 320px;
	z-index: 10000;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	display: none;
}

.proofread-tooltip.visible {
	display: block;
}

/* ----------------------------------------------------------------------------
   Inline edit feedback ("Gemt" / "Annulleret" transient label after save/cancel)
   ---------------------------------------------------------------------------- */
.inline-edit-feedback {
	font-size: 0.75rem;
	font-weight: 500;
	padding: 2px 8px;
	border-radius: 4px;
	opacity: 1;
	transition: opacity 0.5s ease-out;
	display: inline-flex;
	align-items: center;
	align-self: center;
}

.inline-edit-feedback.fade-out {
	opacity: 0;
}

.inline-edit-feedback.saved {
	color: var(--mud-palette-success);
}

.inline-edit-feedback.cancelled {
	color: var(--mud-palette-text-secondary);
}

/* ----------------------------------------------------------------------------
   Plus icons between blocks. Both modes render them as siblings of the
   data-item-id wrappers (no longer nested inside a block — the article-mode
   workaround was removed during the cleanup split).
   ---------------------------------------------------------------------------- */
.composer-add-btn {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 50px;
}

/* Plus icons stay fully visible AT ALL TIMES — no hide-during-drag, no layout
   compensation, no :has() trickery. SortableJS Filter (.composer-add-btn) excludes
   them from drag/swap consideration, and they don't match the Draggable selector
   ([data-item-id]) anyway, so they're inert during a SortableJS reorder.
   Layout never shifts during drag → SortableJS's sibling-rect cache stays valid
   → cursor-Y compute resolves accurately → the C# row-snapping reorder lands
   blocks at the user's intended position consistently. The toolbox HTML5-native
   drag flow (mailArticleDrag) treats plus icons as drop zones via the
   body.composer-dragging outline rule below; that flow is independent of the
   SortableJS path. */

/* ----------------------------------------------------------------------------
   Drop landing effect — the .composer-drop-puff CSS animation.
   Inset shadows render strictly inside the element's box, so the glow can
   never bleed onto row/column neighbours regardless of layout, density, or
   mode. The animation is applied to BOTH the inner card and the drag-handle:
   the drag-handle has its own opaque primary-tinted background and would
   obscure the card's glow at the header otherwise.
   ---------------------------------------------------------------------------- */
.composer-drop-puff .composer-block-card,
.composer-drop-puff .composer-drag-handle {
	animation: composerDropGlow 1s cubic-bezier(.2, .85, .4, 1) forwards;
}

/* Silence the animation on the drag clone (sortable-fallback / sortable-chosen) —
   without this, a fast successive drag picks up an element that still has
   composer-drop-puff from the previous drop and replays the keyframes on the
   floating clone. */
.composer-drop-puff.sortable-fallback .composer-block-card,
.composer-drop-puff.sortable-chosen .composer-block-card,
.composer-drop-puff.sortable-fallback .composer-drag-handle,
.composer-drop-puff.sortable-chosen .composer-drag-handle {
	animation: none !important;
	box-shadow: none !important;
}

@keyframes composerDropGlow {
	0% {
		box-shadow: inset 0 0 0 0 transparent, inset 0 0 0 0 transparent;
	}
	15% {
		box-shadow:
			inset 0 0 60px 8px color-mix(in srgb, var(--mud-palette-primary) 70%, transparent),
			inset 0 0 0 3px color-mix(in srgb, var(--mud-palette-primary) 90%, transparent);
	}
	40% {
		box-shadow:
			inset 0 0 60px 8px color-mix(in srgb, var(--mud-palette-primary) 70%, transparent),
			inset 0 0 0 3px color-mix(in srgb, var(--mud-palette-primary) 90%, transparent);
	}
	100% {
		box-shadow: inset 0 0 0 0 transparent, inset 0 0 0 0 transparent;
	}
}

/* ----------------------------------------------------------------------------
   Empty-column placeholder (multicol row's empty column slot — visual drop
   zone for the toolbox HTML5 drag).
   ---------------------------------------------------------------------------- */
.composer-empty-col-slot {
	transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* ----------------------------------------------------------------------------
   Drag-active body class (driven by mailArticleDrag in HTML5-native flow and
   composerDrag.setDragging in SortableJS-driven flows). The .mail-drop-active
   class is toggled on the specific zone the cursor is over (HTML5-native only).
   ---------------------------------------------------------------------------- */
body.composer-dragging [data-mail-drop-zone="empty-col"] .mud-paper {
	border-color: var(--mud-palette-primary);
}

body.composer-dragging [data-mail-drop-zone="new-row"],
body.composer-dragging .composer-empty-placeholder,
body.composer-dragging .composer-add-btn {
	outline: 2px dashed var(--mud-palette-primary);
	outline-offset: -4px;
	border-radius: 4px;
}

body.composer-dragging [data-mail-drop-zone="replace"] {
	outline: 2px dashed var(--mud-palette-secondary);
	outline-offset: -2px;
}

.mail-drop-active.composer-empty-col-slot .mud-paper {
	background-color: var(--mud-palette-primary-hover) !important;
	border-color: var(--mud-palette-primary) !important;
	border-width: 2px !important;
	box-shadow: 0 0 0 2px var(--mud-palette-primary);
}

.mail-drop-active[data-mail-drop-zone="new-row"],
.mail-drop-active.composer-empty-placeholder {
	background-color: var(--mud-palette-primary-hover);
	outline-style: solid !important;
}

.mail-drop-active[data-mail-drop-zone="replace"] {
	outline-style: solid !important;
}

/* ----------------------------------------------------------------------------
   Drag handle cursor — applied to the chrome bar at the top of each card.
   ---------------------------------------------------------------------------- */
.composer-drag-handle {
	cursor: grab !important;
}

.composer-drag-handle:active {
	cursor: grabbing !important;
}

.composer-drag-handle.drag-disabled {
	cursor: default !important;
}

/* Buttons inside drag handle should keep pointer cursor */
.composer-drag-handle button,
.composer-drag-handle .mud-icon-button {
	cursor: pointer !important;
}

/* ----------------------------------------------------------------------------
   Content zone — both modes now use a homogeneous row list as the SortableJS
   zone. Each `.composer-row-item` is a single sortable item containing its
   plus button + block (or for mail multicol, multicol grid of blocks + empty-
   col placeholders). SortableJS sees only [data-item-id] siblings — no plus
   icons or other heterogeneous siblings at the top level. This is the standard
   SortableJS pattern from the docs.
   ---------------------------------------------------------------------------- */
.composer-row-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-height: 100px;
	transition: background-color 0.2s ease;
}

.composer-row-item {
	display: flex;
	flex-direction: column;
}

/* Multicol grid INSIDE a row item — N columns of blocks (or empty-col placeholders).
   The grid-template-columns is set inline based on the row's ColumnCode (e.g. "50fr 50fr"
   or "33fr 33fr 33fr"). */
.composer-multicol-grid {
	display: grid;
	column-gap: 16px;
	row-gap: 8px;
	align-items: stretch;
}

.composer-multicol-grid > * {
	min-width: 0;
}

/* Highlight an empty-column placeholder while SortableJS drag is over it. */
.composer-empty-col-slot.drop-takeover .mud-paper {
	background-color: var(--mud-palette-primary-hover) !important;
	border-color: var(--mud-palette-primary) !important;
	border-width: 2px !important;
	box-shadow: 0 0 0 2px var(--mud-palette-primary);
}

.composer-row-list.sortable-ghost-parent {
	background-color: var(--mud-palette-action-default-hover);
}

/* Drop-zone visual on the dragged row's ghost slot in the row list. */
.composer-row-list .sortable-ghost {
	opacity: 1 !important;
	background: var(--mud-palette-primary-hover) !important;
	outline: 2px dashed var(--mud-palette-primary);
	outline-offset: -2px;
}

.composer-row-list .sortable-ghost > * {
	visibility: hidden;
}

/* ----------------------------------------------------------------------------
   Toolbox tile styling
   ---------------------------------------------------------------------------- */
.toolbox-item {
	cursor: grab;
	user-select: none;
	opacity: 1 !important;
}

.toolbox-item:active {
	cursor: grabbing;
}

.toolbox-item,
.toolbox-item.sortable-chosen,
.toolbox-item.sortable-selected {
	opacity: 1 !important;
}

.toolbox-item .mud-icon,
.toolbox-item .mud-typography {
	opacity: 1 !important;
	color: inherit !important;
}

.toolbox-item-disabled {
	cursor: not-allowed;
	opacity: 0.5 !important;
}

/* Clone being dragged - keep it visible */
.toolbox-clone {
	opacity: 1;
}

.toolbox-item:hover {
	background-color: rgba(var(--mud-palette-primary-rgb), 0.08);
	border-color: var(--mud-palette-primary);
	transition: all 0.2s ease;
}

.toolbox-item-disabled:hover {
	background-color: inherit;
	border-color: inherit;
	transform: none;
}

/* ----------------------------------------------------------------------------
   Composer block card chrome (white tile + tinted drag-handle bar)
   ---------------------------------------------------------------------------- */
.composer-block-card {
	border: 1px solid var(--mud-palette-divider);
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

/* Oversized block content (wide tables, embeds, unbroken strings) scrolls inside
   the card instead of stretching it — and with it the whole content column. */
.composer-block-body {
	overflow-x: auto;
}

.composer-block-card:hover {
	border-color: color-mix(in srgb, var(--mud-palette-primary) 40%, var(--mud-palette-divider));
	box-shadow: var(--mud-elevation-4);
}

/* Drag-handle chrome strip — primary-tinted bar that runs edge-to-edge across the
   top of each block, reading clearly as the "header" and the draggable affordance.
   Negative margins of -12px on top/left/right cancel the parent MudPaper's pa-3
   (12px) so the bar reaches the card's inner border. Top corners are rounded to
   ~3px so the tint sits cleanly inside the 1px composer-block-card border without
   overlapping it. */
.composer-block-card .composer-drag-handle {
	background-color: color-mix(in srgb, var(--mud-palette-primary) 20%, var(--mud-palette-surface));
	margin: -12px -12px 0 -12px;
	padding: 8px 12px;
	border-radius: 3px 3px 0 0;
	border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-primary) 35%, transparent);
	transition: background-color 0.15s ease;
}

.composer-block-card .composer-drag-handle:hover {
	background-color: color-mix(in srgb, var(--mud-palette-primary) 28%, var(--mud-palette-surface));
}

.composer-block-card .composer-drag-handle.drag-disabled,
.composer-block-card .composer-drag-handle.drag-disabled:hover {
	background-color: var(--mud-palette-action-disabled-background);
}

/* The bar's border-bottom replaces what the in-card MudDivider used to do, so hide
   the divider directly below the drag handle to avoid a doubled hairline. */
.composer-block-card .composer-drag-handle + .mud-divider {
	display: none;
}

/* ----------------------------------------------------------------------------
   Faktaboks / Tekstboks (CKEditor-rendered styled HTML boxes)
   ---------------------------------------------------------------------------- */
.cms-box {
	border: 1px solid var(--mud-palette-lines-default);
	border-radius: 4px;
	padding: 16px;
	margin: 4px 0;
}

.cms-faktaboks {
	background-color: var(--mud-palette-background-gray);
	border-color: #999;
}

.cms-tekstboks {
	background-color: var(--mud-palette-surface);
	border-color: #bbb;
}

.cms-box-title {
	font-weight: 700;
	font-size: 1.1rem;
	margin-bottom: 8px;
}

/* ----------------------------------------------------------------------------
   Brugerkontrol (CustomControl): the control itself only exists on the frontend,
   so the composer shows the same placeholder as the old CMS - a dashed box with
   the label and the control's namespace.
   ---------------------------------------------------------------------------- */
.cms-usercontrol {
	border: 1px dashed #bbb;
	border-radius: 4px;
	background-color: var(--mud-palette-background-gray);
	padding: 10px 14px;
	margin: 4px 0;
}

.cms-usercontrol-label {
	font-size: 0.78rem;
	color: #5e8a63;
	margin-bottom: 2px;
}

.cms-usercontrol-name {
	font-weight: 700;
	word-break: break-all;
}

.cms-usercontrol-missing {
	font-weight: 400;
	font-style: italic;
	color: var(--mud-palette-text-secondary);
}

.cms-usercontrol-description {
	margin-top: 6px;
	font-size: 0.85rem;
	color: var(--mud-palette-text-secondary);
}

/* ----------------------------------------------------------------------------
   Misc disabled state used inline in markup
   ---------------------------------------------------------------------------- */
.disabled-icon {
	opacity: 0.4;
	cursor: not-allowed !important;
}

/* ----------------------------------------------------------------------------
   Container modules (Faktaboksmodul / Tekstboksmodul).
   A module is one header card; the blocks inside it follow as indented rows
   inside a bracket drawn in the module's accent colour, and a slim synthetic
   "Slut på …" footer row closes the bracket. Everything stays a flat list of
   [data-item-id] siblings (SortableJS homogeneity) — the nesting is purely
   visual, membership lives in Cmscontent.ParentCmscontentId.
   ---------------------------------------------------------------------------- */
.composer-row-item {
	--cms-container-accent: #8e8e8e;
}

.composer-row-item.cms-container-faktaboks {
	--cms-container-accent: #5e8a63;
}

.composer-row-item.cms-container-tekstboks {
	--cms-container-accent: #4f7cb8;
}

/* Module header card: accent-tinted chrome bar + a thick left edge the children continue. */
.composer-block-card.cms-container-card {
	border-color: color-mix(in srgb, var(--cms-container-accent) 55%, var(--mud-palette-divider));
	border-left: 4px solid var(--cms-container-accent);
}

.composer-block-card.cms-container-card .composer-drag-handle {
	background-color: color-mix(in srgb, var(--cms-container-accent) 22%, var(--mud-palette-surface));
	border-bottom-color: color-mix(in srgb, var(--cms-container-accent) 45%, transparent);
}

.composer-block-card.cms-container-card .composer-drag-handle:hover {
	background-color: color-mix(in srgb, var(--cms-container-accent) 32%, var(--mud-palette-surface));
}

.cms-container-hint {
	color: var(--mud-palette-text-secondary);
}

/* Children (and the footer) sit indented inside the module's bracket. The plus button above a
   child is inside the indented row too, so "insert here" visibly means "inside the module". */
.composer-row-item.composer-in-container {
	margin-left: 28px;
	padding-left: 12px;
	border-left: 3px solid var(--cms-container-accent);
}

.composer-row-item.composer-in-container .composer-block-card {
	border-color: color-mix(in srgb, var(--cms-container-accent) 35%, var(--mud-palette-divider));
}

/* Footer row: slim, muted, closes the bracket. Not draggable — no drag handle, and excluded via
   the SortableJS Filter — but still a sortable sibling so drops above/below it are unambiguous. */
.composer-row-item.composer-container-end {
	border-bottom-left-radius: 6px;
	padding-bottom: 4px;
}

.composer-container-end-bar {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: color-mix(in srgb, var(--cms-container-accent) 80%, var(--mud-palette-text-primary));
	background-color: color-mix(in srgb, var(--cms-container-accent) 12%, var(--mud-palette-surface));
	border: 1px dashed color-mix(in srgb, var(--cms-container-accent) 60%, transparent);
	border-radius: 4px;
	user-select: none;
}

/* "Ikke med i print": a faint hatch tells the journalist the block is web-only. */
.composer-row-item.composer-excluded-from-print .composer-block-card {
	background-image: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--mud-palette-warning) 8%, transparent) 14px 16px);
}

/* Preview: a module renders as the same box as the single-block faktaboks/tekstboks. */
.cms-container {
	background-color: var(--mud-palette-background-gray);
	border-color: #bbb;
}

.cms-print-note {
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #9a6b00;
	margin-bottom: 4px;
}

/* ----------------------------------------------------------------------------
   Mørkt tema: fladerne ovenfor følger paletten, men stregerne og de to
   accentfarver er lyse-tema-farver, som forsvinder mod en mørk flade.
   ---------------------------------------------------------------------------- */
.cms-theme-dark .cms-faktaboks,
.cms-theme-dark .cms-tekstboks,
.cms-theme-dark .cms-container,
.cms-theme-dark .cms-usercontrol {
	border-color: var(--mud-palette-lines-inputs);
}

.cms-theme-dark .cms-usercontrol-label {
	color: var(--cms-success-soft-text);
}

.cms-theme-dark .cms-print-note {
	color: var(--cms-warning-soft-text);
}
