/* Shinvoy's theme for Frappe's desk, its login page and every app (docs/design-system.md).
 *
 * Frappe 16 paints with Espresso tokens (--surface-*, --ink-*, --outline-*), and its older names (--fg-color,
 * --card-bg, --border-color, --btn-primary …) are aliases of them, all built on one neutral --gray-* ramp. Each of our
 * React apps' tokens (<app>/frontend/app.css) read those same names. So the ramp below, warm instead of neutral, in
 * light and in dark, re-themes Frappe and every app at once. Only layout-free things are touched: colour, font,
 * radius and shadow.
 *
 * Order matters: the light block comes first and the dark block after it, both at the same specificity as Frappe's,
 * so on <html data-theme="dark"> the dark one wins and on light the light one does.
 */

:root,
[data-theme="light"] {
	/* the warm ladder: 50 is the soft page, 100 the cream band, 200 the hairline, 300 the field border */
	--gray-50: #fbf9f6;
	--gray-100: #f3eee3;
	--gray-200: #e4ded3;
	--gray-300: #d4ccbf;
	--gray-400: #b3ab9f;
	--gray-500: #8c857b;
	--gray-600: #6e685f;
	--gray-700: #57524b;
	--gray-800: #3a3632;
	--gray-900: #312d2a; /* the action charcoal: --btn-primary is --surface-gray-10, which is this */
	--gray-950: #111111; /* ink */

	--ink-gray-8: #111111; /* body text (Frappe's --text-color) is ink, not charcoal */
	--surface-sidebar: #fbf9f6;

	--ss-canvas: #ffffff;
	--ss-canvas-soft: #fbf9f6;
	--ss-canvas-warm: #f3eee3;
	--ss-hairline: #e4ded3;
	--ss-field: #d4ccbf;
	--ss-ink: #111111;
	--ss-ink-2: #57524b;
	--ss-primary: #312d2a;
	--ss-primary-pressed: #47423e;
	--ss-on-primary: #ffffff;
	--ss-mark: #d9541e;
	--ss-link: #006b8f;
	--ss-focus: #227e9e;
	--ss-late: #b42318;
	--ss-late-bg: #fdf1ef;
	--ss-soon: #8a5a00;
	--ss-soon-bg: #fbf3e4;
	--ss-good: #2f6b3a;
}

[data-theme="dark"],
.dark {
	--gray-50: #f3eee3;
	--gray-100: #ddd6ca;
	--gray-200: #b3ab9f;
	--gray-300: #9c9489;
	--gray-400: #7d766c;
	--gray-450: #5a544d;
	--gray-500: #46413b;
	--gray-600: #3b3732;
	--gray-700: #2e2a26;
	--gray-800: #26231f;
	--gray-900: #1f1c19;
	--gray-950: #171513;

	--ink-gray-8: #f3eee3;
	--surface-sidebar: transparent;

	--ss-canvas: #1f1c19;
	--ss-canvas-soft: #171513;
	--ss-canvas-warm: #26231f;
	--ss-hairline: #3b3732;
	--ss-field: #46413b;
	--ss-ink: #f3eee3;
	--ss-ink-2: #b3ab9f;
	--ss-primary: #f3eee3; /* the action flips polarity on dark, as Oracle's inverse button does */
	--ss-primary-pressed: #ddd6ca;
	--ss-on-primary: #111111;
	--ss-mark: #d9541e;
	--ss-link: #5bb8db;
	--ss-focus: #5bb8db;
	--ss-late: #f0857a;
	--ss-late-bg: #3a1e1a;
	--ss-soon: #e2b65e;
	--ss-soon-bg: #33290f;
	--ss-good: #7cc48a;
}

/* both themes: Inter (Frappe ships it in /assets/frappe/css/fonts, so nothing comes from Google), Japanese from the
 * system, no shadows anywhere, and the focus ring in our blue */
:root,
[data-theme="light"],
[data-theme="dark"] {
	--font-stack: "InterVariable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
		"Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "Noto Sans JP", sans-serif;

	--elevation-sm: none;
	--elevation-base: none;
	--elevation-md: none;
	--elevation-lg: none;
	--elevation-xl: none;
	--elevation-2xl: none;
	--shadow-sm: none;
	--shadow: none;
	--shadow-md: none;
	--shadow-lg: none;
	--shadow-xl: none;
	--shadow-2xl: none;
	--shadow-base: none;
	--shadow-xs: none;
	--custom-shadow-sm: none;
	--drop-shadow: none;
	--card-shadow: none;
	--highlight-shadow: none;

	--focus-default: 0 0 0 2px var(--ss-focus);
	--focus-outline-default: 2px solid var(--ss-focus);
}

body {
	font-family: var(--font-stack);
	font-feature-settings: "cv11" 1;
}

/* every action is the charcoal (cream on dark) at 4px; links in our teal-blue */
.btn {
	border-radius: var(--radius-sm);
}
.btn.btn-primary {
	background-color: var(--ss-primary);
	color: var(--ss-on-primary);
	--icon-fill-bg: var(--ss-primary);
}
.btn.btn-primary:hover,
.btn.btn-primary:focus-visible {
	background-color: var(--ss-primary-pressed);
	color: var(--ss-on-primary);
}
.btn.btn-primary:active {
	color: var(--ss-on-primary) !important;
	background-color: var(--ss-primary-pressed) !important;
}
.btn.btn-secondary-dark,
.btn.btn-default {
	border-radius: var(--radius-sm);
}
.ql-editor a,
.frappe-control a:not(.btn),
.like-disabled-input a,
.markdown-preview a {
	color: var(--ss-link);
}

/* depth comes from the ladder and a hairline, so whatever used to float on a shadow gets a border */
.dropdown-menu,
.popover,
.modal-content,
.awesomplete > ul,
.frappe-card,
.widget,
.toast,
.datepicker {
	box-shadow: none !important;
}
.dropdown-menu,
.popover,
.modal-content,
.awesomplete > ul,
.datepicker {
	border: 1px solid var(--ss-hairline) !important;
}
.frappe-card,
.widget {
	border: 1px solid var(--ss-hairline);
	border-radius: var(--radius);
}

/* inputs read as something you type into: white with the field border, as on the mockup's search */
.form-control,
.frappe-control .like-disabled-input,
.search-widget-button {
	box-shadow: none;
}
input.form-control:not([type="checkbox"]):not([type="radio"]),
textarea.form-control,
select.form-control {
	background-color: var(--ss-canvas);
	border: 1px solid var(--ss-field);
	border-radius: var(--radius-sm);
}
input.form-control:focus,
textarea.form-control:focus,
select.form-control:focus {
	border-color: var(--ss-focus);
	box-shadow: 0 0 0 1px var(--ss-focus);
}

/* the login page: a white card with a hairline on the soft page */
body[data-path="login"],
body[data-path="update-password"] {
	background-color: var(--ss-canvas-soft);
}
body[data-path="login"] .page-card,
body[data-path="login"] .login-content,
body[data-path="update-password"] .page-card {
	background-color: var(--ss-canvas);
	border: 1px solid var(--ss-hairline);
	border-radius: var(--radius);
	box-shadow: none;
}
body[data-path="login"] .btn-login,
body[data-path="login"] .btn-primary {
	background-color: var(--ss-primary);
	color: var(--ss-on-primary);
}

/* Frappe's own pop-ups, buttons and status pills in the design system's look (docs/design-system.md), so every
   frappe.ui.Dialog, prompt, confirm, msgprint and list pill matches the React screens. One place, every app. */

/* dialogs: 8px like every card, a hairline instead of a shadow (above) */
.modal-content {
	border-radius: var(--radius);
}
.modal-header,
.modal-footer {
	border-color: var(--ss-hairline);
}

/* the secondary button: white with a hairline, not Frappe's cream fill */
.btn.btn-default,
.btn.btn-secondary {
	background-color: var(--ss-canvas);
	color: var(--ss-ink);
	border: 1px solid var(--ss-hairline);
}
.btn.btn-default:hover,
.btn.btn-secondary:hover,
.btn.btn-default:focus-visible,
.btn.btn-secondary:focus-visible {
	background-color: var(--ss-canvas);
	border-color: var(--ss-field);
	color: var(--ss-ink);
}
/* a danger action is outlined in late red, never a red fill */
.btn.btn-danger {
	background-color: var(--ss-canvas);
	color: var(--ss-late);
	border: 1px solid color-mix(in srgb, var(--ss-late) 40%, transparent);
}
.btn.btn-danger:hover,
.btn.btn-danger:focus-visible {
	background-color: var(--ss-late-bg);
	color: var(--ss-late);
}

/* status pills: 4px tags. Late is red, soon is amber, good is green text, everything else neutral; no orange,
   no purple, no cyan (the list views' colours map onto these without touching their code) */
.indicator-pill,
.indicator-pill-right {
	border-radius: var(--radius-sm);
}
.indicator-pill.red,
.indicator-pill-right.red,
.indicator-pill.pink,
.indicator-pill-right.pink {
	background: var(--ss-late-bg);
	color: var(--ss-late);
}
.indicator-pill.orange,
.indicator-pill-right.orange,
.indicator-pill.yellow,
.indicator-pill-right.yellow,
.indicator-pill.amber,
.indicator-pill-right.amber {
	background: var(--ss-soon-bg);
	color: var(--ss-soon);
}
.indicator-pill.green,
.indicator-pill-right.green {
	background: var(--ss-canvas);
	color: var(--ss-good);
	box-shadow: inset 0 0 0 1px var(--ss-hairline);
}
.indicator-pill.blue,
.indicator-pill-right.blue,
.indicator-pill.light-blue,
.indicator-pill-right.light-blue,
.indicator-pill.cyan,
.indicator-pill-right.cyan,
.indicator-pill.purple,
.indicator-pill-right.purple,
.indicator-pill.violet,
.indicator-pill-right.violet,
.indicator-pill.gray,
.indicator-pill-right.gray,
.indicator-pill.grey,
.indicator-pill-right.grey,
.indicator-pill.darkgrey,
.indicator-pill-right.darkgrey {
	background: var(--ss-canvas);
	color: var(--ss-ink-2);
	box-shadow: inset 0 0 0 1px var(--ss-hairline);
}
/* the dots on pills, list rows, dashboards and toasts follow the same four meanings */
.indicator.red::before, .indicator-pill.red::before, .indicator-pill-right.red::after,
.indicator.pink::before, .indicator-pill.pink::before {
	background: var(--ss-late);
}
.indicator.orange::before, .indicator-pill.orange::before, .indicator-pill-right.orange::after,
.indicator.yellow::before, .indicator-pill.yellow::before, .indicator-pill-right.yellow::after,
.indicator.amber::before, .indicator-pill.amber::before {
	background: var(--ss-soon);
}
.indicator.green::before, .indicator-pill.green::before, .indicator-pill-right.green::after {
	background: var(--ss-good);
}
.indicator.blue::before, .indicator-pill.blue::before, .indicator-pill-right.blue::after,
.indicator.light-blue::before, .indicator-pill.light-blue::before,
.indicator.cyan::before, .indicator-pill.cyan::before, .indicator-pill-right.cyan::after,
.indicator.purple::before, .indicator-pill.purple::before, .indicator-pill-right.purple::after,
.indicator.violet::before, .indicator-pill.violet::before,
.indicator.gray::before, .indicator-pill.gray::before, .indicator-pill-right.gray::after,
.indicator.grey::before, .indicator-pill.grey::before,
.indicator.darkgrey::before, .indicator-pill.darkgrey::before {
	background: var(--ss-field);
}

/* form headlines and alerts: the same meanings as the pills, on the soft ladder instead of Frappe's colour blocks */
.form-message,
.alert {
	border-radius: var(--radius-sm);
}
.form-message.blue,
.form-message.green,
[data-theme="dark"] .form-message.blue,
[data-theme="dark"] .form-message.green,
.alert-info,
.alert-success,
.alert-primary,
.alert-secondary {
	background: var(--ss-canvas-soft);
	color: var(--ss-ink);
	border: 1px solid var(--ss-hairline);
}
.form-message.yellow,
.form-message.orange,
[data-theme="dark"] .form-message.yellow,
[data-theme="dark"] .form-message.orange,
.alert-warning {
	background: var(--ss-soon-bg);
	color: var(--ss-soon);
	border: 0;
}
.form-message.red,
[data-theme="dark"] .form-message.red,
.alert-danger {
	background: var(--ss-late-bg);
	color: var(--ss-late);
	border: 0;
}
.text-danger {
	color: var(--ss-late) !important;
}

/* inside a pop-up, fields are the React dialogs' 36px (lib/ui.tsx), so every pop-up in an app reads the same;
   forms on the page keep Frappe's own height */
.modal-body input.form-control:not([type="checkbox"]):not([type="radio"]),
.modal-body select.form-control {
	height: 36px;
}
.modal-title {
	font-weight: 700;
}

/* Frappe 16's own buttons (es-button: the confirm/prompt footer, the page head's New task and language, tree and
   grid buttons). The default and subtle ones are the design's secondary: white with a hairline at 4px; solid is the
   charcoal action. Ghost (icon-only) buttons keep their quiet hover. */
.es-button {
	--bt-solid-bg: var(--ss-primary);
	--bt-solid-bg-hover: var(--ss-primary-pressed);
	--bt-solid-bg-active: var(--ss-primary-pressed);
	--bt-solid-fg: var(--ss-on-primary);
	--bt-fill-bg: var(--ss-canvas);
	--bt-fill-bg-hover: var(--ss-canvas);
	--bt-fill-bg-active: var(--ss-canvas-soft);
	--bt-fg: var(--ss-ink);
	--bt-border: var(--ss-hairline);
	--bt-border-hover: var(--ss-field);
	border-radius: var(--radius-sm);
}
.es-button:not([data-variant]),
.es-button[data-variant=subtle] {
	border-color: var(--ss-hairline);
}
.es-button:not([data-variant]):hover,
.es-button[data-variant=subtle]:hover {
	border-color: var(--ss-field);
}
/* the dialog footer's own pair: secondary as above, primary charcoal */
.btn-modal-primary {
	background: var(--ss-primary);
	color: var(--ss-on-primary);
	border-color: transparent;
}
.btn-modal-primary:hover {
	background: var(--ss-primary-pressed);
}
