/*
 * Millingo brand overrides
 *
 * Loaded via BOTH:
 *   - app_include_css (millingo/hooks.py)  — desk pages (/app/*)
 *   - web_include_css (millingo/hooks.py)  — website pages (login, www routes)
 *
 * Frappe v16 brand-variable chain (apps/frappe/frappe/public/scss/common/css_variables.scss):
 *
 *   --brand-color: var(--primary)         // line 6   — cascades from --primary
 *   --btn-primary: var(--gray-900)        // line 99  — primary button background
 *   --primary-color: var(--gray-900)      // line 130 — body text color (NEAR-BLACK)
 *
 * We override --primary, --brand-color, and --btn-primary to wheat-gold #D4A015.
 *
 * We DELIBERATELY DO NOT override --primary-color. Despite the name, Frappe
 * uses it as the body-text color (default gray-900). Tinting body text to
 * wheat-gold would give 2.36:1 contrast on white — fails WCAG AA.
 *
 * Variables marked !important because Frappe's css_variables.scss defines them
 * under the same `:root, [data-theme="light"]` selector. Same specificity means
 * source-order wins — and on the LOGIN page, Frappe's login.bundle.css loads
 * AFTER our web_include_css (via the `{% block head_include %}` in login.html,
 * which renders after templates/includes/head.html). !important is the only
 * reliable way to ensure our value wins regardless of bundle order. Desk pages
 * don't hit this problem, but we apply !important uniformly so a single CSS
 * file serves both contexts.
 *
 * Structural variables (--bg-color, --fg-color, --text-color, navbar
 * background, borders) are untouched. Brand identity comes through accents,
 * not chrome.
 */
:root,
[data-theme="light"] {
	--primary: #d4a015 !important;
	--brand-color: #d4a015 !important;
	--btn-primary: #d4a015 !important;
}

[data-theme="dark"] {
	/* Slightly brighter wheat-gold for contrast against dark backgrounds. */
	--primary: #e8b547 !important;
	--brand-color: #e8b547 !important;
	--btn-primary: #e8b547 !important;
}

/*
 * Primary button styling — wheat-gold background, dark text for AAA contrast.
 *
 * Frappe's default at apps/frappe/frappe/public/scss/common/buttons.scss:114-125
 *
 *   .btn.btn-primary {
 *     background-color: var(--btn-primary);
 *     color: var(--neutral);
 *   }
 *
 * resolves to white text in light mode (--neutral → neutral-white). White on
 * #D4A015 gives 2.36:1 contrast — fails WCAG AA. Force dark text in both
 * themes for 8.88:1 (light) / 9.55:1 (dark), which passes AAA.
 *
 * Background-color is also set explicitly here (rather than relying purely on
 * the var(--btn-primary) cascade) for belt-and-suspenders defense on web
 * pages where bundle order can vary.
 *
 * We deliberately don't override --neutral globally because the navbar
 * background (--navbar-bg: var(--neutral)) depends on it; redirecting
 * --neutral would tint the navbar and break readability everywhere else.
 */
.btn.btn-primary {
	background-color: #d4a015 !important;
	color: #1f1f1f !important;
}
[data-theme="dark"] .btn.btn-primary {
	background-color: #e8b547 !important;
	color: #1f1f1f !important;
}

/*
 * Login page primary button — explicit selector targeting the actual button
 * class in apps/frappe/frappe/www/login.html (line 47):
 *
 *   <button class="btn btn-sm btn-primary btn-block btn-login" type="submit">
 *
 * Same wheat-gold treatment. Covered by .btn.btn-primary above, but this
 * selector adds a higher-specificity safety net in case the login.bundle.css
 * loads after us and tries to reset.
 */
.btn.btn-primary.btn-login,
.btn.btn-primary.btn-forgot,
.btn.btn-primary.btn-login-with-email-link {
	background-color: #d4a015 !important;
	color: #1f1f1f !important;
}
[data-theme="dark"] .btn.btn-primary.btn-login,
[data-theme="dark"] .btn.btn-primary.btn-forgot,
[data-theme="dark"] .btn.btn-primary.btn-login-with-email-link {
	background-color: #e8b547 !important;
	color: #1f1f1f !important;
}

