// Case-insensitive string compare
int strCaseCmp(const char* s1, const char* s2) {
    while (*s1 && *s2) {
        if (tolower((unsigned char)*s1) != tolower((unsigned char)*s2))
            return (tolower((unsigned char)*s1) - tolower((unsigned char)*s2));
        s1++;
        s2++;
    }
    return *s1 - *s2;
}

// Delete all occurrences of song by title (case-insensitive)
int deleteSong(const char* title) {
    if (!head) return -1;

    Node* current = head;
    int deleted = 0;

    do {
        if (strCaseCmp(current->title, title) == 0) {
            deleted = 1;
            if (current->next == current) {  // only one node
                free(current);
                head = NULL;
                return 1;
            }

            Node* nextNode = current->next;
            current->prev->next = current->next;
            current->next->prev = current->prev;
            if (current == head) head = nextNode;
            free(current);
            current = nextNode;
            continue; // keep checking for duplicates
        }
        current = current->next;
    } while (current != head);

    return deleted ? 1 : 0; // 0 if not found
}