/* TzamunERP theme — plain CSS, no build step.
 *
 * Values are the exact semantic tokens from ../brand/tokens.json (v1). Only
 * two themes exist in tokens.json ("light" is the only declared theme), so the
 * dark block reuses the same token values — navy/slate ramps for surfaces and
 * inks; no invented colours.
 *
 * Frappe v16 variables overridden (confirmed in ../ref/frappe):
 *   Desk + website legacy aliases   frappe/public/css/espresso/legacy.css
 *     --primary-color (:131), --text-color (:41), --bg-color (:25),
 *     --card-bg (:27), --border-color (:49), --control-bg (:30),
 *     --text-muted (:43), --heading-color (:42), --btn-primary (:55)
 *   Undefined-but-consumed gaps     frappe/public/scss/common/css_variables.scss:49,
 *     frappe/public/scss/common/buttons.scss:172  → --primary, --danger
 *   Espresso status fills           frappe/public/css/espresso/legacy.css:60-90
 *     → --bg-blue/--bg-green/--bg-amber/--bg-red + their --text-on-<c> pairs
 *   Alert weak surfaces             legacy.css:106-113 (dark :143-150)
 *     → --alert-bg-success/warning/danger/info
 *   Focus ring                      frappe/public/css/espresso/effects.css:27-28
 *     → --focus-default, --focus-outline-default (dark re-declared :42-53)
 *   Buttons (espresso)              frappe/public/css/espresso/components/button.css:33-36
 *     → .es-button scoped --bt-solid-bg/-hover/-active/-fg
 *   Navbar/sidebar                  legacy.css:36 (--navbar-bg),
 *     frappe/public/scss/desk/sidebar.scss:24 (--desk-sidebar-bg)
 *   Fonts                           frappe/public/scss/espresso/_typography.scss:12
 *     → --font-stack (the one var html/body consume)
 *
 * Dark mode: the desk sets [data-theme="dark"] on <html>
 * (frappe/public/js/frappe/ui/theme_switcher.js:175-182) and
 * frappe/public/css/espresso/colors.css:591+ re-declares the token scale, so
 * every override below is repeated in a [data-theme="dark"], .dark block.
 * The website/login pages never set the attribute and always render :root.
 *
 * Links: v16 links compile from --text-color (scss/desk/variables.scss:43),
 * so they follow the body ink here; there is no link custom property to
 * override.
 */

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Sans+Arabic:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap");

/* ------------------------------------------------------------------ */
/* Tzamun semantic tokens — light (exact hexes from tokens.json)       */
/* ------------------------------------------------------------------ */
:root,
[data-theme="light"] {
	--tz-font-heading: "Poppins", "IBM Plex Sans", sans-serif;
	--tz-font-body: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
	--tz-font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

	/* color-primary = blue-500; hover/active/weak per usage notes */
	--tz-color-primary: #0e70b4;
	--tz-color-primary-hover: #0c63a0;
	--tz-color-primary-active: #0a5184;
	--tz-color-primary-weak: #eaf4fb;
	--tz-color-primary-border: #cce4f5;
	/* text-on-brand: labels on color-primary (5.3:1 on blue-500) */
	--tz-text-on-brand: #ffffff;

	/* color-secondary = teal-500. Brand rule: teal fills take navy text. */
	--tz-color-secondary: #2fb492;
	--tz-color-secondary-text: #15183c;

	/* Inks */
	--tz-text-strong: #15183c; /* navy-900 — headings, 17:1 on card */
	--tz-text-body: #3c4250; /* slate-700 — body copy, 10:1 on card */
	--tz-text-muted: #6b7688; /* slate-500 — captions, helper text */
	--tz-text-subtle: #95a0b1; /* slate-400 — placeholders ONLY */

	/* Surfaces */
	--tz-surface-page: #f5f7f9; /* slate-50 */
	--tz-surface-card: #ffffff; /* white */
	--tz-surface-sunken: #eceff3; /* slate-100 */
	--tz-surface-inverse: #15183c; /* navy-900 */

	/* Borders */
	--tz-border-subtle: #dde2ea; /* slate-200 — dividers, cards */
	--tz-border-default: #c3ccd8; /* slate-300 — controls */
	--tz-border-strong: #95a0b1; /* slate-400 */
	--tz-border-focus: #0e70b4; /* blue-500 */

	/* Status */
	--tz-color-success: #2fb492; /* success-500 */
	--tz-color-success-weak: #e8f8f2; /* success-50 */
	--tz-color-warning: #e8a33d; /* warning-500 */
	--tz-color-warning-weak: #fdf3e3; /* warning-50 */
	--tz-color-danger: #d8473f; /* danger-500 */
	--tz-color-danger-weak: #fdecea; /* danger-50 */
	--tz-color-info: #0e70b4; /* info-500 */
	--tz-color-info-weak: #eaf4fb; /* info-50 */

	/* Focus ring (ring-focus) */
	--tz-ring-focus: 0 0 0 3px rgba(14, 112, 180, 0.28);
	--tz-ring-focus-outline: 3px solid rgba(14, 112, 180, 0.28);

	/* Shadows (navy-tinted, low-spread) */
	--tz-shadow-sm: 0 1px 3px rgba(21, 24, 60, 0.08), 0 1px 2px rgba(21, 24, 60, 0.04);

	/* ---------------------------------------------------------------- */
	/* Frappe variable mapping — light                                   */
	/* ---------------------------------------------------------------- */
	--primary: var(--tz-color-primary);
	--primary-color: var(--tz-color-primary);
	--btn-primary: var(--tz-color-primary);
	--text-color: var(--tz-text-body);
	--text-dark: var(--tz-text-body);
	--text-muted: var(--tz-text-muted);
	--heading-color: var(--tz-text-strong);
	--bg-color: var(--tz-surface-page);
	--card-bg: var(--tz-surface-card);
	--control-bg: var(--tz-surface-card);
	--border-color: var(--tz-border-subtle);
	--navbar-bg: var(--tz-surface-card);
	--desk-sidebar-bg: var(--tz-surface-page);
	--font-stack: var(--tz-font-body);

	--focus-default: var(--tz-ring-focus);
	--focus-outline-default: var(--tz-ring-focus-outline);

	--danger: var(--tz-color-danger);

	/* Status fills + their label colours */
	--bg-blue: var(--tz-color-primary);
	--text-on-blue: var(--tz-text-on-brand);
	--bg-green: var(--tz-color-secondary);
	--text-on-green: var(--tz-color-secondary-text);
	--bg-amber: var(--tz-color-warning);
	--text-on-amber: var(--tz-color-secondary-text);
	--bg-red: var(--tz-color-danger);
	--text-on-red: var(--tz-text-on-brand);

	/* Alert weak surfaces */
	--alert-bg-success: var(--tz-color-success-weak);
	--alert-bg-warning: var(--tz-color-warning-weak);
	--alert-bg-danger: var(--tz-color-danger-weak);
	--alert-bg-info: var(--tz-color-info-weak);

	/* Espresso solid buttons: brand blue, white label. Danger buttons keep
	 * their own [data-theme="red"] scope (higher specificity). */
	--bt-solid-bg: var(--tz-color-primary);
	--bt-solid-bg-hover: var(--tz-color-primary-hover);
	--bt-solid-bg-active: var(--tz-color-primary-active);
	--bt-solid-fg: var(--tz-text-on-brand);
	color-scheme: light;
}

/* ------------------------------------------------------------------ */
/* Dark theme — same tokens, navy surfaces, slate inks. Repeated so   */
/* espresso/colors.css:591+ re-declarations do not shadow the brand.  */
/* ------------------------------------------------------------------ */
[data-theme="dark"],
.dark {
	--tz-text-strong: #ffffff; /* white — headings on navy */
	--tz-text-body: #eceff3; /* slate-100 */
	--tz-text-muted: #95a0b1; /* slate-400 */
	--tz-text-subtle: #6b7688; /* slate-500 — placeholders ONLY */

	--tz-surface-page: #0d0f29; /* navy-950 */
	--tz-surface-card: #15183c; /* navy-900 */
	--tz-surface-sunken: #1c1f47; /* navy-800 */
	--tz-surface-inverse: #eceff3; /* slate-100 */

	--tz-border-subtle: #25295a; /* navy-700 */
	--tz-border-default: #4e5868; /* slate-600 */
	--tz-border-strong: #95a0b1; /* slate-400 */
	--tz-border-focus: #5ea8de; /* blue-300 — primary on dark grounds */

	/* On navy, plain blue-500 fills still carry white labels; text-toned
	 * primary moves to blue-300 for contrast. */
	--tz-color-primary-weak: #1c1f47; /* navy-800 wash */
	--tz-color-primary-border: #25295a; /* navy-700 */
	/* Ring uses the border-focus token (blue-300 here, blue-500 in light);
	 * tokens.json declares no alpha value for focus rings. */
	--tz-ring-focus: 0 0 0 3px var(--tz-border-focus);
	--tz-ring-focus-outline: 3px solid var(--tz-border-focus);
	--tz-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);

	--primary: var(--tz-color-primary);
	--primary-color: var(--tz-color-primary);
	--btn-primary: var(--tz-color-primary);
	--text-color: var(--tz-text-body);
	--text-dark: var(--tz-text-body);
	--text-muted: var(--tz-text-muted);
	--heading-color: var(--tz-text-strong);
	--bg-color: var(--tz-surface-page);
	--card-bg: var(--tz-surface-card);
	--control-bg: var(--tz-surface-card);
	--border-color: var(--tz-border-subtle);
	--navbar-bg: var(--tz-surface-card);
	--desk-sidebar-bg: var(--tz-surface-sunken);
	--font-stack: var(--tz-font-body);

	--focus-default: var(--tz-ring-focus);
	--focus-outline-default: var(--tz-ring-focus-outline);

	--danger: var(--tz-color-danger);

	--bg-blue: var(--tz-color-primary);
	--text-on-blue: var(--tz-text-on-brand);
	--bg-green: var(--tz-color-secondary);
	--text-on-green: var(--tz-color-secondary-text);
	--bg-amber: var(--tz-color-warning);
	--text-on-amber: var(--tz-color-secondary-text);
	--bg-red: var(--tz-color-danger);
	--text-on-red: var(--tz-text-on-brand);

	--alert-bg-success: var(--tz-surface-sunken);
	--alert-bg-warning: var(--tz-surface-sunken);
	--alert-bg-danger: var(--tz-surface-sunken);
	--alert-bg-info: var(--tz-surface-sunken);

	--bt-solid-bg: var(--tz-color-primary);
	--bt-solid-bg-hover: var(--tz-color-primary-hover);
	--bt-solid-bg-active: var(--tz-color-primary-active);
	--bt-solid-fg: var(--tz-text-on-brand);
	color-scheme: dark;
}

/* ------------------------------------------------------------------ */
/* Type                                                                */
/* ------------------------------------------------------------------ */
html,
body {
	font-family: var(--tz-font-body);
}

h1,
h2,
h3,
h4,
h5,
h6,
.page-title,
.section-title {
	font-family: var(--tz-font-heading);
}

code,
pre,
kbd,
samp,
.text-monospace {
	font-family: var(--tz-font-mono);
}

/* Subtle text is for placeholders only. */
::placeholder,
input::placeholder,
textarea::placeholder {
	color: var(--tz-text-subtle);
}

/* RTL: Arabic body/UI type. */
html[dir="rtl"] body {
	font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
}

html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6 {
	font-family: "IBM Plex Sans Arabic", "Poppins", system-ui, sans-serif;
}

/* ------------------------------------------------------------------ */
/* Login page (web_include_css; markup untouched)                      */
/* v16 markup: frappe/www/login.html — no .login-page class exists;    */
/* the page root is #page-login, the card is .for-* > .page-card, and  */
/* an <img class="app-logo"> already renders in .page-card-head, fed   */
/* by the app_logo_url hook (navbar_settings.py get_app_logo).         */
/* ------------------------------------------------------------------ */
#page-login .page-card {
	background: var(--tz-surface-card);
	border: 1px solid var(--tz-border-subtle);
	border-radius: var(--radius-lg, 14px);
	box-shadow: var(--tz-shadow-sm);
}

#page-login .page-card img.app-logo {
	max-height: 48px;
	width: auto;
}

#page-login .page-card-subtitle {
	color: var(--tz-text-muted);
}

#page-login .form-control {
	border-color: var(--tz-border-default);
	background: var(--tz-surface-card);
	color: var(--tz-text-body);
}

#page-login .form-control:focus {
	border-color: var(--tz-border-focus);
	box-shadow: var(--tz-ring-focus);
}

#page-login .es-button[data-variant="solid"] {
	background: var(--tz-color-primary);
	color: var(--tz-text-on-brand);
	border-color: var(--tz-color-primary);
}

#page-login .es-button[data-variant="solid"]:hover {
	background: var(--tz-color-primary-hover);
}

#page-login .es-button[data-variant="solid"]:active {
	background: var(--tz-color-primary-active);
}
