-- Tabla de configuracion de prioridades de tareas (semaforizacion)
-- Permite configurar 6 niveles de colores segun dias antes/despues de vencimiento

CREATE TABLE IF NOT EXISTS task_priority_config (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    priority_level INTEGER NOT NULL UNIQUE,
    days_from INTEGER,
    days_to INTEGER,
    background_color TEXT NOT NULL DEFAULT '#FFFFFF',
    border_color TEXT NOT NULL DEFAULT '#CCCCCC',
    label TEXT NOT NULL,
    notify_superuser INTEGER DEFAULT 0,
    notify_assignee INTEGER DEFAULT 1,
    notify_creator INTEGER DEFAULT 0,
    is_active INTEGER DEFAULT 1,
    sort_order INTEGER DEFAULT 0
);

-- Insertar configuracion por defecto (6 niveles)
-- Columnas sincronizadas con tasksemaphore/admin.php::insertDefaults()
INSERT OR IGNORE INTO task_priority_config (priority_level, days_from, days_to, background_color, border_color, label, notify_superuser, notify_assignee, notify_creator, is_active, sort_order) VALUES
(0, 31, NULL, '#EEF6F0', '#B0D2B6', 'Lejana', 0, 0, 0, 1, 6),
(1, 15, 30, '#E8F5E9', '#81C784', 'Normal', 0, 0, 0, 1, 5),
(2, 7, 14, '#FFF9C4', '#FFF176', 'Proxima', 0, 0, 0, 1, 4),
(3, 1, 6, '#FFECB3', '#FFD54F', 'Urgente', 0, 1, 0, 1, 3),
(4, 0, 0, '#FFCDD2', '#EF5350', 'Hoy vence', 0, 1, 0, 1, 2),
(5, NULL, -1, '#F8E8E8', '#F0AFAD', 'Vencida', 0, 1, 0, 1, 1);
