/**
 * coach-detail.html 交互逻辑
 */

/* 任务展开/收起 */
function toggleAllTasks() {
    var hidden = document.getElementById('hiddenTasks');
    var btn = document.getElementById('toggleTasksBtn');
    if (hidden.classList.contains('hidden')) {
        hidden.classList.remove('hidden');
        btn.textContent = '收起 ↑';
    } else {
        hidden.classList.add('hidden');
        btn.textContent = '展开全部 ↓';
    }
}

/* 收入明细月份切换 */
function switchIncomeTab(tab) {
    var tabs = document.querySelectorAll('.income-tab');
    tabs.forEach(function(t) { t.classList.remove('active'); });
    document.getElementById('incomeTab_' + tab).classList.add('active');

    document.getElementById('incomeThisMonth').classList.toggle('hidden', tab !== 'this');
    document.getElementById('incomeLastMonth').classList.toggle('hidden', tab !== 'last');
}

/* 备注弹窗 */
function showNoteModal() {
    document.getElementById('noteModal').classList.remove('hidden');
    document.getElementById('noteModal').classList.add('flex');
    document.getElementById('noteText').value = '';
}
function hideNoteModal() {
    document.getElementById('noteModal').classList.add('hidden');
    document.getElementById('noteModal').classList.remove('flex');
}
function saveNote() {
    var text = document.getElementById('noteText').value.trim();
    if (!text) { showToast('请输入备注内容'); return; }
    hideNoteModal();
    showToast('备注已保存');
}

/* Toast */
function showToast(msg) {
    var toast = document.getElementById('toast');
    toast.textContent = msg;
    toast.classList.remove('hidden');
    setTimeout(function() { toast.classList.add('hidden'); }, 1500);
}
