﻿/* #region Employee form — sectioned fields */

/* The employee form used to be one flat three-column dump: every field carried the same visual weight, so
   the working-hours block (an arrangement toggle, dynamic sub-blocks and a provenance history) ended up
   squeezed into a 20rem column next to "Sex" and "Country", running far taller than its neighbours. Grouping
   by concern into named cards fixes that: each card is a unit a person can scan and decide "not my business
   right now", and the two genuinely variable-length blocks (working hours, leave policies) get to be tall
   without unbalancing anything beside them. The card surface itself is not new — it is the same one
   Leave Settings already uses for policy-card and statutory-row, so moving between "Edit Employee" and
   "Leave Policies" does not feel like two different products. */
employee-form-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.25rem;
	width: 100%;
}

employee-form-grid field-group[full-width] {
	grid-column: 1 / -1;
}

@media screen and (max-width: 1200px) {
	employee-form-grid {
		grid-template-columns: 1fr;
	}
}

field-group {
	display: flex;
	flex-direction: column;
	gap: 1.1rem;
	background: var(--blue-gray);
	box-shadow: var(--soft-continer-outer-shadow);
	border-radius: 1rem;
	padding: 1.5rem;
}

field-group h3 {
	font-size: var(--font-size-medium);
	font-weight: 650;
	color: var(--global-font-color);
}

/* The header row: either a lone <h3>, or an <h3> paired with an info tooltip via the app's existing
   .label-with-info row-layout. Both get the same rule beneath them, so a card's title always separates
   cleanly from its fields regardless of which shape it takes. */
field-group > h3,
field-group > row-layout.label-with-info {
	margin: 0;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--border-color);
	width: 100%;
}

field-group > row-layout.label-with-info h3 {
	margin: 0;
}

/* .label-with-info's icon is positioned for a narrow label; stretched across a full card header that reads
   wrong — the icon ends up stranded at the card's far edge instead of beside the words it explains. Here it
   sits back in flow, right after the heading. */
field-group > row-layout.label-with-info svg {
	position: static;
	right: auto;
	margin-left: 0.4rem;
}

/* Leave policy assignments, laid out like the statutory list on the Leave Settings page: a grid of labelled
   rows rather than a vertical stack, so a tenant with a couple of leave types and one with a dozen both read
   the same way instead of the latter turning into a wall. */
field-group leave-policy-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	gap: 0.75rem 1.25rem;
}

field-group assignment-row {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

field-group assignment-row label {
	font-size: var(--font-size-small);
	font-weight: 600;
	color: var(--global-font-color);
}

/* The opening-grant choice under a newly chosen yearly policy (see leavePolicyAssignments.js): the same label-over-
   field rhythm as the row it belongs to, set slightly apart from the policy select it qualifies. */
field-group assignment-row year-grant-choice {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	margin-top: 0.35rem;
}

field-group assignment-row year-grant-choice[hidden] {
	display: none;
}

@media screen and (max-width: 860px) {
	field-group {
		padding: 1.15rem;
	}
}

/* #endregion */

/* #region Working hours — the terms block on the employee form */

/* One block under the employment type, read with it. Custom elements rather than divs with classes, like the rest
   of the module's forms: the tag says what the thing is. */
working-hours-terms {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	width: 100%;
}

working-hours-terms arrangement-block {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	width: 100%;
	padding: 0 0.25rem;
}

working-hours-terms arrangement-block[hidden],
working-hours-terms terms-change[hidden] {
	display: none;
}

/* The house segmented-radio-group sizes to its own content (see the Renew Membership presets it borrows the
   look from); every other control on this form stretches to fill its field, so every radio group on this
   form (working hours' arrangement, sex) is told to as well rather than sitting short with dead space beside
   it. Scoped to the form rather than by id, so a third small fixed-choice field can adopt the same control
   without a third copy of this rule. */
employee-form-grid sl-radio-group {
	width: 100%;
}

employee-form-grid sl-radio-group::part(button-group) {
	width: 100%;
}

employee-form-grid sl-radio-group::part(button-group__base) {
	width: 100%;
}

employee-form-grid sl-radio-group sl-radio-button {
	flex: 1;
}

employee-form-grid sl-radio-group sl-radio-button::part(button) {
	justify-content: center;
}

/* Seven cells, Monday first. Each is a day's hours over its optional start time — the two facts a contract states
   about a working day, in the order a person reads them. */
working-hours-terms weekday-grid {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 0.35rem;
	width: 100%;
}

working-hours-terms weekday-cell {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.25rem;
	min-width: 0;
}

working-hours-terms weekday-name {
	font-size: var(--font-size-tiny);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--light-global-font-color);
	text-align: center;
}

/* Repeated per day rather than a single header naming the two rows: the grid drops from 7 to 4 columns under
   860px (below), and a header pinned to column 1 would stop lining up with the row it names the moment a day
   wraps. A caption on every cell stays correct at any width. */
working-hours-terms weekday-field {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
}

working-hours-terms weekday-field-label {
	font-size: var(--font-size-tiny);
	color: var(--light-global-font-color);
	text-align: center;
}

working-hours-terms weekday-cell input {
	width: 100%;
	min-width: 0;
	padding-left: 0.35rem;
	padding-right: 0.35rem;
	text-align: center;
	font-size: var(--font-size-small);
}

/* The browser's spinner and clock glyphs eat most of a narrow cell; the values are short, so they go. */
working-hours-terms weekday-cell input::-webkit-inner-spin-button,
working-hours-terms weekday-cell input::-webkit-calendar-picker-indicator {
	display: none;
}

working-hours-terms weekday-cell input[type="number"] {
	-moz-appearance: textfield;
	appearance: textfield;
}

/* The derived line — "= 24 h/week over 3 days". The figure people would otherwise type a second time. */
working-hours-terms terms-summary {
	display: block;
	min-height: 1.2em;
	font-size: var(--font-size-small);
	font-weight: 600;
	color: var(--global-font-color);
}

working-hours-terms terms-summary:empty {
	display: none;
}

working-hours-terms terms-change {
	display: block;
	width: 100%;
	padding: 0.25rem 0.25rem 0;
	border-top: 1px dashed var(--border-color);
}

/* The register beneath the block: every set of terms ever recorded, latest first, in the same provenance
   register the entitlement rail uses — what, from when, by whom. */
working-hours-terms terms-history {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	width: 100%;
	padding: 0.25rem 0.25rem 0;
}

working-hours-terms terms-entry {
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
	padding: 0.35rem 0 0.35rem 0.7rem;
	border-left: 2px solid var(--border-color);
	font-size: var(--font-size-small);
	color: var(--light-global-font-color);
	line-height: 1.4;
}

/* Razor renders a bool attribute by presence — in-force="in-force" when true, omitted when false. */
working-hours-terms terms-entry[in-force] {
	border-left-color: var(--primary-green);
	color: var(--global-font-color);
}

working-hours-terms terms-entry[scheduled] {
	border-left-style: dashed;
}

working-hours-terms entry-terms {
	font-weight: 600;
}

working-hours-terms entry-meta {
	font-size: var(--font-size-tiny);
}

@media screen and (max-width: 860px) {
	working-hours-terms weekday-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* #endregion */

/* #region Clocking register — one employee's records, grouped by month */

/* The month is the unit that gets locked and granted from, so it is the unit the table reads in. Each month is its
   own block with the lock state and the whole month's total on its header — the number people look at all month
   is the number the close grants from. */
clocking-register {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	width: 100%;
}

clocking-register clocking-month {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

clocking-register month-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	padding: 0 0.25rem;
}

clocking-register month-title {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

clocking-register month-title h4 {
	margin: 0;
	font-size: var(--font-size-normal);
	font-weight: 600;
}

clocking-register month-total {
	display: flex;
	align-items: baseline;
	gap: 0.75rem;
	flex-wrap: wrap;
}

/* The lock's provenance — closed when, by whom, and the reopen reason if there was one. The same register the
   working-hours history keeps: what, from when, by whom. */
clocking-register month-lock-line {
	display: block;
	padding: 0 0.25rem;
	font-size: var(--font-size-small);
	color: var(--light-global-font-color);
}

/* A closed month reads as settled rather than as an alarm: a padlock and a quieter header, nothing red. */
clocking-register clocking-month[closed] month-title h4 {
	color: var(--light-global-font-color);
}

lock-mark {
	display: inline-flex;
	align-items: center;
	font-size: 1.1em;
	color: var(--light-global-font-color);
}

/* A voided row stays on the page, dimmed and struck through, with the reason beneath its provenance — the record
   happened, and what became of it is part of the record. */
clocking-register tr[voided] td {
	color: var(--light-global-font-color);
	text-decoration: line-through;
	text-decoration-color: color-mix(in srgb, var(--global-font-color) 40%, transparent);
}

clocking-register tr[voided] td provenance-chip,
clocking-register tr[voided] td void-line {
	text-decoration: none;
}

clocking-register void-line {
	display: block;
	margin-top: 0.2rem;
	font-size: var(--font-size-tiny);
	color: var(--light-global-font-color);
}

/* An open shift is the one row that stops a month from closing, so it is marked by a rule down its leading cell
   rather than by colour across the row. */
clocking-register tr[open-shift] td:first-child {
	box-shadow: inset 3px 0 0 var(--primary-green);
}

clocking-register td {
	vertical-align: top;
}

/* #endregion */

/* #region Clocking periods — the page where months are closed */

clocking-periods {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	width: 100%;
}

clocking-periods page-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
	justify-content: flex-end;
}

/* A month still in progress cannot be acted on; it is on the list so the current month is not mistaken for a
   missing one, and it reads quieter for it. */
clocking-periods tr[in-progress] td {
	color: var(--light-global-font-color);
}

clocking-periods tr[closed] td:first-child strong {
	color: var(--light-global-font-color);
	font-weight: 500;
}


/* A folded stretch of months in which nothing was recorded. It sits in the table's own grid, so it is styled
   to read as a seam between months rather than as another month. */
clocking-periods tr[quiet-run] td {
	padding: 0.35rem 1rem;
	background: var(--deep-background-color);
}

clocking-periods tr[quiet-run] sl-details::part(base) {
	border: none;
	background: transparent;
}

clocking-periods tr[quiet-run] sl-details::part(header) {
	padding: 0.35rem 0;
	font-size: var(--font-size-small);
	color: var(--light-global-font-color);
}

clocking-periods tr[quiet-run] sl-details::part(content) {
	padding: 0.25rem 0 0.5rem;
}

clocking-periods quiet-months {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

/* One opened month: its name, and the lock that is the only thing worth doing to a month with nothing in it. */
clocking-periods quiet-month {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	padding: 0.3rem 0.5rem;
	border-radius: var(--small-border-radius, 0.5rem);
	color: var(--light-global-font-color);
}

/* #endregion */

/* #region Month close preview — the modal that shows the grant before it is written */

month-close-preview {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

month-close-preview leave-note ul {
	margin: 0.35rem 0 0;
	padding-left: 1.1rem;
}

/* The review rows in the preview borrow the Needs Review tab's shape without its three-column grid: here each row
   is a name and one sentence. */
month-close-preview review-list {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

month-close-preview review-row {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	padding: 0.7rem 1rem;
	border-radius: 0.65rem;
	background: var(--blue-gray);
	box-shadow: var(--soft-continer-outer-shadow);
	font-size: var(--font-size-small);
}

month-close-preview review-row employee-name {
	font-weight: 600;
	color: var(--global-font-color);
}

/* #endregion */