/*
 * The ordering workflow's list pages (migration order 6): orders first, then manage baskets, bookshelves,
 * saved searches, ISBN lists and invoices, moving to the design system. Each page is inside .managePage
 * (templates/peters/order/manage.html.twig, peters/basket/manage.html.twig, peters/basket/forSchool/,
 * peters/bookshelf/, peters/savedSearch/, peters/isbn/, peters/invoice/, peters/reports/).
 *
 * Not basket.css, which is legacy CSS. Loaded on every main-site page, like checkout.css. Unlayered, so
 * these rules win over everything in the legacy layer, including legacy rules on IDs: keep selectors
 * scoped and set only the properties that need to change. Colours are changed in default.css in place,
 * so the legacy cascade between its rules is unchanged.
 */

/* Keyboard focus. Legacy CSS removes the outline from fields. */
.managePage :focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

/* Links in text are underlined, as in the style guide (.ds-link): steel is too close to the text colour
   for colour alone to show them */
.managePage p a {
	text-decoration: underline;
}

/* Sentence case and the page's font: legacy CSS puts every button in capitals, and browsers give
   <button>s their own font */
.managePage button {
	text-transform: none;
	font-family: inherit;
}

/* Controls that were links without an href, clickable cells or icons, and are now buttons: no button
   look. Not scoped to .managePage: the order tracking modal (components/orderTracking.js) is on the
   invoices, ISBN lists and cancellations pages too. */
.managePlainButton {
	background: none;
	border: 0;
	margin: 0;
	padding: 0;
	width: auto;
	font: inherit;
	color: inherit;
	line-height: inherit;
	text-align: inherit;
	text-transform: none;
	cursor: pointer;
}

.managePlainButton:hover {
	background: none;
}

.managePlainButton:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

/* Buttons that look like links (Cancel on an order line, which was a link) */
.manageLinkButton {
	color: var(--color-primary);
	text-decoration: underline;
}

.manageLinkButton:hover {
	color: var(--color-primary-hover);
}

/* The order tracking modal's branch toggle was a clickable cell: keep it a 24px target */
.orderBranchesToggle {
	min-width: 24px;
	min-height: 24px;
}

/* Cancel on an order line asks first, in its cell (orderTracking.js): the question and its two buttons, 24px
   targets */
.orderCancelConfirm {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0 12px;
}

.orderCancelConfirm .managePlainButton {
	min-height: 24px;
}

/* Date fields (datepicker.mjs): the calendar opens from a button in the field, where the icon was */
.datepickerContainer .ui-datepicker-trigger {
	position: absolute;
	right: 4px;
	top: 0;
	bottom: 0;
	margin: auto 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	height: 24px;
	color: var(--color-text);
}

/* jQuery UI's calendar, added at the end of <body> on any page with one, so not scoped. Weekday names in steel
   (Peters blue was 3.3:1 at their size) and days 24px high (they were 21px). */
.ui-datepicker th {
	color: var(--color-primary);
}

.ui-datepicker td .ui-state-default {
	box-sizing: border-box;
	min-height: 24px;
	line-height: 20px;
}

/* jQuery UI in dark mode (the calendar, and autocomplete lists such as schools' baskets'): its theme
   (jquery-ui.min.css, legacy layer) is white with grey and bright blue states. Light is left as it is. */
[data-theme="dark"] .ui-widget-content {
	border-color: var(--color-border);
	background: var(--color-surface);
	color: var(--color-text);
}

[data-theme="dark"] .ui-widget-content a,
[data-theme="dark"] .ui-widget-header a {
	color: inherit;
}

[data-theme="dark"] .ui-widget-header {
	border-color: var(--color-border);
	background: var(--color-bg-subtle);
	color: var(--color-text);
}

[data-theme="dark"] .ui-state-default {
	border-color: var(--color-border);
	background: var(--grey-100);
	color: var(--color-text);
}

[data-theme="dark"] .ui-state-hover,
[data-theme="dark"] .ui-state-focus {
	border-color: var(--color-primary);
	background: var(--grey-200);
	color: var(--color-text);
}

[data-theme="dark"] .ui-state-active {
	border-color: var(--color-primary);
	background: var(--color-primary);
	color: var(--color-on-primary);
}

[data-theme="dark"] .ui-state-highlight {
	border-color: var(--color-warning);
	background: var(--color-warning-bg);
	color: var(--color-text);
}

/* The sort order icon is a button now (it was the icons, in a label with display: inline-block in its
   style attribute, which kept it beside the dropdown) */
.managePage .orderFilters .sortOrderLabel {
	display: inline-block;
}

.managePage .sortOrderLabel .sortOrderIcon {
	display: inline-flex;
	align-items: center;
	min-height: 24px;
	color: var(--color-text);
}

/* Filters: the layout tables' cells hold <label>s now. Legacy CSS makes labels blocks with a margin. */
.managePage .orderFilters label {
	display: inline;
	margin: 0;
	font-weight: inherit;
	font-size: inherit;
	color: inherit;
}

/* Column headings that sort (Tablesort) are buttons now, so the keyboard can sort: they keep the heading's
   look */
.managePage .manageSortButton {
	font-weight: inherit;
}

/* Page links of lists paged in the browser, hidden with one page (dsPagination.html.twig) */
.managePage .pagination nav[hidden] {
	display: none;
}

/* The cancellations report's section headings: steel, as Peters blue at their size fails contrast (3.3:1) */
.managePage .eventTitle {
	color: var(--color-primary);
}

/* The reports dashboard's charts (components/dashboard.js): each has its figures in a table below it, behind
   "Show the figures" */
.managePage .dashboardFigures {
	margin: var(--space-2, 8px) auto var(--space-6, 24px);
	max-width: 40rem;
}

.managePage .dashboardFigures summary {
	display: inline-flex;
	align-items: center;
	min-height: 24px;
	color: var(--color-primary);
	text-decoration: underline;
	cursor: pointer;
}

.managePage .dashboardFigures summary:hover {
	color: var(--color-primary-hover);
}

.managePage .dashboardFigures table {
	margin-top: var(--space-2, 8px);
}

.managePage .dashboardLegendText {
	color: var(--color-text);
}

/* Results per page: a <label> now (it was a <div>) */
.managePage .pagination .info label.bppText {
	display: inline;
	margin: 0 5px 0 0;
}

/* On phones the list's table keeps basket.css's layout, which wraps each row to the screen's width (the
   CMS template's phone rule no longer flattens it, default.css). No scrolling box: it would clip the
   export menu that opens below the last row. */
@media (max-width: 768px) {
	/* Filters: each label beside its field. The CMS template's phone rule used to flatten the layout
	   table into one column, all the labels first. */
	.managePage .orderFilters,
	.managePage .orderFilters tbody {
		display: block;
	}

	.managePage .orderFilters tr {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
	}

	.managePage .orderFilters td {
		box-sizing: border-box;
		padding: 4px 0;
	}

	.managePage .orderFilters td:nth-child(odd) {
		flex: 0 0 40%;
	}

	.managePage .orderFilters td:nth-child(even) {
		flex: 0 0 60%;
	}
}

/* Wider screens fit the table: no scrolling box, which would also clip the school name's tooltip on manage
   schools' baskets */
@media (min-width: 769px) {
	.managePage .ds-table-wrap {
		overflow: visible;
	}
}

/* Tables in a .ds-table-wrap (manage baskets) scroll sideways on phones, as the style guide's do. Below
   425px default.css makes every basket table's rows wrapping flex boxes, for the shopping basket: here the
   header row wrapped while the list's rows (shown and hidden by Index.filterByLimit() with an inline
   display) didn't, so headings and cells no longer lined up and the actions were cut off. */
@media (max-width: 768px) {
	/* The box positioned things in the table (the bookshelf previews) are placed in, so it scrolls them too:
	   they made the page wider than the screen, past what it can scroll to */
	.managePage .ds-table-wrap {
		position: relative;
	}

	.managePage .ds-table-wrap table.basketTable tr {
		display: table-row;
	}

	.managePage .ds-table-wrap table.basketTable td,
	.managePage .ds-table-wrap table.basketTable th {
		flex: none;
	}

	/* A row's actions stay on one line (basket.css wraps them below 1100px): wrapped into the narrow
	   column, each row was over 250px tall */
	.managePage .ds-table-wrap .btn-group {
		flex-wrap: nowrap;
	}

	/* Report summaries fit the screen: basket.css gives their values at least 340px */
	.managePage table.topData tr > td:nth-child(2) {
		min-width: 0;
	}
}

/* Export menus (exportDropdown.html.twig, manageList.mjs): open only while their button says so. Legacy
   CSS opened them while the button had focus, and Tab closed them before reaching a download. */
.managePage .exportDropdown:not(.active) .dropdown-toggle:focus + .menu {
	display: none;
}

.managePage .exportDropdown.active .menu {
	display: block;
}

/* Their choices: the link colour on white (Peters blue was 3.3:1), white on steel when picked */
.managePage .exportDropdown .menu-item .btn,
.managePage .exportDropdown .menu-item a {
	color: var(--color-primary);
}

/* The invoices page's bib. data for the period are plain links: Peters blue on light blue (1.7:1) when
   focused or hovered */
.managePage .exportDropdown .menu-item .btn:hover,
.managePage .exportDropdown .menu-item .btn:focus-visible,
.managePage .exportDropdown .menu-item a:hover,
.managePage .exportDropdown .menu-item a:focus-visible {
	color: var(--color-on-primary);
	background: var(--color-primary);
}
