/* ==========================================================================
   Griffen / SSM ERP - central readability layer (v0.12.2)
   Rule: white / light background = dark text, dark background = light text.
   One place for every form control, dropdown list, modal and table filter, so
   a theme, a browser dark mode or an older rule can never produce invisible text.
   Loaded after ssm.css on the portal, the wp-admin ERP pages and the catalogue.
   Scopes: the portal body, the wp-admin console, the catalogue, modals.
   ========================================================================== */
:root{
	--ssm-ink:#0f172a;          /* text on light surfaces (contrast 17:1 on white) */
	--ssm-ink-soft:#334155;     /* secondary text on light surfaces */
	--ssm-ink-muted:#475569;    /* muted / placeholder-safe text (7.5:1 on white) */
	--ssm-field-bg:#ffffff;
	--ssm-field-bg-off:#f1f5f9;
	--ssm-pick-bg:#e0e7ff;      /* hover / selected row in lists */
	--ssm-on-dark:#ffffff;      /* text on dark / coloured surfaces */
}

/* ---- 1. Every control: dark text on white, in every state ---- */
body.ssm-body input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]):not([type=hidden]),
body.ssm-body select, body.ssm-body textarea,
.ssm-admin input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=button]):not([type=submit]):not([type=reset]):not([type=hidden]),
.ssm-admin select, .ssm-admin textarea,
.ssm-pc input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .ssm-pc select, .ssm-pc textarea,
.ssm-modal input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]), .ssm-modal select, .ssm-modal textarea{
	color:var(--ssm-ink) !important;
	-webkit-text-fill-color:var(--ssm-ink);   /* beats themes that force a text-fill colour */
	background-color:var(--ssm-field-bg);
	caret-color:var(--ssm-ink);
	color-scheme:light;                        /* native pop-ups (select list, date picker) render light, not OS-dark */
	opacity:1;
}
body.ssm-body input[type=file], .ssm-admin input[type=file], .ssm-modal input[type=file]{color:var(--ssm-ink) !important;background:transparent;color-scheme:light}

/* ---- 2. Dropdown lists when OPEN (native <select>) ---- */
body.ssm-body select option, body.ssm-body select optgroup,
.ssm-admin select option, .ssm-admin select optgroup,
.ssm-pc select option, .ssm-modal select option, .ssm-modal select optgroup{
	color:var(--ssm-ink) !important;
	background-color:#ffffff;
}
body.ssm-body select option:checked, body.ssm-body select option:hover,
.ssm-admin select option:checked, .ssm-admin select option:hover,
.ssm-pc select option:checked, .ssm-modal select option:checked, .ssm-modal select option:hover{
	color:var(--ssm-ink) !important;
	background-color:var(--ssm-pick-bg);
	background-image:linear-gradient(var(--ssm-pick-bg),var(--ssm-pick-bg));
}
body.ssm-body select option:disabled, .ssm-admin select option:disabled, .ssm-modal select option:disabled{color:var(--ssm-ink-muted) !important}
body.ssm-body select[multiple], .ssm-admin select[multiple]{color:var(--ssm-ink) !important;background-color:#fff}

/* ---- 3. Placeholder, hover, focus, disabled, read-only, auto-fill ---- */
body.ssm-body ::placeholder, .ssm-admin ::placeholder, .ssm-pc ::placeholder, .ssm-modal ::placeholder{color:var(--ssm-ink-muted) !important;-webkit-text-fill-color:var(--ssm-ink-muted);opacity:1}
body.ssm-body input:hover, body.ssm-body select:hover, body.ssm-body textarea:hover,
.ssm-admin input:hover, .ssm-admin select:hover, .ssm-admin textarea:hover{color:var(--ssm-ink) !important;-webkit-text-fill-color:var(--ssm-ink);background-color:#fff}
body.ssm-body input:focus, body.ssm-body select:focus, body.ssm-body textarea:focus,
.ssm-admin input:focus, .ssm-admin select:focus, .ssm-admin textarea:focus,
.ssm-pc input:focus, .ssm-pc select:focus, .ssm-modal input:focus, .ssm-modal select:focus, .ssm-modal textarea:focus{
	color:var(--ssm-ink) !important;-webkit-text-fill-color:var(--ssm-ink);background-color:#fff;
	outline:3px solid rgba(79,70,229,.35);outline-offset:1px;
}
body.ssm-body input:disabled, body.ssm-body select:disabled, body.ssm-body textarea:disabled, body.ssm-body input[readonly],
.ssm-admin input:disabled, .ssm-admin select:disabled, .ssm-admin textarea:disabled, .ssm-admin input[readonly],
.ssm-modal input:disabled, .ssm-modal select:disabled, .ssm-modal textarea:disabled, .ssm-modal input[readonly]{
	color:var(--ssm-ink-soft) !important;-webkit-text-fill-color:var(--ssm-ink-soft);background-color:var(--ssm-field-bg-off);opacity:1;cursor:not-allowed;
}
body.ssm-body input:-webkit-autofill, body.ssm-body select:-webkit-autofill, body.ssm-body textarea:-webkit-autofill,
.ssm-admin input:-webkit-autofill, .ssm-modal input:-webkit-autofill{
	-webkit-text-fill-color:var(--ssm-ink) !important;caret-color:var(--ssm-ink);
	-webkit-box-shadow:0 0 0 1000px #fff inset !important;box-shadow:0 0 0 1000px #fff inset !important;
}
/* date / time pickers: keep the native icon visible on a white field */
body.ssm-body input[type=date], body.ssm-body input[type=datetime-local], body.ssm-body input[type=time], body.ssm-body input[type=month],
.ssm-admin input[type=date], .ssm-modal input[type=date]{color-scheme:light;min-height:44px}
body.ssm-body input[type=date]::-webkit-datetime-edit, body.ssm-body input[type=datetime-local]::-webkit-datetime-edit,
body.ssm-body input[type=time]::-webkit-datetime-edit{color:var(--ssm-ink)}
body.ssm-body input[type=date]::-webkit-calendar-picker-indicator, body.ssm-body input[type=datetime-local]::-webkit-calendar-picker-indicator{opacity:.85;cursor:pointer}

/* ---- 4. Dynamically generated lists (product search suggestions, pickers, chips) ---- */
.ssm-suggest, .ssm-suggest li{color:var(--ssm-ink)}
.ssm-suggest li.ssm-muted{color:var(--ssm-ink-muted)}
.ssm-suggest button{color:var(--ssm-ink) !important;-webkit-text-fill-color:var(--ssm-ink);background:transparent}
.ssm-suggest button:hover, .ssm-suggest button:focus{color:var(--ssm-ink) !important;-webkit-text-fill-color:var(--ssm-ink);background:var(--ssm-pick-bg)}
.ssm-pick-chosen, .ssm-pick-chosen b, .ssm-chosen{color:var(--ssm-ink)}
.ssm-pick-chosen .ssm-muted, .ssm-pick-meta{color:var(--ssm-ink-muted)}
.ssm-chips a{color:#3730a3 !important}
.ssm-chips a:hover{color:#1e1b4b !important}

/* ---- 5. Panels, tables, filters, labels on light surfaces ---- */
.ssm-panel, .ssm-panel label, .ssm-field > span, .ssm-field label, .ssm-hint{color:var(--ssm-ink-soft)}
.ssm-panel h3, .ssm-panel h4, .ssm-field > span{color:var(--ssm-ink)}
.ssm-panel .ssm-muted, .ssm-muted{color:var(--ssm-ink-muted)}
.ssm-table, .ssm-table td, .ssm-table-wrap td{color:var(--ssm-ink)}
.ssm-table th{color:var(--ssm-ink)}
.ssm-filter-grid label, .ssm-filter-grid span{color:var(--ssm-ink-soft)}
.ssm-check span{color:var(--ssm-ink)}
.ssm-badge-muted, .ssm-badge-soon{color:var(--ssm-ink-muted) !important}   /* was #64748b on #f1f5f9 = 4.3:1 */

/* ---- 6. Dark / coloured surfaces keep light text ---- */
.ssm-card, .ssm-card .ssm-card-l, .ssm-card small, .ssm-card-v, .ssm-hero, .ssm-hero h3, .ssm-side-brand{color:var(--ssm-on-dark)}
.ssm-btn-primary, .ssm-btn-danger{color:var(--ssm-on-dark) !important}

/* ---- 7. wp-admin ERP console: wp-admin colour schemes never change field colours ---- */
.ssm-admin .widefat td, .ssm-admin .widefat th, .ssm-admin .form-table th, .ssm-admin .form-table td, .ssm-admin p, .ssm-admin label{color:#1e293b}
.ssm-admin h1, .ssm-admin h2, .ssm-admin h3{color:#0f172a}

/* ---- 8. v0.20.2 fixes found in the UI review ---- */
/* "Muted" badges (Void, Disabled, Sold, Built-in...) were dark text on a dark slate chip = unreadable. Light chip, dark text (~8:1). */
.ssm-badge-muted, .ssm-card .ssm-badge-muted{background:#e2e8f0 !important;background-image:none !important;color:#334155 !important;border:1px solid rgba(100,116,139,.45) !important;box-shadow:none !important}
/* These two classes were used in markup but never styled (quote "Waiting for approval" banner, duplicate-serial review). */
.ssm-alert-warn{background:linear-gradient(135deg,rgba(254,243,199,.95),rgba(254,226,226,.85));border:1px solid #fcd34d;color:#78350f}
.ssm-alert-ok{background:linear-gradient(135deg,rgba(209,250,229,.92),rgba(204,251,241,.92));border:1px solid #6ee7b7;color:#065f46}
