-- Couleurs I.F.PRO (logo) : vert RGB 26, 142, 98 = #1A8E62 ; noir RGB 3, 3, 3 = #030303.
-- Remplace le bleu de l'application (thème) et des documents (paramètres du centre). Sans risque, relançable.
-- phpMyAdmin : base I.F.PRO, onglet SQL, coller tout, Exécuter. Puis Ctrl+Maj+R sur l'application.

-- 1) Thème de l'application (thème général : boutons, liens, menu actif, en-têtes des tableaux)
INSERT INTO n_themes (thm_centre_id, thm_nom, thm_couleur_primaire, thm_couleur_secondaire, thm_couleur_accent, thm_couleur_fond, thm_couleur_surface,
  thm_couleur_texte, thm_couleur_texte_secondaire, thm_couleur_bordure, thm_couleur_menu_fond, thm_couleur_menu_texte, thm_couleur_entete_fond,
  thm_couleur_entete_texte, thm_couleur_succes, thm_couleur_avertissement, thm_couleur_erreur, thm_couleur_info, thm_police, thm_arrondi_px,
  thm_mode_sombre_autorise, thm_est_actif, created_at)
SELECT NULL, 'Charte I.F.PRO', '#1A8E62', '#126345', '#F0AD4E', '#F1F4F9', '#FFFFFF', '#1C2430', '#5A6474', '#EDF0F5', '#F6F8FC', '#5A6474', '#126345',
  '#FFFFFF', '#00A441', '#FFBE00', '#E63A40', '#5BC0DE', 'Inter', 8, 1, 1, NOW() FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM n_themes WHERE thm_centre_id IS NULL);

UPDATE n_themes SET thm_nom = 'Charte I.F.PRO', thm_couleur_primaire = '#1A8E62', thm_couleur_secondaire = '#126345', thm_couleur_entete_fond = '#126345',
  thm_est_actif = 1, updated_at = NOW()
WHERE thm_centre_id IS NULL;

-- Un éventuel thème propre au centre prendrait le dessus : mis aux mêmes couleurs
UPDATE n_themes SET thm_couleur_primaire = '#1A8E62', thm_couleur_secondaire = '#126345', thm_couleur_entete_fond = '#126345', updated_at = NOW()
WHERE thm_centre_id IS NOT NULL;

-- 2) Paramètres du centre I.F.PRO (couleurs de l'application et des documents)
UPDATE n_centre_param SET cp_couleur_principale = '#1A8E62', cp_couleur_secondaire = '#030303', updated_at = NOW()
WHERE cp_centre_id = (SELECT ct_id FROM n_centres WHERE ct_code = 'IFP');

-- Vérification
SELECT thm_id, thm_centre_id, thm_nom, thm_couleur_primaire, thm_couleur_secondaire, thm_couleur_entete_fond FROM n_themes;
SELECT cp_centre_nom, cp_couleur_principale, cp_couleur_secondaire FROM n_centre_param;
