/* H-32 (Q-244): Seudamgroup HR brand tokens, LIGHT THEME ONLY. Spec: docs/06-design/thuong-hieu-giao-dien-seudamgroup-hr.md
   sections 3.1, 3.2, 4.2. Three layers: (1) primitives, the only place a colour value is written; (2) roles --sg-*,
   always var() to a primitive; (3) Frappe espresso / legacy variables pointed at roles only.
   Loaded first in app_include_css (Desk) and in web_include_css (login, update-password, /my-roster).
   Scope: ":root:not([data-theme="dark"])" instead of a bare ":root", because :root also matches a page in the dark
   theme and this file loads after Frappe's, so a bare :root would paint light values over the dark theme. The dark
   theme keeps Frappe's own values (design 3.4); nothing here names [data-theme="dark"]. */

@import url("/assets/survival_hr/css/brand_base.css");

:root:not([data-theme="dark"]),
html[data-theme="light"] {
	/* 3. Frappe overrides: roles only (design 4.2). The legacy variables that follow these need no line of their own. */
	--ink-gray-9: var(--sg-heading);
	--ink-gray-8: var(--sg-text);
	--ink-gray-7: var(--sg-text-strong-muted);
	--ink-gray-6: var(--sg-text-muted);
	--ink-gray-5: var(--sg-text-light);
	--ink-gray-4: var(--sg-text-subtle);
	--ink-gray-3: var(--sg-text-subtle);
	--surface-gray-1: var(--sg-surface-page);
	--surface-sidebar: var(--sg-surface-page);
	--surface-gray-2: var(--sg-surface-fill);
	--control-bg: var(--sg-surface);
	--control-bg-on-gray: var(--sg-surface);
	--navbar-bg: var(--sg-surface);
	--outline-gray-1: var(--sg-border-hairline);
	--outline-gray-2: var(--sg-border);
	--outline-gray-3: var(--sg-border-control);
	--btn-primary: var(--sg-action);
	--primary: var(--sg-action);
	--primary-color: var(--sg-action);
	--brand-color: var(--sg-action);
	--progress-bar-bg: var(--sg-action);
	--date-active-bg: var(--sg-action);
	--focus-outline-default: 2px solid var(--sg-action);
	--focus-default: var(--sg-focus);
	--checkbox-focus-shadow: var(--sg-focus);
	--checkbox-color: var(--sg-text-on-action);
	--danger: var(--sg-danger);
	--error-border: var(--sg-danger);
	--outline-red-3: var(--sg-danger);
	--surface-green-2: var(--sg-ok-bg);
	--ink-green-8: var(--sg-ok-fg);
	--surface-amber-2: var(--sg-wait-bg);
	--ink-amber-8: var(--sg-wait-fg);
	--surface-orange-2: var(--sg-wait-bg);
	--ink-orange-8: var(--sg-wait-fg);
	--surface-yellow-2: var(--sg-wait-bg);
	--ink-yellow-8: var(--sg-wait-fg);
	--surface-red-2: var(--sg-danger-bg);
	--ink-red-8: var(--sg-danger-text);
	--surface-blue-2: var(--sg-info-bg);
	--ink-blue-8: var(--sg-info-fg);
	--surface-cyan-2: var(--sg-info-bg);
	--ink-cyan-8: var(--sg-info-fg);
	--font-stack: var(--sg-font);
}

/* Small rules of design 4.2, light theme only. :where() keeps the specificity of Frappe's own rule, so the
   borderless inputs Frappe draws inside grid rows (higher specificity) stay as they are. */
:where(html:not([data-theme="dark"])) .form-control,
:where(html:not([data-theme="dark"])) .frappe-control :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]) {
	border: 1px solid var(--sg-border-control);
}

html:not([data-theme="dark"]) .btn.btn-primary:not(:disabled):not(.disabled):hover,
html:not([data-theme="dark"]) .btn.btn-primary:not(:disabled):not(.disabled):focus-visible {
	background-color: var(--sg-action-hover);
	color: var(--sg-text-on-action);
}

/* Desk v16 draws its primary buttons (Save, Submit, New) as espresso .es-button[data-variant="solid"], whose colour
   is set on the button itself (--bt-solid-bg: --surface-gray-10), so --btn-primary on :root does not reach them. The
   default (gray) theme takes the action role; the red theme (danger) keeps its own. This file is not in a cascade
   layer, so it wins over espresso's @layer components. */
:where(html:not([data-theme="dark"])) :is(.es-button:not([data-theme]), .es-button[data-theme="gray"]) {
	--bt-solid-bg: var(--sg-action);
	--bt-solid-bg-hover: var(--sg-action-hover);
	--bt-solid-bg-active: var(--sg-action-active);
	--bt-solid-fg: var(--sg-text-on-action);
}

/* Frappe turns a pressed primary button into the inverted neutral colour with !important. */
html:not([data-theme="dark"]) .btn.btn-primary:not(:disabled):not(.disabled):active {
	background-color: var(--sg-action-active) !important;
	color: var(--sg-text-on-action) !important;
}

/* The top area. Desk v16 has no top navbar (dock | sidebar | content). On a computer the top of the sidebar column
   is the top bar: a 48 px band with the company lockup (28 px high), white with a 3 px crimson rule. A collapsed
   sidebar is 48 px wide, so it shows the square app icon (Oregon tile, silver modules, Bee 17/10) instead. On a phone (below 768 px) the sidebar is a drawer:
   the band heads the open drawer, and the sticky page head is the top bar, with the square app icon before the
   breadcrumbs (design 5.3: narrow screens use the square icon, the lockup needs 173 px).
   Default, Bee may change: TOP_BAR in survival_hr/branding.py; "crimson" sets html[data-sg-top-bar="crimson"]. */
:where(html:not([data-theme="dark"])) .body-sidebar::before {
	content: "";
	display: block;
	flex: 0 0 auto;
	height: 48px;
	background: var(--sg-surface) url("/assets/survival_hr/brand/lockup-l1-hr-ligature.svg") no-repeat 12px center / auto 28px;
	border-bottom: 3px solid var(--sg-brand);
}

:where(html:not([data-theme="dark"])) .body-sidebar-container:not(.expanded) .body-sidebar::before {
	background-image: url("/assets/survival_hr/brand/icons/icon-192.png");
	background-position: center;
	background-size: 28px 28px;
}

@media (max-width: 767.98px) {
	/* A closed drawer fades its children only; the band is not a child, so it is hidden with it. */
	.body-sidebar-container:not(.expanded) .body-sidebar::before {
		display: none;
	}

	:where(html:not([data-theme="dark"])) .page-head {
		background: var(--sg-surface);
		border-bottom: 3px solid var(--sg-brand);
	}

	:where(html:not([data-theme="dark"])) .page-head .title-area::before {
		content: "";
		flex: 0 0 auto;
		width: 24px;
		height: 24px;
		margin-right: 8px;
		background: url("/assets/survival_hr/brand/icons/icon-192.png") no-repeat center / contain;
	}
}

/* The alternative top area (Bee may choose it): a full crimson bar with the white lockup and white icons. The app
   icon (brown tile) stays on the collapsed sidebar and the phone page head: it is not red on red (design 5.3). */
html[data-sg-top-bar="crimson"]:not([data-theme="dark"]) .body-sidebar::before {
	background-color: var(--sg-brand);
	background-image: url("/assets/survival_hr/brand/lockup-l1-hr-ligature-white.svg");
	border-bottom-color: var(--sg-brand);
}

html[data-sg-top-bar="crimson"]:not([data-theme="dark"]) .body-sidebar-container:not(.expanded) .body-sidebar::before {
	background-image: url("/assets/survival_hr/brand/icons/icon-192.png");
}

@media (max-width: 767.98px) {
	/* Inside the bar the text and icon roles turn white and control fills take the bar colour. */
	html[data-sg-top-bar="crimson"]:not([data-theme="dark"]) .page-head {
		background: var(--sg-brand);
		border-bottom-color: var(--sg-brand);
		color: var(--sg-text-on-action);
		--icon-stroke: var(--sg-text-on-action);
		--ink-gray-9: var(--sg-text-on-action);
		--ink-gray-8: var(--sg-text-on-action);
		--ink-gray-7: var(--sg-text-on-action);
		--ink-gray-6: var(--sg-text-on-action);
		--ink-gray-5: var(--sg-text-on-action);
		--control-bg: var(--sg-brand);
		--surface-gray-2: var(--sg-brand);
	}

	html[data-sg-top-bar="crimson"]:not([data-theme="dark"]) .page-head :is(.title-area, .title-text, .es-breadcrumbs, .es-breadcrumbs a, .sidebar-toggle-btn) {
		color: var(--sg-text-on-action);
	}

	html[data-sg-top-bar="crimson"]:not([data-theme="dark"]) .page-head .sidebar-toggle-btn .icon {
		stroke: var(--sg-text-on-action);
	}

	/* The primary button in the bar turns white with crimson text, so it is not crimson on crimson. */
	html[data-sg-top-bar="crimson"]:not([data-theme="dark"]) .page-head :is(.es-button:not([data-theme]), .es-button[data-theme="gray"]) {
		--bt-solid-bg: var(--sg-surface);
		--bt-solid-bg-hover: var(--sg-surface-fill);
		--bt-solid-bg-active: var(--sg-surface-fill);
		--bt-solid-fg: var(--sg-brand);
	}
}

/* Web pages (login, update-password, /my-roster): the company lockup heads /my-roster (www/my-roster.html). */
.sg-brand-head {
	display: flex;
	align-items: center;
	height: 48px;
	margin: 0 0 12px;
	background: var(--sg-surface);
	border-bottom: 3px solid var(--sg-brand);
}

.sg-brand-head img {
	height: 28px;
	width: auto;
}

html[data-sg-top-bar="crimson"] .sg-brand-head {
	padding: 0 12px;
	background: var(--sg-brand);
	border-bottom-color: var(--sg-brand);
}
