/*
 * Business Process Portal — shared look.
 *
 * The parts of the interface that look the same on every screen and in every theme:
 * panels, item names as links, row actions, filter bars, the "danger" look for buttons
 * that delete, file choosers and dates. Loaded on every plugin screen (wp-admin, the
 * front-end portal and the shortcode lists) by BPP_Theme::enqueue_brand_assets(), before
 * the active theme's own stylesheet.
 *
 * The three themes differ in colour and corner radius only. Each sets the `--bpp-ui-*`
 * values below; every rule in this file is written once against them.
 */

/* ---------- Theme values ---------- */
.wrap,
.bpp-portal {
	/* Standard theme: WordPress admin's own palette. */
	--bpp-ui-border: #c3c4c7;
	--bpp-ui-line: #dcdcde;
	--bpp-ui-surface: #fff;
	--bpp-ui-head: #f6f7f7;
	--bpp-ui-radius: 4px;
	--bpp-ui-control-radius: 3px;
	--bpp-ui-text: #1d2327;
	--bpp-ui-soft: #50575e;
	--bpp-ui-link: #2271b1;
	--bpp-ui-link-hover: #135e96;
	--bpp-ui-danger: #b32d2e;
	--bpp-ui-danger-bg: #fcf0f1;
	--bpp-ui-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.bpp-theme {
	--bpp-ui-border: var(--bpp-border);
	--bpp-ui-line: var(--bpp-border);
	--bpp-ui-surface: var(--bpp-surface);
	--bpp-ui-head: var(--bpp-mist);
	--bpp-ui-radius: var(--bpp-radius-card);
	--bpp-ui-control-radius: var(--bpp-radius-pill);
	--bpp-ui-text: var(--bpp-ink);
	--bpp-ui-soft: var(--bpp-text-soft);
	--bpp-ui-link: var(--bpp-teal-deep);
	--bpp-ui-link-hover: var(--bpp-action-fill);
	--bpp-ui-danger: #b3261e;
	--bpp-ui-danger-bg: #fdf1f0;
	--bpp-ui-shadow: var(--bpp-shadow-card);
}

.ft-theme {
	--bpp-ui-border: var(--ft-grey-tint);
	--bpp-ui-line: var(--ft-grey-tint);
	--bpp-ui-surface: var(--ft-white);
	--bpp-ui-head: #f8f4fc;
	--bpp-ui-radius: var(--ft-radius-md);
	--bpp-ui-control-radius: var(--ft-radius-pill);
	--bpp-ui-text: var(--ft-dark);
	--bpp-ui-soft: var(--ft-body-text);
	--bpp-ui-link: #6a00c4;
	--bpp-ui-link-hover: var(--ft-dark);
	--bpp-ui-danger: #c4002b;
	--bpp-ui-danger-bg: #fff0f3;
	--bpp-ui-shadow: var(--ft-shadow-sm);
}

/* ---------- Panels: one box style for every group of controls ----------
   `.bpp-panel` is the box; a heading placed first inside it becomes its title bar. The
   System Settings groups (direct children of .bpp-settings-groups) are panels too.
   `!important` on margin and padding beats per-screen rules and the themes' card class. */
.bpp-panel,
.bpp-settings-groups > div {
	margin: 0 0 16px !important;
	padding: 14px 18px 16px !important;
	background: var(--bpp-ui-surface);
	border: 1px solid var(--bpp-ui-border);
	border-radius: var(--bpp-ui-radius);
	box-shadow: var(--bpp-ui-shadow);
	box-sizing: border-box;
}

.bpp-panel > h2:first-child,
.bpp-panel > h3:first-child,
.bpp-settings-groups > div > h2:first-child,
.bpp-settings-groups > .bpp-theme-settings h2 {
	margin: -14px -18px 12px !important;
	padding: 10px 18px !important;
	font-size: 14px !important;
	font-weight: 700;
	line-height: 1.3;
	color: var(--bpp-ui-text);
	background: var(--bpp-ui-head);
	border-bottom: 1px solid var(--bpp-ui-line);
	border-radius: var(--bpp-ui-radius) var(--bpp-ui-radius) 0 0;
}

/* Sub-headings inside a panel. */
.bpp-panel h3:not(:first-child),
.bpp-settings-groups > div h3 {
	margin: 20px 0 8px;
	padding-top: 14px;
	border-top: 1px solid var(--bpp-ui-line);
	font-size: 13px;
}

.bpp-panel > :last-child,
.bpp-settings-groups > div > :last-child {
	margin-bottom: 0 !important;
}

/* A panel with nothing but a row of controls (filter bars, the model's export bar). */
.bpp-panel.bpp-panel--bar {
	padding: 10px 14px !important;
}

/* A table directly inside a panel runs edge to edge under the title bar. */
.bpp-panel > table {
	margin-top: 0;
}

/* ---------- Item names are links, not buttons ---------- */
.wrap a.bpp-item-link,
.bpp-portal a.bpp-item-link {
	display: inline;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	font-weight: 600;
	line-height: 1.4;
	color: var(--bpp-ui-link);
	text-decoration: none;
	overflow-wrap: break-word;
}

/* The name column keeps a readable width however many columns sit beside it. */
.wrap td:has(> a.bpp-item-link),
.bpp-portal td:has(> a.bpp-item-link) {
	min-width: 11em;
}

.wrap a.bpp-item-link:hover,
.wrap a.bpp-item-link:focus,
.bpp-portal a.bpp-item-link:hover,
.bpp-portal a.bpp-item-link:focus {
	color: var(--bpp-ui-link-hover);
	text-decoration: underline;
}

/* ---------- Row actions stay on one line ----------
   Small buttons, never wrapped. Each list sits in a container that knows its own width;
   where that is too narrow for every action, Duplicate and Delete fold under "More".

   "More" needs no script: `.bpp-more` shows its menu while anything inside it has the
   focus and closes when the focus leaves. tabindex="-1" on the wrapper lets Safari,
   which does not focus a button on click, focus the wrapper instead. */
.wrap.bpp-models,
.bpp-explorer-main,
.bpp-portal-screen {
	container-type: inline-size;
}

.wrap td.bpp-row-actions,
.bpp-portal td.bpp-row-actions {
	display: table-cell;
	white-space: nowrap;
	width: 1%;
}

.wrap td.bpp-row-actions > *,
.bpp-portal td.bpp-row-actions > * {
	display: inline-flex;
	vertical-align: middle;
	margin: 0 3px 0 0;
}

.wrap td.bpp-row-actions > :last-child,
.bpp-portal td.bpp-row-actions > :last-child {
	margin-right: 0;
}

.bpp-theme td.bpp-row-actions .bpp-btn,
.ft-theme td.bpp-row-actions .ft-btn {
	min-height: 24px;
	padding: 0 8px;
	font-size: 12px;
}

/* Wide enough: no "More", its two actions sit in the row. */
.bpp-more {
	position: relative;
	outline: 0;
}

/* Selectors carry the cell so they outrank the themes' own button and form rules. */
.wrap td.bpp-row-actions .bpp-more .bpp-more-toggle,
.bpp-portal td.bpp-row-actions .bpp-more .bpp-more-toggle {
	display: none;
}

.wrap td.bpp-row-actions .bpp-more-menu,
.bpp-portal td.bpp-row-actions .bpp-more-menu {
	display: inline;
}

.wrap td.bpp-row-actions .bpp-more-menu > *,
.bpp-portal td.bpp-row-actions .bpp-more-menu > * {
	display: inline-flex;
	vertical-align: middle;
	margin: 0 3px 0 0;
}

.wrap td.bpp-row-actions .bpp-more-menu > :last-child,
.bpp-portal td.bpp-row-actions .bpp-more-menu > :last-child {
	margin-right: 0;
}

.bpp-more:empty {
	display: none;
}

/* Too narrow: "More" appears and holds Duplicate and Delete. */
@container (max-width: 1060px) {
	.wrap td.bpp-row-actions .bpp-more .bpp-more-toggle,
	.bpp-portal td.bpp-row-actions .bpp-more .bpp-more-toggle {
		display: inline-flex;
	}

	.wrap td.bpp-row-actions .bpp-more-menu,
	.bpp-portal td.bpp-row-actions .bpp-more-menu {
		display: none;
		position: absolute;
		right: 0;
		top: calc(100% + 4px);
		z-index: 20;
		flex-direction: column;
		align-items: stretch;
		gap: 6px;
		min-width: 9em;
		padding: 8px;
		background: var(--bpp-ui-surface);
		border: 1px solid var(--bpp-ui-border);
		border-radius: var(--bpp-ui-radius);
		box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
	}

	.wrap td.bpp-row-actions .bpp-more:focus-within .bpp-more-menu,
	.bpp-portal td.bpp-row-actions .bpp-more:focus-within .bpp-more-menu {
		display: flex;
	}

	.wrap td.bpp-row-actions .bpp-more-menu > *,
	.bpp-portal td.bpp-row-actions .bpp-more-menu > * {
		display: flex;
		margin: 0;
	}

	td.bpp-row-actions .bpp-more-menu button {
		width: 100%;
		justify-content: center;
	}
}

/* In a narrow list the cells sit closer together and the name column gives up some
   width, so a wide list still fits beside the folder tree. */
@container (max-width: 1060px) {
	.wrap table th,
	.wrap table td,
	.bpp-portal table th,
	.bpp-portal table td {
		padding-left: 6px;
		padding-right: 6px;
	}

	.wrap td:has(> a.bpp-item-link),
	.bpp-portal td:has(> a.bpp-item-link) {
		min-width: 8em;
	}

	.wrap .bpp-explorer-main table th,
	.wrap .bpp-explorer-main table td,
	.bpp-portal .bpp-explorer-main table th,
	.bpp-portal .bpp-explorer-main table td {
		padding-left: 5px;
		padding-right: 5px;
	}

	.bpp-col-date {
		min-width: 7.5em;
	}

	.wrap .bpp-documents-table th,
	.wrap .bpp-documents-table td,
	.bpp-portal .bpp-documents-table th,
	.bpp-portal .bpp-documents-table td {
		padding-left: 5px;
		padding-right: 5px;
	}
}

@container (max-width: 1060px) {
	.wrap .bpp-documents-table td.bpp-row-actions .bpp-more .bpp-more-toggle,
	.bpp-portal .bpp-documents-table td.bpp-row-actions .bpp-more .bpp-more-toggle {
		display: inline-flex;
	}

	.wrap .bpp-documents-table td.bpp-row-actions .bpp-more-menu,
	.bpp-portal .bpp-documents-table td.bpp-row-actions .bpp-more-menu {
		display: none;
		position: absolute;
		right: 0;
		top: calc(100% + 4px);
		z-index: 20;
		flex-direction: column;
		align-items: stretch;
		gap: 6px;
		min-width: 9em;
		padding: 8px;
		background: var(--bpp-ui-surface);
		border: 1px solid var(--bpp-ui-border);
		border-radius: var(--bpp-ui-radius);
		box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
	}

	.wrap .bpp-documents-table td.bpp-row-actions .bpp-more:focus-within .bpp-more-menu,
	.bpp-portal .bpp-documents-table td.bpp-row-actions .bpp-more:focus-within .bpp-more-menu {
		display: flex;
	}

	.wrap .bpp-documents-table td.bpp-row-actions .bpp-more-menu > *,
	.bpp-portal .bpp-documents-table td.bpp-row-actions .bpp-more-menu > * {
		display: flex;
		margin: 0;
	}

	.bpp-documents-table td.bpp-row-actions .bpp-more-menu button {
		width: 100%;
		justify-content: center;
	}
}

/* ---------- Buttons that delete or archive: red outline ---------- */
.wrap .bpp-danger,
.bpp-portal .bpp-danger,
.wrap .button.bpp-danger,
.bpp-theme .bpp-btn.bpp-danger,
.ft-theme .ft-btn.bpp-danger {
	background: var(--bpp-ui-surface);
	border-color: var(--bpp-ui-danger);
	color: var(--bpp-ui-danger);
}

.wrap .bpp-danger:hover,
.wrap .bpp-danger:focus,
.bpp-portal .bpp-danger:hover,
.bpp-portal .bpp-danger:focus,
.wrap .button.bpp-danger:hover,
.bpp-theme .bpp-btn.bpp-danger:hover,
.ft-theme .ft-btn.bpp-danger:hover {
	background: var(--bpp-ui-danger-bg);
	border-color: var(--bpp-ui-danger);
	color: var(--bpp-ui-danger);
}

/* ---------- Filter bars: fields first, the button last ---------- */
.wrap .bpp-filter-row,
.bpp-portal .bpp-filter-row,
.bpp-filter-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0;
	float: none;
}

.bpp-filter-bar > *,
.wrap .bpp-filter-row > * {
	margin: 0 !important;
}

/* Fields share the row; the Filter button keeps its own size at the end of it. */
.bpp-portal .bpp-filter-bar > input[type="search"],
.bpp-portal .bpp-filter-bar > select,
.wrap .bpp-filter-row > input,
.wrap .bpp-filter-row > select,
.wrap .bpp-filter-row > .bpp-people-picker,
.bpp-portal .bpp-filter-row > input,
.bpp-portal .bpp-filter-row > select,
.bpp-portal .bpp-filter-row > .bpp-people-picker {
	flex: 1 1 130px;
	width: auto;
	min-width: 110px;
	max-width: 220px;
}

.wrap .bpp-filter-row > .bpp-people-picker input,
.bpp-portal .bpp-filter-row > .bpp-people-picker input {
	width: 100%;
	max-width: none;
}

/* A list never pushes the page sideways: when too wide it scrolls inside its own area. */
.bpp-explorer-main,
.bpp-portal-screen {
	min-width: 0;
	overflow-x: auto;
}

/* ---------- File choosers: the browser's own button, dressed as ours ---------- */
.wrap input[type="file"],
.bpp-portal input[type="file"] {
	max-width: 100%;
	font-size: 13px;
	color: var(--bpp-ui-soft);
}

.wrap input[type="file"]::file-selector-button,
.bpp-portal input[type="file"]::file-selector-button {
	min-height: 28px;
	margin: 0 10px 0 0;
	padding: 0 12px;
	font: inherit;
	font-weight: 600;
	color: var(--bpp-ui-text);
	background: var(--bpp-ui-surface);
	border: 1px solid var(--bpp-ui-border);
	border-radius: var(--bpp-ui-control-radius);
	cursor: pointer;
}

.wrap input[type="file"]::file-selector-button:hover,
.bpp-portal input[type="file"]::file-selector-button:hover {
	background: var(--bpp-ui-head);
}

/* ---------- Dates never break mid-date ----------
   Wide enough for the date on one line; where a table is short of room the time drops
   to a second line. */
.bpp-col-date {
	min-width: 8.5em;
}

/* ---------- Under a screen's title: the way back, and the item's badges ---------- */
.bpp-breadcrumb {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 6px 0 12px;
}

/* ---------- Labelled controls in a bar (the model's export bar) ---------- */
.bpp-bar-field {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 600;
	color: var(--bpp-ui-soft);
}

.wrap .bpp-bar-field select,
.bpp-portal .bpp-bar-field select {
	width: auto;
	min-width: 0;
	max-width: 12em;
}

/* ---------- One pager under every list ---------- */
.bpp-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin: 10px 0 16px;
	font-size: 13px;
}

.bpp-pagination-count {
	color: var(--bpp-ui-soft, #50575e);
}

.bpp-pagination-links .page-numbers {
	display: inline-block;
	min-width: 2em;
	margin-left: 2px;
	padding: 4px 8px;
	box-sizing: border-box;
	border: 1px solid var(--bpp-ui-border, #c3c4c7);
	border-radius: var(--bpp-ui-control-radius, 4px);
	background: var(--bpp-ui-surface, #fff);
	color: var(--bpp-ui-link, #2271b1);
	text-align: center;
	text-decoration: none;
}

.bpp-pagination-links .page-numbers.current {
	border-color: var(--bpp-ui-link, #2271b1);
	background: var(--bpp-ui-link, #2271b1);
	color: #fff;
	font-weight: 600;
}

.bpp-pagination-links .page-numbers.dots {
	border-color: transparent;
	background: transparent;
}

/* ---------- Import forms ----------
   The label/field table drawn in the plugin's own proportions, not WordPress's
   settings-page ones (larger text, wide label column). */
.bpp-import-panel form {
	display: block;
	max-width: none;
}

.bpp-import-panel .form-table {
	margin: 0 0 12px;
	border-collapse: collapse;
}

.bpp-import-panel .form-table th,
.bpp-import-panel .form-table td {
	padding: 12px 0;
	font-size: 13px;
	line-height: 1.5;
	vertical-align: top;
	border-top: 1px solid var(--bpp-ui-line);
}

.bpp-import-panel .form-table tr:first-child th,
.bpp-import-panel .form-table tr:first-child td {
	border-top: 0;
	padding-top: 2px;
}

.bpp-import-panel .form-table th {
	width: 170px;
	padding-right: 16px;
	font-weight: 600;
	color: var(--bpp-ui-text);
}

.bpp-import-panel .form-table td p,
.bpp-import-panel .form-table td .description,
.bpp-import-panel .form-table td li,
.bpp-import-panel .form-table td label {
	font-size: 13px;
}

.bpp-import-panel .form-table td ul {
	margin: 4px 0 8px 1.4em;
	list-style: disc;
}

.bpp-import-panel p.submit {
	margin: 0;
	padding: 0;
}

/* ---------- Fields inside the front-end portal wear the theme too ----------
   portal.css resets every field inside .bpp-portal and outranks the themes' field
   classes; these put the theme's border and corners back. */
.bpp-portal.bpp-theme .bpp-input,
.bpp-portal.bpp-theme .bpp-select,
.bpp-portal.bpp-theme .bpp-textarea,
.bpp-portal .bpp-theme .bpp-input,
.bpp-portal .bpp-theme .bpp-select {
	border: 1px solid var(--bpp-border);
	border-radius: var(--bpp-radius-control);
}

.bpp-portal.ft-theme .ft-input,
.bpp-portal.ft-theme .ft-select,
.bpp-portal.ft-theme .ft-textarea {
	border: 1.5px solid var(--ft-grey-tint);
	border-radius: var(--ft-radius-sm);
}

.bpp-portal .bpp-approved-filter input[type="search"] {
	min-width: 0;
}

/* Standard theme: WordPress's fixed-width list columns cannot grow to hold a row of
   actions, so there the actions may wrap inside their column instead of being cut off. */
.wrap table.fixed td.bpp-row-actions {
	white-space: normal;
	width: auto;
}

.bpp-bar-field select {
	font-weight: 400;
}

/* ---------- Count bubbles on tabs ----------
   After "Awaiting Review" (attention colour) and "Approved" (neutral). Never shown for
   zero. */
.bpp-count {
	display: inline-block;
	min-width: 1.5em;
	margin-left: 6px;
	padding: 0 6px;
	box-sizing: border-box;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.6;
	text-align: center;
	vertical-align: middle;
	text-decoration: none;
}

.bpp-count--attention {
	background: #d63638;
	color: #fff;
}

.bpp-count--neutral {
	background: #dcdcde;
	color: #1d2327;
}

/* ---------- Classification badges ----------
   Shared by documents and models. */
.bpp-classification-badge {
	display: inline-block;
	box-sizing: border-box;
	padding: 1px 8px;
	border-radius: 10px;
	border: 1px solid transparent;
	font-size: 11px;
	font-weight: 600;
	line-height: 16px;
	white-space: nowrap;
	vertical-align: middle;
}

.bpp-classification-level-0 {
	background: #edfaef;
	border-color: #68de7c;
	color: #00450c;
}

.bpp-classification-level-1 {
	background: #fcf9e8;
	border-color: #f0c33c;
	color: #4d3800;
}

.bpp-classification-level-2 {
	background: #fcf0f1;
	border-color: #f86368;
	color: #691c1c;
}

.bpp-classification-level-3 {
	background: #3c434a;
	border-color: #1d2327;
	color: #fff;
}

/* ---------- Dashboard ----------
   Metric boxes: one number over its label. The only coloured mark is the edge of a box
   that needs the person's attention, and that box also says so in words. */
.bpp-metric-group {
	margin: 0 0 20px;
}

.wrap .bpp-metric-heading,
.bpp-portal .bpp-metric-heading {
	margin: 0 0 8px;
	padding: 0;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--bpp-ui-text);
}

.bpp-metric-hint {
	margin: -4px 0 8px !important;
}

.bpp-metrics {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 12px;
}

.wrap .bpp-metric,
.bpp-portal .bpp-metric {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-height: 84px;
	padding: 12px 14px;
	box-sizing: border-box;
	background: var(--bpp-ui-surface);
	border: 1px solid var(--bpp-ui-border);
	border-left: 4px solid var(--bpp-ui-border);
	border-radius: var(--bpp-ui-radius);
	box-shadow: var(--bpp-ui-shadow);
	color: var(--bpp-ui-text);
	text-decoration: none;
}

.wrap a.bpp-metric:hover,
.wrap a.bpp-metric:focus,
.bpp-portal a.bpp-metric:hover,
.bpp-portal a.bpp-metric:focus {
	border-color: var(--bpp-ui-link);
	color: var(--bpp-ui-text);
	text-decoration: none;
	outline: 0;
	box-shadow: 0 0 0 1px var(--bpp-ui-link);
}

.bpp-metric-value {
	font-size: 28px;
	font-weight: 700;
	line-height: 1.15;
	font-variant-numeric: tabular-nums;
	color: var(--bpp-ui-text);
}

.bpp-metric-label {
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--bpp-ui-text);
}

.bpp-metric-note {
	font-size: 12px;
	line-height: 1.3;
	color: var(--bpp-ui-soft);
}

/* Something is waiting for this person: a coloured edge, plus the note in words. */
.wrap .bpp-metric--attention,
.bpp-portal .bpp-metric--attention {
	border-left-color: var(--bpp-ui-danger);
	background: var(--bpp-ui-danger-bg);
}

.bpp-metric--attention .bpp-metric-note {
	color: var(--bpp-ui-danger);
	font-weight: 600;
}

/* The two "last 5 opened" panels sit side by side when there is room. */
.bpp-recent-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
	gap: 16px;
	margin: 0 0 20px;
}

.bpp-recent-grid .bpp-panel {
	margin: 0 !important;
	min-width: 0;
	overflow-x: auto;
}

.bpp-recent-table {
	margin: 0;
	border: 0;
}

@media (max-width: 480px) {
	.bpp-recent-grid {
		grid-template-columns: 1fr;
	}
}

/* The line above a filtered list saying how many it holds, and the open-comment count
   beside a name when a list is filtered to open comments. */
.wrap .bpp-result-count,
.bpp-portal .bpp-result-count {
	margin: 0 0 10px;
	color: var(--bpp-ui-text);
}

.bpp-open-comments-note {
	display: inline-block;
	font-size: 12px;
	color: var(--bpp-ui-soft);
	white-space: nowrap;
}
