-- DROP TABLE IF EXISTS `n_themes`;
CREATE TABLE IF NOT EXISTS `n_themes` (
  `thm_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `thm_centre_id` bigint(20) unsigned DEFAULT NULL,
  `thm_nom` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_primaire` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_secondaire` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_accent` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_fond` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_surface` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_texte` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_texte_secondaire` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_bordure` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_menu_fond` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_menu_texte` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_entete_fond` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_entete_texte` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_succes` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_avertissement` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_erreur` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_couleur_info` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `thm_police` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Inter',
  `thm_arrondi_px` tinyint(3) unsigned NOT NULL DEFAULT '8',
  `thm_mode_sombre_autorise` tinyint(1) NOT NULL DEFAULT '1',
  `thm_est_actif` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT (now()),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `thm_centre_key` bigint(20) unsigned GENERATED ALWAYS AS (ifnull(`thm_centre_id`,0)) VIRTUAL,
  PRIMARY KEY (`thm_id`),
  UNIQUE KEY `uq_theme_centre` (`thm_centre_key`),
  KEY `n_themes_thm_centre_id_foreign` (`thm_centre_id`),
  KEY `n_themes_created_by_foreign` (`created_by`),
  KEY `n_themes_updated_by_foreign` (`updated_by`),
  CONSTRAINT `n_themes_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `n_utilisateurs` (`user_id`) ON DELETE SET NULL,
  CONSTRAINT `n_themes_thm_centre_id_foreign` FOREIGN KEY (`thm_centre_id`) REFERENCES `n_centres` (`ct_id`) ON DELETE CASCADE,
  CONSTRAINT `n_themes_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `n_utilisateurs` (`user_id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT IGNORE INTO `n_themes` (`thm_id`, `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_by`, `updated_by`, `created_at`, `updated_at`) VALUES (1,NULL,'Charte SUP MTI','#2CA07D','#1C3B7B','#F0AD4E','#F1F4F9','#FFFFFF','#1C2430','#5A6474','#EDF0F5','#F6F8FC','#5A6474','#43557B','#FFFFFF','#00A441','#FFBE00','#E63A40','#5BC0DE','Inter',8,1,1,NULL,NULL,'2026-09-28 13:11:02','2026-10-09 12:58:40');


