/* ==========================================================================
   TASK NOTIFICATION CENTER (獨立任務通知中心)
   用於 Git 同步、離線下載、檔案上傳等具備進度條之任務卡片
   ========================================================================== */

:root {
    --task-cyan: var(--hud-cyan, #00f3ff);
    --task-green: var(--hud-green, #00ffaa);
    --task-red: var(--hud-red, #ff3e3e);
    --task-yellow: var(--hud-yellow, #ffb700);
    --task-bg: var(--bg-panel, rgba(6, 12, 22, 0.94));
    --task-border: var(--hud-panel-border, rgba(0, 243, 255, 0.22));
}

/* 獨立通知中心外層容器（位於左上角，自 Header 下方向下排開） */
#task-notification-center {
    position: fixed;
    top: calc(52px + env(safe-area-inset-top, 0px));
    left: 16px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 330px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
    user-select: none;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
}

/* 單一任務卡片本體 */
.task-notification-item {
    pointer-events: auto;
    position: relative;
    background: var(--task-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--task-border);
    border-left: 3.5px solid var(--task-accent, var(--task-cyan));
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 12px rgba(var(--hud-cyan-rgb, 0, 243, 255), 0.12);
    padding: 10px 12px 10px 14px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: top center;
    animation: taskItemSlideDown 0.44s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    max-height: 120px;
    will-change: transform, opacity, filter;
}

/* 狀態色彩變數 */
.task-notification-item.status-running {
    --task-accent: var(--task-cyan);
    border-color: var(--hud-panel-border-active, rgba(0, 243, 255, 0.28));
}

.task-notification-item.status-success {
    --task-accent: var(--task-green);
    border-color: rgba(0, 255, 170, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 14px rgba(0, 255, 170, 0.18);
}

.task-notification-item.status-error {
    --task-accent: var(--task-red);
    border-color: rgba(255, 62, 62, 0.38);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 14px rgba(255, 62, 62, 0.2);
}

.task-notification-item.status-warning {
    --task-accent: var(--task-yellow);
    border-color: rgba(255, 183, 0, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 14px rgba(255, 183, 0, 0.18);
}

/* 由上往下刷出進場動畫 (自然滑翔展開與柔焦凝聚) */
@keyframes taskItemSlideDown {
    0% {
        opacity: 0;
        transform: translateY(-26px) scale(0.94);
        filter: blur(5px);
    }
    60% {
        filter: blur(0px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0px);
    }
}

/* 平滑消失收合動畫 (兩階段分層消散：純 CSS Animation 保證覆蓋進場動畫並 100% 平滑播放) */
.task-notification-item.dismissing {
    animation: taskItemDismiss 0.48s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
    pointer-events: none !important;
}

@keyframes taskItemDismiss {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0px);
        max-height: 120px;
        margin-top: 0px;
        margin-bottom: 0px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    40% {
        /* 第一階段 (0s ~ 0.19s)：先向上飄散、微縮並淡出至透明，高度與邊距保持不變，杜絕文字被擠壓 */
        opacity: 0;
        transform: translateY(-14px) scale(0.93);
        filter: blur(4px);
        max-height: 120px;
        margin-top: 0px;
        margin-bottom: 0px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    100% {
        /* 第二階段 (0.19s ~ 0.48s)：內容已 100% 完全隱形，高度與邊距平滑折疊歸零，下方卡片絲滑遞補 */
        opacity: 0;
        transform: translateY(-20px) scale(0.90);
        filter: blur(6px);
        max-height: 0px;
        margin-top: 0px;
        margin-bottom: -10px;
        padding-top: 0px;
        padding-bottom: 0px;
        border-color: transparent;
        box-shadow: none;
    }
}

/* 頂部標題列 (Icon + 標題 + 百分比 + 關閉按鈕) */
.task-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
}

.task-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.task-icon {
    font-size: 0.85rem;
    color: var(--task-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    flex-shrink: 0;
    transition: color 0.3s ease;
}

.task-title-text {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f1f5f9;
    letter-spacing: 0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-meta-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.task-percent-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--task-accent);
    letter-spacing: 0.5px;
    min-width: 34px;
    text-align: right;
    transition: color 0.3s ease;
}

/* 卡片右上方手動關閉小按鈕 */
.task-close-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 2px 4px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}

.task-close-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.1);
}

/* 中間動態內容文字 */
.task-message-text {
    font-size: 0.73rem;
    color: #94a3b8;
    line-height: 1.35;
    margin-bottom: 7px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s ease;
}

/* 底部進度條槽道 */
.task-progress-track {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

/* 動態進度條本體 */
.task-progress-bar {
    height: 100%;
    border-radius: 999px;
    width: 0%;
    background: linear-gradient(90deg, #00c6ff 0%, var(--task-accent) 100%);
    box-shadow: 0 0 8px var(--task-accent);
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}

/* 未定進度條 (Indeterminate 流光掃描) */
.task-progress-bar.indeterminate {
    width: 35% !important;
    position: absolute;
    top: 0;
    left: -35%;
    animation: taskIndeterminateSlide 1.3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes taskIndeterminateSlide {
    0% {
        left: -35%;
    }
    100% {
        left: 100%;
    }
}
