-- =============================================================================
-- Apply Workwear-style light admin theme with ORANGE brand accent as the
-- install default. Safe to run multiple times. Only overwrites values that
-- are still at a previous default; custom admin-chosen colors are preserved.
-- =============================================================================
START TRANSACTION;

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_primary', 2, '#F97316', 'Admin primary color', 'string', 60, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_primary');

UPDATE `plugin_base_options` SET `value` = '#F97316'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_primary'
  AND LOWER(`value`) IN ('#4b5563', '#374151', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_secondary', 2, '#64748B', 'Admin secondary color', 'string', 61, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_secondary');

UPDATE `plugin_base_options` SET `value` = '#64748B'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_secondary'
  AND LOWER(`value`) IN ('#94a3b8', '#4b5563', '#9ca3af', '#8b5cf6', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_sidebar', 2, '#FDF9F8', 'Admin sidebar color', 'string', 62, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar');

UPDATE `plugin_base_options` SET `value` = '#FDF9F8'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar'
  AND LOWER(`value`) IN ('#111827', '#1d1d2d', '#4b5563', '#ffffff', '#fff6f0', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_success', 2, '#10B981', 'Admin success color', 'string', 63, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_success');

UPDATE `plugin_base_options` SET `value` = '#10B981'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_success'
  AND LOWER(`value`) IN ('#84b66a', '#059669', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_warning', 2, '#F59E0B', 'Admin warning color', 'string', 64, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_warning');

UPDATE `plugin_base_options` SET `value` = '#F59E0B'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_warning'
  AND LOWER(`value`) IN ('#f4c152', '#d97706', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_info', 2, '#3B6FA8', 'Admin info color', 'string', 65, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_info');

UPDATE `plugin_base_options` SET `value` = '#3B6FA8'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_info'
  AND LOWER(`value`) IN ('#94a3b8', '#0284c7', '#8b5cf6', '#3b82f6', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_danger', 2, '#EF4444', 'Admin danger color', 'string', 66, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_danger');

UPDATE `plugin_base_options` SET `value` = '#EF4444'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_danger'
  AND LOWER(`value`) IN ('#ef6b6b', '#b91c1c', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_sidebar_secondary', 2, '#FFF1E6', 'Sidebar secondary bg', 'string', 71, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_secondary');

UPDATE `plugin_base_options` SET `value` = '#FFF1E6'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_secondary'
  AND LOWER(`value`) IN ('#1f2937', '#282938', '#f8fafc', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_sidebar_active', 2, '#FFEAD9', 'Sidebar active bg', 'string', 72, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_active');

UPDATE `plugin_base_options` SET `value` = '#FFEAD9'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_active'
  AND LOWER(`value`) IN ('#374151', '#353543', '#fff1e6', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_sidebar_text', 2, '#64748B', 'Sidebar text color', 'string', 73, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_text');

UPDATE `plugin_base_options` SET `value` = '#64748B'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_text'
  AND LOWER(`value`) IN ('#f3f4f6', '#ffffff', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_sidebar_muted', 2, '#94A3B8', 'Sidebar muted text', 'string', 74, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_muted');

UPDATE `plugin_base_options` SET `value` = '#94A3B8'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_muted'
  AND LOWER(`value`) IN ('#9ca3af', '#868994', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_main_bg', 2, '#F8FAFC', 'Main page background', 'string', 75, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_main_bg');

UPDATE `plugin_base_options` SET `value` = '#F8FAFC'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_main_bg'
  AND LOWER(`value`) IN ('#f5f6f8', '#f7f7f6', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_card_bg2', 2, '#FFFFFF', 'Card background', 'string', 76, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_card_bg2');

UPDATE `plugin_base_options` SET `value` = '#FFFFFF'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_card_bg2'
  AND LOWER(`value`) IN ('#fefefe', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_table_border', 2, '#E2E8F0', 'Table border color', 'string', 77, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_border');

UPDATE `plugin_base_options` SET `value` = '#E2E8F0'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_border'
  AND LOWER(`value`) IN ('#e5e7eb', '#d1d1d0', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_input_border', 2, '#E2E8F0', 'Input border color', 'string', 78, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_input_border');

UPDATE `plugin_base_options` SET `value` = '#E2E8F0'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_input_border'
  AND LOWER(`value`) IN ('#e5e7eb', '#e0e0df', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_main_text', 2, '#0F172A', 'Main text color', 'string', 79, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_main_text');

UPDATE `plugin_base_options` SET `value` = '#0F172A'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_main_text'
  AND LOWER(`value`) IN ('#111827', '#2f2f2f', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_accent', 2, '#F97316', 'Accent color', 'string', 80, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_accent');

UPDATE `plugin_base_options` SET `value` = '#F97316'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_accent'
  AND LOWER(`value`) IN ('#4b5563', '#f9761b', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_link_color', 2, '#F97316', 'Link color', 'string', 81, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_link_color');

UPDATE `plugin_base_options` SET `value` = '#F97316'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_link_color'
  AND LOWER(`value`) IN ('#9ca3af', '#b9d5f3', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_table_header_bg', 2, '#F8FAFC', 'Table header background', 'string', 82, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_header_bg');

UPDATE `plugin_base_options` SET `value` = '#F8FAFC'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_header_bg'
  AND LOWER(`value`) IN ('#f3f4f6', '#374151', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_table_row_bg', 2, '#FFFFFF', 'Table row background', 'string', 83, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_row_bg');

UPDATE `plugin_base_options` SET `value` = '#FFFFFF'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_row_bg'
  AND LOWER(`value`) IN ('');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_table_row_alt', 2, '#F8FAFC', 'Table alt row background', 'string', 84, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_row_alt');

UPDATE `plugin_base_options` SET `value` = '#F8FAFC'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_row_alt'
  AND LOWER(`value`) IN ('#f9fafb', '#fafafa', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_table_row_hover', 2, '#FFF7ED', 'Table row hover background', 'string', 85, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_row_hover');

UPDATE `plugin_base_options` SET `value` = '#FFF7ED'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_row_hover'
  AND LOWER(`value`) IN ('#f9fafb', '#f3f4f6', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_table_text', 2, '#334155', 'Table text color', 'string', 86, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_text');

UPDATE `plugin_base_options` SET `value` = '#334155'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_table_text'
  AND LOWER(`value`) IN ('#374151', '#2f2f2f', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_heading_text', 2, '#0F172A', 'Heading text color', 'string', 87, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_heading_text');

UPDATE `plugin_base_options` SET `value` = '#0F172A'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_heading_text'
  AND LOWER(`value`) IN ('#111827', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_muted_text', 2, '#64748B', 'Muted text color', 'string', 88, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_muted_text');

UPDATE `plugin_base_options` SET `value` = '#64748B'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_muted_text'
  AND LOWER(`value`) IN ('#9ca3af', '#6b7280', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_link_text', 2, '#F97316', 'Link text color', 'string', 89, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_link_text');

UPDATE `plugin_base_options` SET `value` = '#F97316'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_link_text'
  AND LOWER(`value`) IN ('#4b5563', '#2563eb', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_sidebar_icon', 2, '#64748B', 'Sidebar icon color', 'string', 90, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_icon');

UPDATE `plugin_base_options` SET `value` = '#64748B'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_sidebar_icon'
  AND LOWER(`value`) IN ('#f3f4f6', '#ffffff', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_icon_color', 2, '#64748B', 'Icon color', 'string', 91, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_icon_color');

UPDATE `plugin_base_options` SET `value` = '#64748B'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_icon_color'
  AND LOWER(`value`) IN ('#4b5563', '#6b7280', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_topbar_bg', 2, '#FFFFFF', 'Topbar background', 'string', 92, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_topbar_bg');

UPDATE `plugin_base_options` SET `value` = '#FFFFFF'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_topbar_bg'
  AND LOWER(`value`) IN ('#f8f9fa', '');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_input_bg', 2, '#FFFFFF', 'Input background', 'string', 93, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_input_bg');

UPDATE `plugin_base_options` SET `value` = '#FFFFFF'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_input_bg'
  AND LOWER(`value`) IN ('');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_card_border', 2, '#E2E8F0', 'Card border color', 'string', 94, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `plugin_base_options` WHERE `foreign_id` = 1 AND `key` = 'o_admin_card_border');

UPDATE `plugin_base_options` SET `value` = '#E2E8F0'
WHERE `foreign_id` = 1 AND `key` = 'o_admin_card_border'
  AND LOWER(`value`) IN ('#e5e7eb', '');

COMMIT;
