/* Standard page layout (system/classes/layout.inc.php). Everything is scoped to .bl-page. */

.bl-page {
	--bl-ink: #1e293b;
	--bl-text: #334155;
	--bl-muted: #64748b;
	--bl-line: #dfe3dc;
	--bl-line-soft: #edf0ea;
	--bl-tint: #f8faf7;
	--bl-field: #cbd5e1;
	--bl-action: #334155;
	--bl-action-hover: #1e293b;
	--bl-bar: #475569;
	--bl-bar-hover: #333333;
	--bl-bar-current: #dcebdf;
	--bl-leaf: #2f6b3f;
	--bl-leaf-dark: #1f5130;
	--bl-leaf-soft: #e4f0e7;
	--bl-link: #1d4e89;
	--bl-radius: 4px; /* every control and box; toolbar blocks and the primary button stay square, badges/crumbs are pills */

	padding: 4px 12px 32px;
	color: var(--bl-ink);
	font-size: 14px;
	line-height: 1.45;
	background: #ffffff;
}

/* Undo the old site-wide rules in style.css */
.bl-page p { margin: 0; }
.bl-page li { margin-left: 0; }
.bl-page label { width: auto; padding-left: 0; font-weight: 500; }
.bl-page td { padding-left: 0; }
.bl-page a { font-size: inherit; color: var(--bl-link); }
.bl-page a:hover { font-size: inherit; text-decoration: none; }
.bl-page input:not([type=checkbox]):not([type=radio]),
.bl-page select,
.bl-page textarea {
	height: 40px;
	padding: 0 10px;
	border: 1px solid var(--bl-field);
	border-radius: var(--bl-radius, 4px);
	background: #ffffff;
	color: var(--bl-ink);
	font: inherit;
}
.bl-page textarea { height: auto; padding: 8px 10px; }
.bl-page input:focus,
.bl-page select:focus,
.bl-page textarea:focus {
	width: auto;
	border-color: var(--bl-muted);
	background: #ffffff;
	color: var(--bl-ink);
	outline: 2px solid rgba(51, 65, 85, .25);
	outline-offset: 1px;
}
.bl-page svg.lucide { width: 16px; height: 16px; flex: 0 0 auto; }

.bl-spacer { flex: 1 1 0; }

/* Breadcrumb */
.bl-crumbs {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 6px;
	margin-bottom: 10px;
	background: #ffffff;
	border: 1px solid var(--bl-line);
	border-radius: 999px;
	font-size: 13px;
}
.bl-page .bl-crumb-home {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 999px;
	color: var(--bl-muted);
}
.bl-crumbs .bl-crumb-sep { width: 14px; height: 14px; color: #94a3b8; }
.bl-crumb { padding: 5px 10px; border-radius: 999px; color: #475569; font-weight: 500; }
.bl-page a.bl-crumb { color: #475569; }
.bl-page a.bl-crumb:hover, .bl-page .bl-crumb-home:hover { background: var(--bl-tint); }
.bl-crumb-current { background: var(--bl-leaf-soft); color: var(--bl-leaf-dark); font-weight: 600; }

/* Toolbar: related pages, same blocks as the old .toolbar; current page has an inset line so its size doesn't change */
.bl-toolbar { display: flex; flex-wrap: wrap; gap: 1px; margin-bottom: 12px; background: #eeeeee; font-size: 12px; font-weight: 700; }
.bl-page a.bl-toolbar-item { padding: 13px 20px; line-height: 14px; background: var(--bl-bar); color: #ffffff; text-decoration: none; }
.bl-page a.bl-toolbar-item:hover { background: var(--bl-bar-hover); color: #ffffff; }
.bl-page a.bl-toolbar-item.is-current { box-shadow: inset 0 -4px 0 var(--bl-bar-current); }

/* Header */
.bl-header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 12px; }
.bl-page h1.bl-title { margin: 0; font-size: 26px; font-weight: 700; color: var(--bl-ink); }
.bl-header-meta, .bl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Buttons */
.bl-page .bl-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 40px;
	padding: 0 16px;
	border: 1px solid transparent;
	border-radius: var(--bl-radius, 4px);
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	text-decoration: none;
	white-space: nowrap;
}
.bl-page .bl-btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.bl-page .bl-btn-primary { background: var(--bl-bar); color: #ffffff; border-radius: 0; }
.bl-page .bl-btn-primary:hover { background: var(--bl-bar-hover); color: #ffffff; }
.bl-page .bl-btn-secondary { background: #ffffff; border-color: var(--bl-field); color: var(--bl-text); }
.bl-page .bl-btn-secondary:hover { background: var(--bl-tint); color: var(--bl-ink); }
.bl-page .bl-btn-approve { background: var(--bl-leaf); color: #ffffff; }
.bl-page .bl-btn-approve:hover { background: var(--bl-leaf-dark); color: #ffffff; }
.bl-page .bl-btn-danger { background: #ffffff; border-color: #e3b4ae; color: #9f1d1d; }
.bl-page .bl-btn-danger:hover { background: #fbe9e7; color: #9f1d1d; }
.bl-page .bl-btn:focus-visible { outline: 2px solid rgba(51, 65, 85, .45); outline-offset: 2px; }

/* Status tabs */
.bl-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--bl-line); }
.bl-page .bl-tab {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 44px;
	padding: 0 14px;
	margin-bottom: -1px;
	border-bottom: 2px solid transparent;
	color: #475569;
	font-weight: 500;
	text-decoration: none;
}
.bl-page .bl-tab:hover { color: var(--bl-ink); }
.bl-page .bl-tab.is-active { color: var(--bl-ink); font-weight: 700; border-bottom-color: var(--bl-action); }
.bl-tab-count { padding: 1px 8px; border-radius: 999px; background: #e8ecf2; color: var(--bl-text); font-size: 12px; font-weight: 600; }
.bl-tab.is-active .bl-tab-count { background: var(--bl-ink); color: #ffffff; }

/* Filter bar */
.bl-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.bl-search { position: relative; flex: 1 1 260px; max-width: 380px; }
.bl-search svg.lucide { position: absolute; left: 12px; top: 12px; color: var(--bl-muted); }
/* [type=search] so this outranks the general .bl-page input:not(...) padding */
.bl-page .bl-search input[type=search],
.bl-page .bl-search input[type=search]:focus { width: 100%; padding-left: 36px; box-sizing: border-box; }
.bl-page .bl-select { max-width: 260px; color: var(--bl-text); }

/* Export menu (DataTables Buttons collection) */
.bl-export .dt-buttons { display: flex; }
/* Buttons wraps icon + label in one span, and the bs4 theme adds its own caret */
.bl-export .bl-btn > span { display: inline-flex; align-items: center; gap: 8px; }
.bl-export .dropdown-toggle::after { display: none; }
.bl-export .dt-button-collection,
.bl-page .dt-button-collection {
	min-width: 180px;
	padding: 6px;
	border: 1px solid var(--bl-line);
	border-radius: var(--bl-radius, 4px);
	box-shadow: 0 12px 28px rgba(15, 23, 42, .14);
}
.dt-button-collection .dt-button.bl-menu-item,
.dt-button-collection .bl-menu-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 9px 12px;
	border: 0;
	border-radius: var(--bl-radius, 4px);
	background: transparent;
	color: var(--bl-ink, #1e293b);
	font-size: 14px;
	text-align: left;
}
.dt-button-collection .bl-menu-item:hover { background: #f1f4ef; }

/* Notices */
.bl-notice { margin-bottom: 12px; padding: 12px 16px; border: 1px solid var(--bl-line); border-radius: var(--bl-radius, 4px); background: var(--bl-tint); color: var(--bl-text); }
.bl-notice-warning { background: #fdf3dc; border-color: #f0d9a8; color: #7a4d00; }
.bl-notice-danger { background: #fbe9e7; border-color: #e3b4ae; color: #9f1d1d; }

/* Summary cards: one figure each, related detail in the note line */
.bl-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.bl-stat { padding: 14px 16px; background: #ffffff; border: 1px solid var(--bl-line); border-radius: var(--bl-radius, 4px); }
.bl-stat-label { margin-bottom: 6px; color: var(--bl-muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.bl-stat-value { color: var(--bl-ink); font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.bl-stat-unit { color: var(--bl-muted); font-size: 13px; font-weight: 400; }
.bl-stat-note { margin-top: 4px; color: var(--bl-muted); font-size: 12px; }
.bl-stat.is-flagged { background: #fbe9e7; border-color: #e3b4ae; }
.bl-stat.is-flagged .bl-stat-label, .bl-stat.is-flagged .bl-stat-value { color: #9f1d1d; }
a.bl-stat-link { display: block; color: inherit; text-decoration: none; }
a.bl-stat-link:hover { border-color: #475569; text-decoration: none; }
a.bl-stat-link.is-flagged:hover { border-color: #9f1d1d; }

/* table.bl-table stays hidden until BL.table() has set it up, so raw rows never flash; shown after 3s regardless in case the script fails */
@keyframes bl-reveal { to { opacity: 1; } }
.bl-card table.bl-table:not(.dataTable) { opacity: 0; animation: bl-reveal 0s 3s forwards; }
.bl-card table.bl-table.dataTable { animation: bl-fade-in .15s ease-out; }
@keyframes bl-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Table card */
.bl-card { background: #ffffff; border: 1px solid var(--bl-line); border-radius: var(--bl-radius, 4px); overflow-x: auto; overflow-y: hidden; }
/* Sort arrow always just after the heading; DataTables puts it on the left for numeric columns */
.bl-card thead th div.dt-column-header { justify-content: flex-start; gap: 6px; }
.bl-card thead th.bl-num div.dt-column-header,
.bl-card thead th.dt-type-numeric div.dt-column-header { flex-direction: row; justify-content: flex-end; }
.bl-card table { width: 100% !important; margin: 0 !important; border-collapse: collapse !important; border: 0 !important; }
.bl-card table thead th {
	padding: 12px !important;
	background: var(--bl-tint);
	border: 0 !important;
	border-bottom: 1px solid var(--bl-line) !important;
	color: #475569;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	white-space: nowrap;
}
.bl-card table tbody td {
	padding: 10px 12px !important;
	border: 0 !important;
	border-bottom: 1px solid var(--bl-line-soft) !important;
	background: #ffffff !important;
	box-shadow: none !important;
	vertical-align: middle;
}
.bl-card table tbody tr:hover td { background: var(--bl-tint) !important; }
.bl-card table tfoot td { padding: 10px 12px !important; border: 0 !important; border-top: 2px solid var(--bl-line) !important; background: var(--bl-tint); color: var(--bl-ink); font-weight: 700; }
.bl-card .bl-num { text-align: right; font-variant-numeric: tabular-nums; }
.bl-card .bl-sub { display: block; margin-top: 2px; color: var(--bl-muted); font-size: 12px; }
/* Expandable rows (data-bl-detail, see BL.table); the detail table sits on a tint */
.bl-card tr[data-bl-detail] { cursor: pointer; }
.bl-card tr[data-bl-detail] > td:first-child::before { content: '\25B8'; display: inline-block; width: 1.1em; color: #475569; }
.bl-card tr[data-bl-detail].is-open > td:first-child::before { content: '\25BE'; }
.bl-card table.bl-detail td { background: var(--bl-tint) !important; }
/* Row that needs attention (e.g. an unknown grade); amber like Pending */
.bl-card table tbody tr.is-flagged td { background: #fdf3dc !important; }
.bl-card table tbody tr.is-flagged:hover td { background: #fbecc4 !important; }
/* Many figure columns: tighter cells; the card scrolls sideways */
.bl-card table.bl-table-wide { font-size: 13px; }
.bl-card table.bl-table-wide thead th { padding: 8px 10px !important; }
.bl-card table.bl-table-wide tbody td, .bl-card table.bl-table-wide tfoot td { padding: 8px 10px !important; white-space: nowrap; }
.bl-page .bl-row-link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--bl-link);
	font-weight: 600;
	text-align: left;
	cursor: pointer;
}
.bl-card .dt-layout-row { margin: 0 !important; padding: 12px 16px; border-top: 1px solid var(--bl-line-soft); color: var(--bl-muted); font-size: 13px; }
.bl-card .dt-layout-row.dt-layout-table { padding: 0; border-top: 0; }
.bl-card .dt-length label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.bl-page .bl-card .dt-length select { height: 32px; }
/* Footer: info left, rows-per-page + paging right, one line */
.bl-card .dt-layout-row:not(.dt-layout-table) { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px !important; }
.bl-card .dt-layout-row > .dt-layout-cell { padding: 0; }
.bl-card .dt-layout-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 16px; margin-left: auto; }

/* Paging: undo the old .pagination rules in style.css/dashboard.css (121px bordered li boxes) and Bootstrap's blue links */
.bl-card .dt-paging .pagination { display: flex; gap: 4px; height: auto; margin: 0; padding: 0; }
.bl-card .dt-paging .page-item { display: block; float: none; width: auto; height: auto; margin: 0; padding: 0; border: 0; }
.bl-card .dt-paging .page-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 32px;
	height: 32px;
	margin: 0;
	padding: 0 10px;
	border: 1px solid var(--bl-field);
	border-radius: var(--bl-radius, 4px) !important;
	background: #ffffff;
	color: var(--bl-text);
	font-size: 13px;
	line-height: 1;
}
.bl-card .dt-paging .page-link:hover { background: var(--bl-tint); color: var(--bl-ink); }
.bl-card .dt-paging .page-link:focus { box-shadow: 0 0 0 2px rgba(51, 65, 85, .25); }
.bl-card .dt-paging .page-item.active .page-link { background: var(--bl-bar); border-color: var(--bl-bar); color: #ffffff; }
.bl-card .dt-paging .page-item.disabled .page-link { background: #ffffff; border-color: var(--bl-line-soft); color: var(--bl-field); cursor: default; }

/* Badges */
.bl-badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.bl-badge-approved  { background: #e4f0e7; color: #1f5130; }
.bl-badge-pending   { background: #fdf3dc; color: #7a4d00; }
.bl-badge-rejected  { background: #fbe9e7; color: #9f1d1d; }
.bl-badge-suspended { background: #e8ecf2; color: #334155; }
.bl-badge-edited    { background: #e0f2f1; color: #115e59; }
.bl-badge-terminated { background: #334155; color: #ffffff; }
.bl-badge-returning { background: #e6eef8; color: #1d4e89; }
.bl-badge-new       { background: #f3e8d6; color: #6b4513; }
.bl-badge-neutral   { background: #f1f5f9; color: #475569; }

/* Selection bar */
.bl-bulk { display: none; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--bl-radius, 4px); background: var(--bl-ink); color: #ffffff; }
.bl-bulk.is-visible { display: flex; }
.bl-bulk-note { color: #cbd5e1; }

/* Side panel (BL.panel) */
.bl-scrim[hidden], .bl-panel[hidden] { display: none; }
.bl-scrim { position: fixed; inset: 0; z-index: 1040; background: rgba(15, 23, 42, .28); }
.bl-panel {
	padding: 0;
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 1041;
	display: flex;
	flex-direction: column;
	width: 440px;
	max-width: 100%;
	background: #ffffff;
	box-shadow: -12px 0 32px rgba(15, 23, 42, .16);
	color: #1e293b;
	font-size: 14px;
}
.bl-panel-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px; border-bottom: 1px solid #edf0ea; }
.bl-panel-title { flex: 1 1 0; min-width: 0; margin: 0; font-size: 20px; font-weight: 700; }
.bl-panel-close { width: 36px; height: 36px; border: 0; border-radius: var(--bl-radius, 4px); background: transparent; color: #475569; cursor: pointer; }
.bl-panel-close:hover { background: #f1f4ef; }
.bl-panel-body { flex: 1 1 0; overflow-y: auto; padding: 20px 24px; }
.bl-panel-foot:empty { display: none; }
.bl-panel-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 24px; border-top: 1px solid #edf0ea; }

/* Toast (BL.toast) */
.bl-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 1050;
	transform: translateX(-50%);
	padding: 12px 18px;
	border-radius: var(--bl-radius, 4px);
	background: #1f5130;
	color: #ffffff;
	font-weight: 600;
	box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
}

@media (max-width: 640px) {
	.bl-page { padding: 0 0 24px; }
	.bl-search { max-width: none; }
}
