/**
 * APEX RecSite Builder — Layout & Component Styles
 *
 * Compact card layout, featured spotlight, card density modifiers,
 * sort bar, active filter pills, and horizontal filter bar widget.
 *
 * All colours reference CSS custom properties injected by design-tokens.php
 * so they automatically reflect the agency's brand settings.
 *
 * @package ApexRecSiteBuilderCore
 * @since   1.0.0
 */

/* -----------------------------------------------------------------------
   Compact card layout
   ----------------------------------------------------------------------- */

/**
 * Single-row card: title / meta / type badges / action all on one line.
 * Adjacent compact cards collapse their borders to form a unified list.
 */
.apex-job-card--compact {
	display: grid;
	grid-template-columns: 1fr auto auto auto;
	align-items: center;
	gap: 0 20px;
	padding: 13px 20px;
	background: #ffffff;
	border: 1px solid var(--apex-border, #e0e3e5);
	border-bottom-width: 0;
	transition: background-color 0.15s ease;
}

.apex-job-card--compact:first-child {
	border-radius: var(--apex-radius, 4px) var(--apex-radius, 4px) 0 0;
}

.apex-job-card--compact:last-child {
	border-bottom-width: 1px;
	border-radius: 0 0 var(--apex-radius, 4px) var(--apex-radius, 4px);
}

/* Only one card: round all corners */
.apex-job-card--compact:only-child {
	border-radius: var(--apex-radius, 4px);
	border-bottom-width: 1px;
}

.apex-job-card--compact:hover {
	background: var(--apex-light, #f7f9fb);
}

/* Title cell — flex so priority dot sits beside the link */
.apex-job-card--compact .apex-job-card__title-cell {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.apex-job-card--compact .apex-job-card__title-link {
	font-weight: 600;
	font-size: 0.95rem;
	color: var(--apex-dark, #050e1d);
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: color 0.15s ease;
}

.apex-job-card--compact .apex-job-card__title-link:hover {
	color: var(--apex-primary, #b5106b);
}

/* Meta cell (location + salary) */
.apex-job-card--compact .apex-job-card__meta-cell {
	display: flex;
	gap: 16px;
	font-size: 0.875rem;
	color: var(--apex-text-muted, #45474c);
	white-space: nowrap;
}

/* Type cell (job type + remote badge) */
.apex-job-card--compact .apex-job-card__type-cell {
	display: flex;
	gap: 6px;
	white-space: nowrap;
}

/* Action cell */
.apex-job-card--compact .apex-job-card__action-cell {
	flex-shrink: 0;
}

/* Small priority dot for compact layout — replaces the full badge */
.apex-badge--priority-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--apex-primary, #b5106b);
	flex-shrink: 0;
}

/* Priority left-border for compact cards */
.apex-job-card--compact.apex-job-card--priority {
	border-left: 3px solid var(--apex-primary, #b5106b);
}

/* Responsive: stack to two rows on small screens */
@media ( max-width: 640px ) {
	.apex-job-card--compact {
		grid-template-columns: 1fr auto;
		grid-template-rows: auto auto;
		row-gap: 6px;
	}

	.apex-job-card--compact .apex-job-card__meta-cell {
		grid-column: 1;
	}

	.apex-job-card--compact .apex-job-card__type-cell {
		display: none;
	}

	.apex-job-card--compact .apex-job-card__action-cell {
		grid-column: 2;
		grid-row: 1 / 3;
		align-self: center;
	}
}

/* -----------------------------------------------------------------------
   Featured card treatment (.apex-job-card--priority)
   ----------------------------------------------------------------------- */

/**
 * Applied by job-card.php when _apex_priority_listing meta is set.
 * Adds a primary-colour left accent border and a subtle elevated shadow.
 */
.apex-job-card--priority:not(.apex-job-card--compact) {
	border-left: 3px solid var(--apex-primary, #b5106b);
	box-shadow: 0 2px 10px rgba( 0, 0, 0, 0.07 );
}

/**
 * The "HIGH PRIORITY" badge that appears inside priority cards.
 */
.apex-badge--priority {
	display: inline-flex;
	align-items: center;
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--apex-primary, #b5106b);
	background: transparent;
	border: 1px solid var(--apex-primary, #b5106b);
	padding: 2px 8px;
	border-radius: 99px;
	margin-bottom: 8px;
	opacity: 0.85;
}

/* -----------------------------------------------------------------------
   Featured spotlight section
   ----------------------------------------------------------------------- */

/**
 * Wraps the top N priority listings above the main grid/list.
 * A thin labelled rule separates it from the regular results.
 */
.apex-featured-spotlight {
	margin-bottom: calc( var(--apex-sp, 8px) * 3 );
}

.apex-featured-spotlight__heading {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--apex-primary, #b5106b);
	margin: 0 0 14px;
}

.apex-featured-spotlight__heading::after {
	content: '';
	flex: 1;
	height: 1px;
	background: currentColor;
	opacity: 0.2;
}

/* Spotlight cards get extra elevation */
.apex-featured-spotlight .apex-job-card:not(.apex-job-card--compact) {
	box-shadow: 0 4px 16px rgba( 0, 0, 0, 0.09 );
}

/* -----------------------------------------------------------------------
   Card density modifiers
   ----------------------------------------------------------------------- */

/**
 * Applied to .apex-job-listings-wrap via a data attribute or modifier class.
 *
 *  .apex-job-listings--density-compact   — tighter, less visual weight
 *  .apex-job-listings--density-spacious  — more breathing room
 *  (comfortable = default, no modifier needed)
 */

/* Compact: hide excerpt and tags, reduce card body padding */
.apex-job-listings--density-compact .apex-job-card__excerpt,
.apex-job-listings--density-compact .apex-job-card__tags {
	display: none;
}

.apex-job-listings--density-compact .apex-job-card__body {
	padding: 12px 16px;
}

.apex-job-listings--density-compact .apex-job-card__footer {
	padding: 8px 16px;
}

/* Spacious: more padding, always show excerpt */
.apex-job-listings--density-spacious .apex-job-card__body {
	padding: 28px 28px 24px;
}

.apex-job-listings--density-spacious .apex-job-card__footer {
	padding: 16px 28px;
}

.apex-job-listings--density-spacious .apex-job-card__excerpt {
	display: block !important;
}

/* -----------------------------------------------------------------------
   Sort bar
   ----------------------------------------------------------------------- */

/**
 * Rendered above .apex-job-listings when the "Show Sort Control" option
 * is enabled on the Job Listings widget.
 */
.apex-sort-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding-bottom: calc( var(--apex-sp, 8px) * 2 );
	margin-bottom: calc( var(--apex-sp, 8px) * 2 );
	border-bottom: 1px solid var(--apex-border, #e0e3e5);
}

.apex-sort-bar__count {
	font-size: 0.875rem;
	color: var(--apex-text-muted, #45474c);
}

.apex-sort-bar__control {
	display: flex;
	align-items: center;
	gap: 8px;
}

.apex-sort-bar__label {
	font-size: 0.875rem;
	color: var(--apex-text-muted, #45474c);
	white-space: nowrap;
}

.apex-sort-bar__select {
	appearance: none;
	background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6H0z' fill='%2345474c'/%3E%3C/svg%3E") no-repeat right 10px center;
	border: 1px solid var(--apex-border, #e0e3e5);
	border-radius: var(--apex-radius, 4px);
	padding: 7px 32px 7px 12px;
	font-size: 0.875rem;
	color: var(--apex-dark, #050e1d);
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.apex-sort-bar__select:focus {
	outline: none;
	border-color: var(--apex-primary, #b5106b);
	box-shadow: 0 0 0 3px rgba( 181, 16, 107, 0.12 );
}

/* -----------------------------------------------------------------------
   Active filter pills strip
   ----------------------------------------------------------------------- */

/**
 * Container rendered above the job listing. JS fills it with dismissible
 * pill buttons representing each active filter. Hides itself when empty.
 */
.apex-active-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-bottom: calc( var(--apex-sp, 8px) * 2 );
	min-height: 0;
}

.apex-active-filters:empty {
	display: none;
	margin-bottom: 0;
}

.apex-active-filter-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 6px 4px 12px;
	background: #ffffff;
	border: 1px solid var(--apex-primary, #b5106b);
	border-radius: 99px;
	color: var(--apex-primary, #b5106b);
	font-size: 0.8rem;
	font-weight: 500;
	cursor: pointer;
	transition: background-color 0.15s ease;
	line-height: 1.4;
}

.apex-active-filter-pill:hover {
	background: var(--apex-light, #f7f9fb);
}

.apex-active-filter-pill__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--apex-primary, #b5106b);
	color: #ffffff;
	font-size: 0.8rem;
	line-height: 1;
	flex-shrink: 0;
}

/* "Clear all" pill — less prominent */
.apex-active-filter-pill--clear-all {
	border-color: var(--apex-border, #e0e3e5);
	color: var(--apex-text-muted, #45474c);
	padding: 4px 12px;
}

.apex-active-filter-pill--clear-all:hover {
	border-color: var(--apex-dark, #050e1d);
	color: var(--apex-dark, #050e1d);
	background: transparent;
}

/* -----------------------------------------------------------------------
   Horizontal filter bar widget (.apex-filter-bar)
   ----------------------------------------------------------------------- */

/**
 * A compact row of pill buttons that acts as a lightweight alternative to
 * the sidebar filter panel. One pill group per filter dimension.
 */
.apex-filter-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: calc( var(--apex-sp, 8px) * 1.5 ) 0;
}

.apex-filter-bar__group {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.apex-filter-bar__group-label {
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--apex-text-muted, #45474c);
	margin-right: 2px;
	white-space: nowrap;
}

.apex-filter-bar__pill {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 6px 14px;
	background: #ffffff;
	border: 1px solid var(--apex-border, #e0e3e5);
	border-radius: 99px;
	color: var(--apex-text, #191c1e);
	font-size: 0.85rem;
	font-weight: 500;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
	white-space: nowrap;
	user-select: none;
	line-height: 1.4;
}

.apex-filter-bar__pill:hover {
	border-color: var(--apex-primary, #b5106b);
	color: var(--apex-primary, #b5106b);
}

.apex-filter-bar__pill.is-active {
	background: var(--apex-primary, #b5106b);
	border-color: var(--apex-primary, #b5106b);
	color: #ffffff;
}

.apex-filter-bar__count {
	font-size: 0.75rem;
	opacity: 0.7;
}

/* Thin vertical divider between filter groups */
.apex-filter-bar__divider {
	width: 1px;
	height: 22px;
	background: var(--apex-border, #e0e3e5);
	flex-shrink: 0;
}

@media ( max-width: 480px ) {
	.apex-filter-bar {
		gap: 6px;
	}

	.apex-filter-bar__group-label {
		display: none;
	}

	.apex-filter-bar__pill {
		padding: 5px 11px;
		font-size: 0.8rem;
	}
}

/* -----------------------------------------------------------------------
   Sidebar filter panel  (.apex-filter-panel)
   ----------------------------------------------------------------------- */

/**
 * Full sidebar filter panel rendered by widget-job-filter.php.
 * Sections are optionally collapsible via a toggle button.
 * The dual salary slider uses a custom track-fill element.
 */
.apex-filter-panel {
	background: #ffffff;
	border: 1px solid var(--apex-border, #e0e3e5);
	border-radius: var(--apex-radius, 4px);
	overflow: hidden;
}

.apex-filter-panel__section {
	padding: 16px 20px;
}

.apex-filter-panel__section + .apex-filter-panel__section {
	border-top: 1px solid var(--apex-border, #e0e3e5);
}

/* Section header — wraps label + optional toggle chevron */
.apex-filter-panel__section-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
	cursor: pointer;
	user-select: none;
}

/* When the section is NOT collapsible, the label stands alone */
.apex-filter-panel__section > .apex-filter-panel__label {
	margin: 0 0 12px;
}

.apex-filter-panel__label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	color: var(--apex-dark, #050e1d);
	margin: 0;
}

/* Collapse toggle chevron */
.apex-filter-section-toggle {
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: none;
	cursor: pointer;
	color: var(--apex-text-muted, #45474c);
	transition: transform 0.2s ease, color 0.15s ease;
	flex-shrink: 0;
	padding: 0;
}

.apex-filter-section-toggle:hover {
	color: var(--apex-primary, #b5106b);
}

.apex-filter-panel__section.is-collapsed .apex-filter-section-toggle {
	transform: rotate( -90deg );
}

/* Section body — slides shut when collapsed */
.apex-filter-panel__section-body {
	overflow: hidden;
	transition: max-height 0.28s ease, opacity 0.22s ease;
	max-height: 800px;
	opacity: 1;
}

.apex-filter-panel__section.is-collapsed .apex-filter-panel__section-body {
	max-height: 0;
	opacity: 0;
}

/* Option list */
.apex-filter-panel__options {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.apex-filter-panel__option-label {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-size: 0.875rem;
	color: var(--apex-dark, #050e1d);
	padding: 3px 0;
	transition: color 0.15s ease;
	line-height: 1.4;
}

.apex-filter-panel__option-label:hover {
	color: var(--apex-primary, #b5106b);
}

.apex-filter-panel__checkbox {
	width: 16px;
	height: 16px;
	accent-color: var(--apex-primary, #b5106b);
	cursor: pointer;
	flex-shrink: 0;
}

.apex-filter-panel__count {
	font-size: 0.75rem;
	color: var(--apex-text-muted, #45474c);
	margin-left: auto;
}

/* Location text input */
.apex-filter-panel__text-input {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid var(--apex-border, #e0e3e5);
	border-radius: var(--apex-radius, 4px);
	font-size: 0.875rem;
	color: var(--apex-dark, #050e1d);
	background: #fff;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	box-sizing: border-box;
	font-family: inherit;
}

.apex-filter-panel__text-input:focus {
	outline: none;
	border-color: var(--apex-primary, #b5106b);
	box-shadow: 0 0 0 3px rgba( 181, 16, 107, 0.1 );
}

/* -----------------------------------------------------------------------
   Salary dual-handle range slider
   ----------------------------------------------------------------------- */

/**
 * Two stacked <input type="range"> elements share the same track.
 * A .apex-filter-range__fill div is positioned between min and max thumbs.
 * JavaScript (initSalarySliders) updates left/right offsets on input events.
 */
.apex-filter-range {
	position: relative;
	padding-bottom: 30px;
}

.apex-filter-range__track-wrap {
	position: relative;
	height: 4px;
	background: var(--apex-border, #e0e3e5);
	border-radius: 99px;
	margin: 16px 0 8px;
}

.apex-filter-range__fill {
	position: absolute;
	top: 0;
	height: 100%;
	background: var(--apex-primary, #b5106b);
	border-radius: 99px;
	pointer-events: none;
}

.apex-filter-panel__range-input {
	position: absolute;
	top: -8px; /* vertically centred on the 4px track */
	left: 0;
	width: 100%;
	height: 20px;
	background: transparent;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	pointer-events: none; /* thumbs are the only interactive part */
}

/* Webkit thumb */
.apex-filter-panel__range-input::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--apex-primary, #b5106b);
	border: 2px solid #ffffff;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 );
	cursor: pointer;
	pointer-events: all;
	transition: box-shadow 0.15s ease;
}

.apex-filter-panel__range-input::-webkit-slider-thumb:hover,
.apex-filter-panel__range-input:focus::-webkit-slider-thumb {
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 ), 0 0 0 3px rgba( 181, 16, 107, 0.15 );
}

/* Firefox thumb */
.apex-filter-panel__range-input::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--apex-primary, #b5106b);
	border: 2px solid #ffffff;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 );
	cursor: pointer;
	pointer-events: all;
}

/* Output display of current min/max values */
.apex-filter-range__output {
	display: flex;
	justify-content: space-between;
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--apex-dark, #050e1d);
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
}

/* Footer — reset button */
.apex-filter-panel__footer {
	padding: 14px 20px;
	border-top: 1px solid var(--apex-border, #e0e3e5);
}

.apex-filter-reset {
	width: 100%;
	justify-content: center;
}

/* -----------------------------------------------------------------------
   Wizard: visual pack-selection cards (upgrade from radio buttons)
   ----------------------------------------------------------------------- */

/**
 * Replaces the plain .apex-radio-card with a richer card showing the pack
 * icon, primary colour swatch, and sector label. Applied in wizard Step 1.
 */
.apex-pack-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 20px 18px 16px;
	background: #ffffff;
	border: 2px solid var(--apex-border, #e0e3e5);
	border-radius: 10px;
	cursor: pointer;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
	overflow: hidden;
}

.apex-pack-card:hover {
	border-color: var(--apex-primary, #b5106b);
	box-shadow: 0 4px 16px rgba( 0, 0, 0, 0.1 );
	transform: translateY( -2px );
}

.apex-pack-card.is-selected {
	border-color: var(--apex-primary, #b5106b);
	box-shadow: 0 0 0 3px rgba( 181, 16, 107, 0.15 );
}

/* Colour swatch bar at top of card */
.apex-pack-card__swatch {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	border-radius: 10px 10px 0 0;
}

.apex-pack-card__icon {
	font-size: 1.6rem;
	line-height: 1;
	margin-top: 4px;
}

.apex-pack-card__name {
	font-weight: 700;
	font-size: 0.95rem;
	color: var(--apex-dark, #050e1d);
	line-height: 1.3;
}

.apex-pack-card__desc {
	font-size: 0.8rem;
	color: var(--apex-text-muted, #45474c);
	line-height: 1.5;
	flex: 1;
}

.apex-pack-card__meta {
	display: flex;
	gap: 10px;
	font-size: 0.75rem;
	color: var(--apex-text-muted, #45474c);
	padding-top: 8px;
	border-top: 1px solid var(--apex-border, #e0e3e5);
	margin-top: auto;
}

.apex-pack-card__meta-item {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* Hidden radio input — accessibility preserved via label association */
.apex-pack-card input[type="radio"] {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

/* Tick badge shown on selected cards */
.apex-pack-card__tick {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--apex-primary, #b5106b);
	color: #ffffff;
	display: none;
	align-items: center;
	justify-content: center;
	font-size: 0.75rem;
}

.apex-pack-card.is-selected .apex-pack-card__tick {
	display: flex;
}

/* Grid layout for the pack cards */
.apex-pack-cards-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 180px, 1fr ) );
	gap: 14px;
	margin: 16px 0;
}
