/* ============================================================
 * 历史任务 Modal
 * ============================================================ */

.task-history-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: thm-fade-in 0.18s ease;
}

@keyframes thm-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.task-history-modal {
    background: #fff;
    border-radius: 18px;
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.4),
                0 8px 20px -8px rgba(124, 58, 237, 0.18);
    overflow: hidden;
    animation: thm-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes thm-pop {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ---------- 头部 ---------- */
.thm-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: linear-gradient(135deg, #FAFBFF 0%, #F5F3FF 100%);
    border-bottom: 1px solid #f1f5f9;
}

.thm-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #0F172A);
}

.thm-title .fa-regular {
    color: var(--accent, #7C3AED);
    font-size: 18px;
}

.thm-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}

.thm-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-primary, #0F172A);
}

.thm-close .fa-xmark {
    font-size: 16px;
}

/* ---------- Tabs ---------- */
.thm-tabs {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    padding: 12px 22px 0;
    border-bottom: 1px solid #f1f5f9;
}

.thm-tab {
    border: none;
    background: transparent;
    padding: 8px 16px;
    font-size: 13px;
    color: #64748b;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    font-weight: 500;
    transition: all 0.18s ease;
    position: relative;
}

.thm-tab:hover {
    color: var(--accent, #7C3AED);
    background: rgba(124, 58, 237, 0.04);
}

.thm-tab.active {
    color: #fff;
    background: linear-gradient(135deg, #3B82F6 0%, #4F46E5 100%);
    box-shadow: 0 4px 10px -2px rgba(79, 70, 229, 0.3);
}

/* ---------- 列表区 ---------- */
.thm-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 22px 22px;
}

/* 自定义滚动条 */
.thm-body::-webkit-scrollbar { width: 6px; }
.thm-body::-webkit-scrollbar-track { background: transparent; }
.thm-body::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.18);
    border-radius: 99px;
}
.thm-body::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 58, 237, 0.3);
}

/* ---------- 任务卡片 ---------- */
.thm-task {
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    position: relative;
}

.thm-task:hover {
    border-color: rgba(79, 70, 229, 0.5);
    box-shadow: 0 8px 24px -8px rgba(79, 70, 229, 0.18);
    transform: translateY(-1px);
}

.thm-task-thumb {
    width: 80px;
    height: 110px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.thm-task-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thm-task-thumb::after {
    content: '\f03d';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 22px;
}

.thm-task-thumb.has-thumb::after { display: none; }

.thm-task-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.thm-task-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.thm-task-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #0F172A);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.thm-platform-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(79, 70, 229, 0.08);
    color: #4F46E5;
    font-size: 11px;
    font-weight: 500;
}

.thm-task-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.thm-task-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: #94a3b8;
    margin-top: auto;
}

.thm-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.thm-status.success {
    color: #10B981;
}

.thm-status.failed {
    color: #EF4444;
}

.thm-status .fa-circle {
    font-size: 8px;
}

/* 删除按钮 */
.thm-task-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #fff;
    border: 1px solid #fecaca;
    color: #ef4444;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: all 0.18s ease;
    z-index: 2;
}

.thm-task:hover .thm-task-delete {
    opacity: 1;
}

.thm-task-delete:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

/* ---------- 空 / 加载状态 ---------- */
.thm-empty {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.thm-empty .fa-inbox {
    font-size: 36px;
    margin-bottom: 12px;
    color: #cbd5e1;
}

.thm-empty p {
    margin: 4px 0;
    font-size: 13px;
}

.thm-empty .thm-empty-hint {
    font-size: 12px;
    color: #cbd5e1;
}

.thm-loading {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 13px;
}

.thm-loading .fa-spinner {
    display: inline-block;
    animation: thm-spin 1s linear infinite;
    margin-right: 6px;
}

@keyframes thm-spin {
    from { transform: rotate(0); }
    to   { transform: rotate(360deg); }
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
    .task-history-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .task-history-modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 18px 18px 0 0;
        animation: thm-slide-up 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    @keyframes thm-slide-up {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .thm-task-thumb {
        width: 60px;
        height: 84px;
    }

    .thm-task-title {
        max-width: 160px;
    }
}
