/**
 * VPro CRM — corrections layer.
 *
 * Loaded AFTER app.css, and last in the queue, so it always wins.
 *
 * WordPress is not a blank canvas: even with theme stylesheets dequeued, core
 * still prints block-library CSS, theme.json "global styles" custom properties,
 * emoji rules and form resets straight into the document. Themes and plugins
 * also inject styles through hooks we do not control. Anything that leaks into
 * the CRM and fights the app layout gets neutralised here.
 *
 * Keep app.css for what the CRM *is*, and this file for what WordPress *does to
 * it*. If you find yourself adding a new component here, it belongs in app.css.
 */

/* ---------- Box model & document reset ---------- */

body.vpro-crm-app,
body.vpro-crm-app *,
body.vpro-crm-app *::before,
body.vpro-crm-app *::after {
	box-sizing: border-box;
}

/*
 * Themes routinely set html { font-size: 62.5% } and body line-heights that make
 * every rem-based size in the app wrong. Pin the root back.
 */
html:has( body.vpro-crm-app ) {
	font-size: 100%;
	margin-top: 0 !important;
	scroll-behavior: auto;
}

body.vpro-crm-app {
	padding: 0;
	min-width: 0;
	overflow-x: hidden;
	letter-spacing: normal;
	word-spacing: normal;
	text-transform: none;
}

/* WordPress reserves space for the admin bar even when it is not rendered. */
body.vpro-crm-app #wpadminbar {
	display: none;
}

/* Core's emoji rules force img sizing that breaks avatars. */
body.vpro-crm-app img.emoji,
body.vpro-crm-app img.wp-smiley {
	display: none;
}

body.vpro-crm-app img {
	max-width: 100%;
	height: auto;
	border: 0;
}

/* ---------- Typography leakage ---------- */

body.vpro-crm-app p {
	margin-top: 0;
}

body.vpro-crm-app h1,
body.vpro-crm-app h2,
body.vpro-crm-app h3,
body.vpro-crm-app h4 {
	font-family: inherit;
	font-weight: 600;
	text-transform: none;
	letter-spacing: normal;
	padding: 0;
}

body.vpro-crm-app ul,
body.vpro-crm-app ol {
	margin: 0;
	padding: 0;
}

/* ---------- Form controls ---------- */

/*
 * Themes love to style every input in the document — full-width rounded pills,
 * uppercase buttons, inherited box-shadows. Reset the parts that matter and let
 * app.css redraw them.
 */
body.vpro-crm-app input,
body.vpro-crm-app select,
body.vpro-crm-app textarea,
body.vpro-crm-app button {
	font-family: inherit;
	letter-spacing: normal;
	text-transform: none;
	margin: 0;
	max-width: 100%;
}

body.vpro-crm-app select {
	-webkit-appearance: none;
	appearance: none;
	background-image: linear-gradient( 45deg, transparent 50%, currentColor 50% ), linear-gradient( 135deg, currentColor 50%, transparent 50% );
	background-position: calc( 100% - 17px ) calc( 50% + 2px ), calc( 100% - 12px ) calc( 50% + 2px );
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	padding-right: 32px;
}

body.vpro-crm-app input[type="checkbox"],
body.vpro-crm-app input[type="radio"] {
	width: auto;
	min-width: 0;
	height: auto;
	padding: 0;
	box-shadow: none;
	background: none;
	border-radius: 3px;
	accent-color: var(--vpro-series-1);
}

/*
 * `wp_dropdown_users()` emits a bare <select id="user_id">, which some themes
 * target directly. Make sure it matches the CRM's other controls.
 */
body.vpro-crm-app select#vpro-lead-owner,
body.vpro-crm-app select#vpro-student-user {
	width: 100%;
}

/* Search inputs get a UA-level appearance in some browsers. */
body.vpro-crm-app input[type="search"] {
	-webkit-appearance: none;
	appearance: none;
}

body.vpro-crm-app input[type="search"]::-webkit-search-decoration,
body.vpro-crm-app input[type="search"]::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

/* Placeholder color is otherwise inherited from whatever the theme set. */
body.vpro-crm-app ::placeholder {
	color: var(--vpro-muted);
	opacity: 1;
}

/* ---------- Button leakage ---------- */

/*
 * The specific failure this guards against: a theme styling `a` broadly, so a
 * link-shaped button renders its label in the link color — blue text on a blue
 * button. app.css already wins on specificity; this makes it unconditional.
 */
body.vpro-crm-app .vpro-btn {
	text-decoration: none !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	text-shadow: none !important;
}

body.vpro-crm-app .vpro-btn--primary,
body.vpro-crm-app a.vpro-btn--primary,
body.vpro-crm-app button.vpro-btn--primary,
body.vpro-crm-app .vpro-btn.is-active {
	color: #ffffff !important;
}

body.vpro-crm-app .vpro-btn--danger {
	color: var(--vpro-danger);
}

body.vpro-crm-app .vpro-btn--danger:hover {
	color: #ffffff;
}

/* Some themes add ::after arrows or underline animations to every link. */
body.vpro-crm-app .vpro-btn::before,
body.vpro-crm-app .vpro-btn::after,
body.vpro-crm-app .vpro-sidebar-nav a::before,
body.vpro-crm-app .vpro-sidebar-nav a::after,
body.vpro-crm-app .vpro-card-title::before,
body.vpro-crm-app .vpro-card-title::after {
	content: none;
}

/* ---------- Tables ---------- */

/*
 * Block-library and classic themes both style tables; the CRM draws its own.
 */
body.vpro-crm-app .vpro-table,
body.vpro-crm-app .vpro-table th,
body.vpro-crm-app .vpro-table td {
	background: none;
	border-top: 0;
	border-left: 0;
	border-right: 0;
}

body.vpro-crm-app .vpro-table caption {
	display: none;
}

/* ---------- Font Awesome ---------- */

/*
 * Icons are decorative here — every one sits beside a text label — so they are
 * hidden from assistive tech at the source (aria-hidden in the markup). This
 * keeps them optically aligned with the text they accompany.
 */
body.vpro-crm-app .fa-solid,
body.vpro-crm-app .fa-regular {
	line-height: 1;
	vertical-align: -0.05em;
	font-style: normal;
}

/* ---------- Third-party overlays ---------- */

/*
 * Browser extensions and helper plugins inject fixed-position widgets that land
 * on top of the sidebar. Push the common ones behind the app chrome.
 */
body.vpro-crm-app > div[style*="position: fixed"]:not( [class*="vpro-" ] ) {
	z-index: 5;
}

/* ---------- Print ---------- */

@media print {
	body.vpro-crm-app .vpro-sidebar,
	body.vpro-crm-app .vpro-topbar,
	body.vpro-crm-app .vpro-toolbar,
	body.vpro-crm-app .vpro-form-actions,
	body.vpro-crm-app .vpro-pagination {
		display: none;
	}

	body.vpro-crm-app .vpro-app-col {
		margin-left: 0;
	}

	body.vpro-crm-app .vpro-app-main {
		padding: 0;
	}

	body.vpro-crm-app .vpro-panel {
		border: 1px solid #ccc;
		box-shadow: none;
		break-inside: avoid;
	}
}
