/*
 * Internal Group Sales Order Lookup/Update form styling. Depends on
 * hsi-portal-shell.css for design tokens (see wp_register_style() deps in
 * class-hsi-portal-lookup-form-render.php).
 */

.hsi-lookup-form {
	max-width: var(--hsi-form-max);
	margin: 0 auto;
}

.hsi-lookup-form__notes-log {
	max-height: 260px;
	overflow-y: auto;
	padding: var(--hsi-space-3) var(--hsi-space-4);
	background: var(--hsi-neutral-tint);
	border: 1px solid #c9ccd1;
	border-radius: var(--hsi-radius);
	font-size: 0.9em;
	/* white-space: pre-wrap REMOVED (client report 2026-09-17): it was right
	   when the log was one raw text blob, but entries are structured divs
	   now, so it rendered the template's own indentation as huge blank
	   areas. Line breaks INSIDE a note body survive via nl2br(). Left-
	   aligned like every log — the theme's centering made entries float
	   oddly mid-box. */
	white-space: normal;
	text-align: left;
}

.hsi-lookup-form__note-entry {
	padding: var(--hsi-space-2) 0;
	border-bottom: 1px solid #dde1e6;
	/* Left-aligned (client report 2026-09-17) — the theme centered entries. */
	text-align: left;
}

.hsi-lookup-form__note-entry:last-child {
	border-bottom: 0;
}

.hsi-lookup-form__note-meta {
	display: block;
	font-size: 0.8em;
	font-weight: 600;
	color: var(--hsi-navy);
	margin-bottom: 2px;
}

.hsi-lookup-form__banner {
	padding: var(--hsi-space-3) var(--hsi-space-4);
	margin-bottom: var(--hsi-space-4);
	border-radius: var(--hsi-radius);
	border: 1px solid transparent;
}

.hsi-lookup-form__banner--success {
	background: var(--hsi-blue-tint);
	border-color: var(--hsi-blue);
	color: #0c2e4e;
}

.hsi-lookup-form__banner--error {
	background: var(--hsi-red-tint);
	border-color: var(--hsi-red);
	color: #611a15;
}

.hsi-lookup-form__banner ul {
	margin: 0.5em 0 0;
	padding-left: 1.25em;
}

.hsi-lookup-form__api-error {
	font-family: monospace;
	white-space: pre-wrap;
	word-break: break-word;
}

.hsi-lookup-form__search {
	display: flex;
	align-items: flex-end;
	gap: var(--hsi-space-3);
	margin-bottom: var(--hsi-space-6);
	padding-bottom: var(--hsi-space-6);
	border-bottom: 1px solid var(--hsi-neutral-tint);
	width:100%;
}

.hsi-lookup-form__search .hsi-lookup-form__field {
	flex: 1;
	margin-bottom: 0;
}

.hsi-lookup-form__search button {
	flex: 1;
	padding: 10px 20px;
	border-radius: var(--hsi-radius);
	/* Unified button style (client decision 2026-09-11): every portal
	   button is navy/white — the old blue-tint version read like the new
	   display-only fields. */
	border: 1px solid var(--hsi-navy);
	background: var(--hsi-navy);
	color: var(--hsi-white);
	font-weight: 600;
	cursor: pointer;
}

/* Lookup-by-phone/company/contact-name pass (item 3) — multi-match chooser. */
.hsi-lookup-form__search-results {
	margin-bottom: var(--hsi-space-6);
	padding-bottom: var(--hsi-space-6);
	border-bottom: 1px solid var(--hsi-neutral-tint);
}

.hsi-lookup-form__search-results-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95em;
}

.hsi-lookup-form__search-results-table th,
.hsi-lookup-form__search-results-table td {
	padding: var(--hsi-space-2) var(--hsi-space-3);
	text-align: left;
	border-bottom: 1px solid #dde1e6;
}

.hsi-lookup-form__search-results-table th {
	font-weight: 600;
	color: #555;
}

.hsi-lookup-form__search-results-table tr:hover td {
	background: var(--hsi-blue-tint);
}

.hsi-lookup-form__search button:hover {
	background: #10126b;
	border-color: #10126b;
}

/* Booking Details summary card, with a stage-color status pill up top —
   the pill's modifier class is applied in HSI_Portal_Lookup_Form_Render
   using the same hsi-calendar__legend-dot--{key} color_key vocabulary as
   the calendar, so status reads identically everywhere in the portal. */
.hsi-lookup-form__display {
	margin-bottom: var(--hsi-space-6);
	padding: var(--hsi-space-4);
	background: var(--hsi-blue-tint);
	border: 1px solid var(--hsi-blue);
	border-radius: var(--hsi-radius-lg);
}

.hsi-lookup-form__display h3 {
	margin-top: 0;
}

.hsi-lookup-form__status-pill {
	display: inline-flex;
	align-items: center;
	padding: 4px 12px;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	margin-bottom: var(--hsi-space-3);
}

.hsi-lookup-form__display-list {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 0.35em 1em;
	margin: 0;
	width:100%;
}

.hsi-lookup-form__display-list dt {
	font-weight: 600;
	color: #555;
	text-align: right;
}

.hsi-lookup-form__display-list dt::after {
	content: ':';
}

.hsi-lookup-form__display-list dd {
	margin: 0;
	text-align: left;
}

/* Status pill colors — same --hsi-stage-{key} tokens as the calendar
   (see hsi-portal-shell.css), so a booking's stage reads identically here
   and on the calendar. */
.hsi-lookup-form__status-pill--deposit_received { background: var(--hsi-stage-deposit_received-bg); color: var(--hsi-stage-deposit_received-fg); }
.hsi-lookup-form__status-pill--class_scheduled { background: var(--hsi-stage-class_scheduled-bg); color: var(--hsi-stage-class_scheduled-fg); }
.hsi-lookup-form__status-pill--needs_reschedule { background: var(--hsi-stage-needs_reschedule-bg); color: var(--hsi-stage-needs_reschedule-fg); }
.hsi-lookup-form__status-pill--class_completed { background: var(--hsi-stage-class_completed-bg); color: var(--hsi-stage-class_completed-fg); }
.hsi-lookup-form__status-pill--balance_paid_in_full { background: var(--hsi-stage-balance_paid_in_full-bg); color: var(--hsi-stage-balance_paid_in_full-fg); }
.hsi-lookup-form__status-pill--certifications_issued { background: var(--hsi-stage-certifications_issued-bg); color: var(--hsi-stage-certifications_issued-fg); }
.hsi-lookup-form__status-pill--cancelled { background: var(--hsi-stage-cancelled-bg); color: var(--hsi-stage-cancelled-fg); }
.hsi-lookup-form__status-pill--new_inquiry { background: var(--hsi-stage-new_inquiry-bg); color: var(--hsi-stage-new_inquiry-fg); }
.hsi-lookup-form__status-pill--quote_provided { background: var(--hsi-stage-quote_provided-bg); color: var(--hsi-stage-quote_provided-fg); }
.hsi-lookup-form__status-pill--lost { background: var(--hsi-stage-lost-bg); color: var(--hsi-stage-lost-fg); }

/* Manager accordion — section container + clickable header. Chrome only
   renders for managers (see HSI_Portal_Lookup_Form_Render); non-managers get
   the same .hsi-lookup-form__section-body grid, always expanded, with no
   header button. */
.hsi-lookup-form__section {
	margin-bottom: var(--hsi-space-4);
	border: 1px solid var(--hsi-neutral-tint);
	border-radius: var(--hsi-radius-lg);
	overflow: hidden;
}

/* Cancel Order (item 4b) — destructive-styled section, visually distinct
   from the manager accordion's neutral sections above (this one isn't part
   of that accordion, it's a separate always-expanded block with its own
   inner .hsi-lookup-form__cancel-form). */
.hsi-lookup-form__section--danger {
	border-color: var(--hsi-red);
	/* Client-specified (2026-09-09): tint moved here from the header rule
	   below, so the whole Cancel Order card reads as the danger zone. */
	background: var(--hsi-red-tint);
}

.hsi-lookup-form__section--danger > .hsi-lookup-form__section-header {
	/* Client-specified (2026-09-09). SCOPED to the danger section only: the
	   literal request was white on every h3 section header, but for
	   non-manager roles EVERY section header is an h3 on the light neutral
	   band, where white text would be invisible — flagged and narrowed. */
	background: var(--hsi-red);
	color: var(--hsi-white);
}

.hsi-lookup-form__section--danger > h3.hsi-lookup-form__section-header {
	/* !important (client-specified 2026-09-09): a theme heading rule was
	   still out-muscling the scoped selector. */
	color: var(--hsi-white) !important;
}

/* Client-specified (2026-09-09): the danger section's body is a single
   stacked form — the shared 2-column grid left it squeezed into half the
   card width. */
.hsi-lookup-form__section--danger .hsi-lookup-form__section-body {
	display: block;
}

.hsi-lookup-form__cancel-form .hsi-lookup-form__field {
	/* Client revision 2026-09-09: full-width single-column stack (was 480px). */
	max-width: 100%;
}

.hsi-lookup-form__section-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: var(--hsi-space-3) var(--hsi-space-4);
	background: var(--hsi-neutral-tint);
	border: 0;
	font-family: var(--hsi-font-head);
	/* Client-specified (2026-09-09), was 1rem. */
	font-size: 1.8rem;
	font-weight: 600;
	color: var(--hsi-navy);
	cursor: pointer;
	text-align: left;
}

.hsi-lookup-form__section-header:disabled,
.hsi-lookup-form__section > h3.hsi-lookup-form__section-header {
	cursor: default;
	color: var(--hsi-navy);
}

.hsi-lookup-form__section-chevron {
	transition: transform 0.15s ease;
	flex: none;
	margin-left: var(--hsi-space-3);
}

.hsi-lookup-form__section[data-collapsed='true'] .hsi-lookup-form__section-chevron {
	transform: rotate(-90deg);
}

.hsi-lookup-form__section-body {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0 var(--hsi-space-4);
	padding: var(--hsi-space-4);
}

.hsi-lookup-form__section[data-collapsed='true'] .hsi-lookup-form__section-body {
	display: none;
}

@media (max-width: 720px) {
	.hsi-lookup-form__section-body {
		grid-template-columns: 1fr;
	}
}

.hsi-lookup-form__field {
	margin-bottom: var(--hsi-space-4);
	min-width: 0;
}

.hsi-lookup-form__section-body > .hsi-lookup-form__field:last-child {
	margin-bottom: 0;
}

/* .hsi-form-row (shared with the Order Completed form, see
   hsi-portal-shell.css) sits directly among .hsi-lookup-form__field
   siblings here, so it needs the same bottom margin those get from the
   section-body's zero row-gap. */
.hsi-lookup-form__section-body .hsi-form-row {
	margin-bottom: var(--hsi-space-4);
}

.hsi-lookup-form__section-body > .hsi-form-row:last-child {
	margin-bottom: 0;
}

/* The training_location address block (street field + address row) isn't
   itself a .hsi-lookup-form__field, so it needs the same bottom margin too. */
.hsi-lookup-form__conditional[data-hsi-lookup-address-field] {
	margin-bottom: var(--hsi-space-4);
}

.hsi-lookup-form__field label {
	display: block;
	font-weight: 600;
	margin-bottom: var(--hsi-space-1);
}

.hsi-lookup-form__field input[type='text'],
.hsi-lookup-form__field input[type='email'],
.hsi-lookup-form__field input[type='url'],
.hsi-lookup-form__field input[type='number'],
.hsi-lookup-form__field input[type='date'],
.hsi-lookup-form__field select,
.hsi-lookup-form__field textarea {
	width: 100%;
	max-width: 100%;
}

/* Long/structural items span both columns. */
.hsi-lookup-form__field--radio,
.hsi-lookup-form__conditional,
.hsi-lookup-form__field:has(textarea),
.hsi-lookup-form__field--submit {
	grid-column: 1 / -1;
}

/*
 * Field-level capability gating (hide-inaccessible-inputs pass, item 2):
 * fields a role cannot edit are now omitted from the markup entirely (see
 * templates/partials/lookup-form.php's own docblock) rather than rendered
 * disabled — this rule now only covers genuinely disabled controls
 * unrelated to capability (e.g. the "Existing instructor confirmed the new
 * date" radio, disabled when no instructor is currently on file). Kept for
 * that case; no longer reachable via a capability gate.
 */
.hsi-lookup-form__field input:disabled,
.hsi-lookup-form__field select:disabled,
.hsi-lookup-form__field textarea:disabled,
.hsi-lookup-form__field--radio:disabled,
.hsi-lookup-form__field--radio:disabled .hsi-lookup-form__radio-option,
.hsi-lookup-form__field--checkbox:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

/* Destructive-controls pass (item 3) — current-value display shown next to
   the Clear Training Date & Time button, inline rather than stacked. */
.hsi-lookup-form__field--inline {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--hsi-space-3);
}

.hsi-lookup-form__current-value {
	font-weight: 600;
	color: #555;
}

.hsi-lookup-form__field--checkbox label {
	display: flex;
	align-items: flex-start;
	gap: 0.5em;
	font-weight: normal;
}

.hsi-lookup-form__radio-option {
	display: flex;
	align-items: center;
	gap: 0.4em;
	font-weight: normal;
}

/* The old "same as company address" assist highlight was REMOVED
   (client decision 2026-09-11): with the blue-tint style now meaning
   "display-only", a tinted radio read as something else entirely — every
   radio option renders identically. */

.hsi-lookup-form__confirm-attendees {
	padding: var(--hsi-space-3) var(--hsi-space-4);
	background: var(--hsi-neutral-tint);
	border: 1px solid #c9ccd1;
	border-radius: var(--hsi-radius);
}

.hsi-lookup-form__required {
	color: var(--hsi-red);
}

.hsi-lookup-form__hint {
	margin: 0;
	/* Client-specified (2026-08-06): field text and notes uniform at 1em. */
	font-size: 1em;
	font-weight: normal;
}

.hsi-lookup-form__hint--found {
	color: #0c2e4e;
}

.hsi-lookup-form__hint--not-found {
	color: #555;
}

.hsi-lookup-form__hint--error {
	color: var(--hsi-red);
}

/* Instructions are instructions (client decision 2026-09-11): plain body
   text, left-aligned — no faded gray, no italics. Italic + gray stays
   reserved for the NOTE convention. */
.hsi-lookup-form__instruction {
	margin: 0 0 var(--hsi-space-4);
	font-size: 1em;
	font-style: normal;
	color: inherit;
	text-align: left;
}

.hsi-lookup-form__field--submit {
	margin-top: var(--hsi-space-2);
}

.hsi-lookup-form__field--submit button {
	padding: 10px 24px;
	border-radius: var(--hsi-radius);
	border: 1px solid var(--hsi-navy);
	background: var(--hsi-navy);
	color: var(--hsi-white);
	font-weight: 600;
	cursor: pointer;
}

.hsi-lookup-form__field--submit button:hover {
	background: #10126b;
	border-color: #10126b;
}

/* Standard NOTE block (client convention 2026-09-09): bold "NOTE:" + italic
   text, always left-aligned. */
.hsi-lookup-form__note {
	margin: var(--hsi-space-1) 0 var(--hsi-space-3);
	font-size: 0.9em;
	font-weight: normal;
	text-align: left;
}

/* Client-specified (2026-09-09): checkboxes are left-aligned, always. */
.hsi-lookup-form__field--checkbox {
	text-align: left;
	justify-content: flex-start;
}

/* Client-specified (2026-09-11): radio groups match every other field —
   bold legend (a legend IS the field's label), and legend + options
   left-aligned, same anti-centering fix as the checkboxes above (centered
   options are easy to skim past). */
.hsi-lookup-form__field--radio {
	text-align: left;
}

.hsi-lookup-form__field--radio legend {
	font-weight: 600;
	text-align: left;
	margin-bottom: var(--hsi-space-1);
}

.hsi-lookup-form__radio-option {
	justify-content: flex-start;
}

/* ------------------------------------------------------------------ *
 * §8C reorg (client decisions 2026-09-11)
 * ------------------------------------------------------------------ */

/* Read-only display values — same visual language as the Booking Overview
   card above (--hsi-blue-tint / --hsi-blue, client-directed), so
   "information, not an input" reads at a glance. Replaces the old grey
   readonly inputs that looked editable-but-broken. */
.hsi-lookup-form__display-value {
	padding: 0.5em 0.75em;
	background: var(--hsi-blue-tint);
	border: 1px solid var(--hsi-blue);
	border-radius: var(--hsi-radius-lg);
}

/* Section-intro instructions (Lead Not Converted) span the 2-column
   section grid instead of squeezing into half of it. */
.hsi-lookup-form__section-body > .hsi-lookup-form__instruction {
	grid-column: 1 / -1;
	margin-top: 0;
}

/* Full-width field utility (client decisions 2026-09-11): a field that
   spans both columns of the section grid — long checkbox labels + their
   NOTEs, the Instructor Status display, Current Shipping Address, the
   Tracking URL row. */
.hsi-lookup-form__field--full {
	grid-column: 1 / -1;
}

/* One-column section body (Lead Not Converted): a section holding a single
   field stack has no business splitting into the shared 2-column grid —
   same override pattern as the danger section above. */
.hsi-lookup-form__section--single .hsi-lookup-form__section-body {
	grid-template-columns: 1fr;
}

/* A button sharing a .hsi-form-row with a labeled display field —
   bottom-align so the button lines up with the value box, not the label. */
.hsi-lookup-form__field--action {
	display: flex;
	align-items: flex-end;
}

/* Paid-in-full confirmation row (client decision 2026-09-17): full-width
   (via --full) with the checkbox label AND its hint left-aligned, not the
   theme's centered default. */
.hsi-lookup-form__field--pif,
.hsi-lookup-form__field--pif .hsi-lookup-form__hint {
	text-align: left;
}

/* Payment hierarchy (client direction 2026-09-17).
   1) Final Adjusted Total (Class Completed only): the step's headline
      editable number — strong navy border, background stays white
      (light blue is reserved for view-only values in this design). */
/* body-prefixed (2026-09-17 follow-up): the shell's base input rule
   (body.hsi-portal-template input[type='text'], specificity 0-2-2) was
   out-ranking the original single-class selector here, so the emphasis
   border never rendered. */
body.hsi-portal-template .hsi-lookup-form__field--amount-final input[type='text'] {
	border: 2px solid var(--hsi-navy);
}

body.hsi-portal-template .hsi-lookup-form__field--amount-final label {
	color: var(--hsi-navy);
}

/* 2) Balance Due: the number that drives collecting the remainder —
      bolder, larger, navy-bordered; Amount Paid to Date keeps the quiet
      standard display style beside it. */
.hsi-lookup-form__display-value--emphasis {
	border: 2px solid var(--hsi-navy);
	font-weight: 700;
	font-size: 1.15em;
}
