/*
 * La couche des composants des thèmes SMATFLOW (apps/erp-gateway/docs/theme/erpnext, document 02 § 6).
 * Aucune couleur ici : seulement les jetons --smf-* qu'un thème définit (smatflow_themes.css, généré par ERP Gateway).
 * Rien ne s'applique tant que la société n'a pas choisi de thème (html[data-smatflow-theme]) ; le mode sombre de Frappe
 * reste le sien. Sélecteurs relevés dans les sources de Frappe version-15 (navbar.html, navbar.scss, global.scss,
 * buttons.scss, page.scss) le 10/11/2026.
 */

/* ── L'en-tête : seul élément sombre de l'écran (règle des écrans clairs, porteur 4/11/2026) ─────────────────── */
/* Les variables de Frappe y sont redéfinies : icônes (--icon-stroke), textes atténués, séparateurs suivent l'en-tête. */
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar {
  background: var(--smf-header-bg);
  border-bottom: 2px solid var(--smf-header-accent);
  --text-color: var(--smf-header-text);
  --text-muted: var(--smf-header-text);
  --text-light: var(--smf-header-text);
  --icon-stroke: var(--smf-header-text);
  --dark-border-color: color-mix(in srgb, var(--smf-header-text) 28%, transparent);
  color: var(--smf-header-text);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .nav-link,
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .navbar-brand,
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .text-muted,
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar #navbar-breadcrumbs a {
  color: var(--smf-header-text) !important;
}
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar #navbar-breadcrumbs a:hover {
  color: var(--smf-header-accent) !important;
}
/* Le logo de l'application, souvent sombre : un liseré clair le détache de l'en-tête. */
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .app-logo {
  border-radius: 6px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--smf-header-text) 45%, transparent);
}
/* La recherche de l'en-tête : un champ translucide, qui redevient clair et foncé au focus. */
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .search-bar .form-control {
  background: color-mix(in srgb, var(--smf-header-text) 12%, transparent);
  color: var(--smf-header-text);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .search-bar .form-control::placeholder {
  color: color-mix(in srgb, var(--smf-header-text) 72%, transparent);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .search-bar .form-control:focus {
  background: var(--smf-surface);
  color: var(--smf-text);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .search-bar:focus-within {
  --icon-stroke: var(--smf-text-muted);
}
/* Ce qui s'ouvre depuis l'en-tête (menus, notifications, résultats de recherche) reste clair et lisible. */
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .dropdown-menu,
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .awesomplete > ul {
  --text-color: var(--smf-text);
  --text-muted: var(--smf-text-muted);
  --text-light: var(--smf-text-muted);
  --icon-stroke: var(--smf-text);
  --dark-border-color: var(--smf-border);
  color: var(--smf-text);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .navbar .dropdown-menu .text-muted {
  color: var(--smf-text-muted) !important;
}

/* ── Le fond des pages : le bureau comme les pages web (connexion, portail) ─────────────────────────────────── */
html[data-smatflow-theme]:not([data-theme="dark"]) body {
  background-color: var(--smf-page-bg);
}

/* ── Les boutons secondaires : la teinte des champs, pas le gris de Frappe ───────────────────────────────────── */
html[data-smatflow-theme]:not([data-theme="dark"]) .btn.btn-default {
  background-color: var(--smf-control-bg);
  color: var(--smf-text);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .btn.btn-default:hover {
  background-color: var(--smf-border);
}

/* ── La page : titres, cartes, champs, liens ─────────────────────────────────────────────────────────────────── */
html[data-smatflow-theme]:not([data-theme="dark"]) .page-head .title-text,
html[data-smatflow-theme]:not([data-theme="dark"]) .widget-title,
html[data-smatflow-theme]:not([data-theme="dark"]) .ce-header {
  color: var(--smf-heading);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .layout-main-section.frappe-card,
html[data-smatflow-theme]:not([data-theme="dark"]) .widget,
html[data-smatflow-theme]:not([data-theme="dark"]) .frappe-card {
  border-radius: var(--smf-radius-card);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .form-control,
html[data-smatflow-theme]:not([data-theme="dark"]) .btn {
  border-radius: var(--smf-radius-control);
}

/* ── Le bouton d'appel : un par écran (« + » doré du pattern de l'écosystème) ───────────────────────────────── */
html[data-smatflow-theme]:not([data-theme="dark"]) .btn.btn-primary {
  background-color: var(--smf-primary-bg);
  border-color: var(--smf-primary-bg);
  color: var(--smf-primary-text);
  --icon-fill-bg: var(--smf-primary-bg);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .btn.btn-primary:hover,
html[data-smatflow-theme]:not([data-theme="dark"]) .btn.btn-primary:focus {
  background-color: var(--smf-primary-hover-bg);
  border-color: var(--smf-primary-hover-bg);
  color: var(--smf-primary-text);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .btn.btn-primary:active {
  background-color: var(--smf-primary-hover-bg) !important;
  color: var(--smf-primary-text) !important;
}

/* ── La barre latérale : l'élément ouvert, marqué d'un trait d'accent ────────────────────────────────────────── */
html[data-smatflow-theme]:not([data-theme="dark"]) .standard-sidebar-item.selected {
  background-color: var(--smf-sidebar-active-bg);
  box-shadow: inset 3px 0 0 var(--smf-accent);
}
html[data-smatflow-theme]:not([data-theme="dark"]) .standard-sidebar-item.selected > a,
html[data-smatflow-theme]:not([data-theme="dark"]) .standard-sidebar-item.selected .sidebar-item-label {
  color: var(--smf-sidebar-active-text);
}

/* ── Le focus : visible, au contraste des contrôles (3:1) ─────────────────────────────────────────────────────── */
html[data-smatflow-theme]:not([data-theme="dark"]) :focus-visible {
  outline: 2px solid var(--smf-focus-ring);
  outline-offset: 2px;
}

/* ── Les montants : chiffres tabulaires, colonnes alignées au centime ────────────────────────────────────────── */
html[data-smatflow-theme]:not([data-theme="dark"]) .frappe-control[data-fieldtype="Currency"],
html[data-smatflow-theme]:not([data-theme="dark"]) .frappe-control[data-fieldtype="Float"],
html[data-smatflow-theme]:not([data-theme="dark"]) .dt-cell__content,
html[data-smatflow-theme]:not([data-theme="dark"]) .grid-static-col[data-fieldtype="Currency"],
html[data-smatflow-theme]:not([data-theme="dark"]) .list-row-col .ellipsis {
  font-variant-numeric: tabular-nums;
}

/* La galerie du réglage « SMATFLOW Theme Settings » (visible avec ou sans thème). */
.smf-theme-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.smf-theme-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--text-color);
  cursor: pointer;
}
.smf-theme-card.is-chosen {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.smf-theme-card small {
  color: var(--text-muted);
}
.smf-theme-swatches {
  display: flex;
  gap: 4px;
}
.smf-theme-swatches i {
  width: 28px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
