/* ================================================================
   浮动任务面板 - 浏览器下载风格
   ================================================================ */

/* 触发按钮 - 下载图标风格 */
.task-panel-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(79,70,229,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 20000;
    transition: transform 0.15s, box-shadow 0.15s;
}
.task-panel-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(79,70,229,0.5);
}
.task-panel-trigger.open {
    transform: rotate(0deg);
}
.task-panel-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #1a1a2e;
}

/* 面板主体 - 类似浏览器下载弹窗 */
.task-panel {
    position: fixed;
    bottom: 78px;
    right: 24px;
    width: 360px;
    max-height: 480px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
}
.task-panel.open {
    display: flex;
    animation: taskPanelIn 0.2s ease;
}
@keyframes taskPanelIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 头部 */
.task-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: #fff;
}
.task-panel-header span {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}
.task-panel-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.task-panel-close:hover {
    color: #374151;
    background: #f3f4f6;
}

/* 头部操作按钮组 */
.task-panel-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.task-panel-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.12s;
    line-height: 1;
}
.task-panel-action-btn:hover {
    background: #f3f4f6;
}

/* 列表 */
.task-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
    background: #fff;
}
.task-list::-webkit-scrollbar { width: 4px; }
.task-list::-webkit-scrollbar-track { background: transparent; }
.task-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.task-empty {
    text-align: center;
    padding: 28px 16px;
    color: #9ca3af;
    font-size: 13px;
    list-style: none;
}

/* 任务项 */
.task-item {
    background: #f9fafb;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.12s;
    border: 1px solid transparent;
}
.task-item:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}
.task-item.completed {
    border-color: #d1fae5;
    background: #f0fdf4;
}
.task-item.failed {
    border-color: #fee2e2;
    background: #fef2f2;
}

.task-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}
.task-tool-icon {
    font-size: 15px;
    flex-shrink: 0;
}
.task-id {
    font-size: 10px;
    color: #9ca3af;
    font-family: monospace;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.task-status-text {
    font-size: 10px;
    color: #6b7280;
    flex-shrink: 0;
}

.task-prompt-text {
    font-size: 12px;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 6px;
}

/* 进度条 */
.task-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.task-progress-bar {
    flex: 1;
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}
.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #6366f1);
    border-radius: 2px;
    transition: width 0.4s ease;
}
.task-progress-pct {
    font-size: 10px;
    color: #9ca3af;
    min-width: 30px;
    text-align: right;
}
.task-msg {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 结果预览 */
.task-result-img, .task-result-video {
    width: 100%;
    max-height: 100px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 6px;
    display: block;
}
.task-result-video {
    background: #000;
}

/* 错误信息 */
.task-error-text {
    font-size: 11px;
    color: #dc2626;
    margin-bottom: 6px;
    word-break: break-all;
}

/* 操作按钮行 */
.task-actions-row {
    display: flex;
    gap: 4px;
}
.task-btn {
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.12s;
    line-height: 1.4;
}
.task-btn:hover {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}
.task-btn-pause:hover { color: #f59e0b; border-color: #fde68a; }
.task-btn-resume:hover { color: #10b981; border-color: #a7f3d0; }
.task-btn-detail:hover { color: #4f46e5; border-color: #c7d2fe; }
.task-btn-remove:hover { color: #dc2626; border-color: #fecaca; }


/* 任务添加动画 */
@keyframes taskItemIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
.task-item-new {
    animation: taskItemIn 0.3s ease forwards;
}

/* 移动端适配 */
@media (max-width: 767px) {
    .task-panel {
        bottom: 80px !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
        max-height: 60vh !important;
        border-radius: 16px 16px 0 0 !important;
        animation: taskPanelSlideUp 0.3s ease !important;
    }
    .task-panel.open {
        animation: taskPanelSlideUp 0.3s ease;
    }
    @keyframes taskPanelSlideUp {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: translateY(0); }
    }
    .task-panel-trigger {
        bottom: 16px !important;
        right: 16px !important;
    }
}
