-- Set Minimal Light as the default admin visual theme.
-- Existing custom colors are preserved; only missing values and the previous default palette are changed.
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, '#374151', '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` = '#374151'
WHERE `foreign_id` = 1
  AND `key` = 'o_admin_primary'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#0a5114');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_secondary', 2, '#9CA3AF', '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` = '#9CA3AF'
WHERE `foreign_id` = 1
  AND `key` = 'o_admin_secondary'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#2e6e4a');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_sidebar', 2, '#4B5563', '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` = '#4B5563'
WHERE `foreign_id` = 1
  AND `key` = 'o_admin_sidebar'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#07320e');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_success', 2, '#059669', '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` = '#059669'
WHERE `foreign_id` = 1
  AND `key` = 'o_admin_success'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#22c55e');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_warning', 2, '#D97706', '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` = '#D97706'
WHERE `foreign_id` = 1
  AND `key` = 'o_admin_warning'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#f59e0b');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_info', 2, '#0284C7', '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` = '#0284C7'
WHERE `foreign_id` = 1
  AND `key` = 'o_admin_info'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#3b82f6');

INSERT INTO `plugin_base_options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_admin_danger', 2, '#B91C1C', '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` = '#B91C1C'
WHERE `foreign_id` = 1
  AND `key` = 'o_admin_danger'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#dc2626');

COMMIT;

START TRANSACTION;

INSERT INTO `options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_brand_color', 1, '#374151', 'Brand color', 'string', 150, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `options` WHERE `foreign_id` = 1 AND `key` = 'o_brand_color');

UPDATE `options`
SET `value` = '#374151'
WHERE `foreign_id` = 1
  AND `key` = 'o_brand_color'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#0a5114');

INSERT INTO `options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_accent_color', 1, '#9CA3AF', 'Accent color', 'string', 151, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `options` WHERE `foreign_id` = 1 AND `key` = 'o_accent_color');

UPDATE `options`
SET `value` = '#9CA3AF'
WHERE `foreign_id` = 1
  AND `key` = 'o_accent_color'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#2e6e4a');

INSERT INTO `options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_price_color', 1, '#374151', 'Price color', 'string', 154, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `options` WHERE `foreign_id` = 1 AND `key` = 'o_price_color');

UPDATE `options`
SET `value` = '#374151'
WHERE `foreign_id` = 1
  AND `key` = 'o_price_color'
  AND (`value` IS NULL OR `value` = '' OR LOWER(`value`) = '#0a5114');

COMMIT;

START TRANSACTION;

UPDATE `multi_lang` ml
INNER JOIN `fields` f ON f.`id` = ml.`foreign_id`
SET ml.`content` = 'Classic Green'
WHERE f.`key` = 'visual_palette_default'
  AND ml.`model` = 'pjField'
  AND ml.`field` = 'title';

UPDATE `multi_lang` ml
INNER JOIN `fields` f ON f.`id` = ml.`foreign_id`
SET ml.`content` = 'Default'
WHERE f.`key` = 'visual_palette_minimal_light'
  AND ml.`model` = 'pjField'
  AND ml.`field` = 'title';

COMMIT;
