/*
   前端UI高级增强 - Advanced UI Enhancements
   - 微交互动画
   - 骨架屏加载
   - 悬停特效
   - 视觉反馈增强
   创建时间: 2026-01-20
*/

/* ==================== 骨架屏加载效果 ==================== */

/* 任务卡片骨架屏 */
.task-item.skeleton {
    pointer-events: none;
    user-select: none;
}

.task-item.skeleton .task-card-header,
.task-item.skeleton .task-prompt,
.task-item.skeleton .task-tag,
.task-item.skeleton .task-btn {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    color: transparent;
    border-color: transparent;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 文本骨架 */
.skeleton-text {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    height: 16px;
    margin: 8px 0;
}

.skeleton-text.large {
    height: 24px;
}

.skeleton-text.small {
    height: 12px;
    width: 60%;
}

/* ==================== 按钮涟漪效果 ==================== */

.btn,
.task-btn {
    position: relative;
    overflow: hidden;
}

.btn.ripple-effect::after,
.task-btn.ripple-effect::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn.ripple-effect:active::after,
.task-btn.ripple-effect:active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

/* ==================== 浮动标签输入框 ==================== */

.input-floating-label {
    position: relative;
    margin: 20px 0;
}

.input-floating-label input,
.input-floating-label textarea {
    width: 100%;
    padding: 16px 12px 8px 12px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-main);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-floating-label label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-input);
    padding: 0 4px;
}

.input-floating-label input:focus,
.input-floating-label textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
    outline: none;
}

.input-floating-label input:focus + label,
.input-floating-label input:not(:placeholder-shown) + label,
.input-floating-label textarea:focus + label,
.input-floating-label textarea:not(:placeholder-shown) + label {
    top: 0;
    font-size: 12px;
    color: var(--primary);
    transform: translateY(0);
}

/* ==================== 输入验证视觉反馈 ==================== */

.input-floating-label.valid input {
    border-color: var(--success);
}

.input-floating-label.valid label {
    color: var(--success);
}

.input-floating-label.invalid input {
    border-color: var(--danger);
    animation: shake 0.5s;
}

.input-floating-label.invalid label {
    color: var(--danger);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ==================== Toast通知增强 ==================== */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
}

.toast.success::before {
    background: var(--success);
}

.toast.error::before {
    background: var(--danger);
}

.toast.warning::before {
    background: var(--warning);
}

.toast.info::before {
    background: #3b82f6;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.removing {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast.info .toast-icon {
    color: #3b82f6;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-main);
}

.toast-message {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.toast-progress-bar {
    height: 100%;
    background: var(--primary);
    animation: toastProgress 3s linear forwards;
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-main);
}

/* ==================== 卡片入场动画 ==================== */

.task-item {
    animation: cardFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.task-item:nth-child(1) { animation-delay: 0s; }
.task-item:nth-child(2) { animation-delay: 0.05s; }
.task-item:nth-child(3) { animation-delay: 0.1s; }
.task-item:nth-child(4) { animation-delay: 0.15s; }
.task-item:nth-child(5) { animation-delay: 0.2s; }
.task-item:nth-child(6) { animation-delay: 0.25s; }
.task-item:nth-child(n+7) { animation-delay: 0.3s; }

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==================== 悬停发光效果 ==================== */

.btn-primary,
.task-btn.enhance {
    position: relative;
}

.btn-primary::before,
.task-btn.enhance::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    background: inherit;
    filter: blur(20px);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
}

.btn-primary:hover::before,
.task-btn.enhance:hover::before {
    opacity: 0.6;
}

/* ==================== 进度条动画增强 ==================== */

.progress-bar-enhanced {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill-enhanced {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #fb923c);
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-fill-enhanced::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ==================== Tooltip提示框 ==================== */

[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.95);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 10000;
}

[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ==================== 下拉菜单动画 ==================== */

.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: dropdownFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: scaleY(0.8) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scaleY(1) translateY(0);
    }
}

.dropdown-item {
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    font-size: 14px;
}

.dropdown-item:hover {
    background: rgba(249, 115, 22, 0.1);
    color: var(--primary);
    transform: translateX(4px);
}

.dropdown-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* ==================== 状态徽章动画 ==================== */

.status-badge-animated {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    animation: badgeFadeIn 0.3s ease-out;
}

@keyframes badgeFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.status-badge-animated.processing::before {
    content: '';
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* ==================== 图片/视频预览悬停放大 ==================== */

.preview-zoom {
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
}

.preview-zoom img,
.preview-zoom video {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-zoom:hover img,
.preview-zoom:hover video {
    transform: scale(1.1);
}

.preview-zoom::after {
    content: '\f00e'; /* magnifying glass icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    color: white;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.preview-zoom:hover::after {
    opacity: 0.8;
}

/* ==================== 空状态插图 ==================== */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.empty-state-icon {
    font-size: 80px;
    color: rgba(249, 115, 22, 0.2);
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
}

.empty-state-description {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ==================== 页面切换动画 ==================== */

.page-transition-enter {
    animation: pageEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.page-transition-exit {
    animation: pageExit 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageExit {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

/* ==================== 加载指示器 ==================== */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(249, 115, 22, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-dots {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== 响应式优化 ==================== */

@media (max-width: 768px) {
    .toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        margin: 0;
    }

    [data-tooltip]::before {
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* ==================== 性能优化 ==================== */

/* GPU加速 */
.task-item,
.toast,
.btn,
.task-btn,
.progress-fill-enhanced {
    will-change: transform;
    backface-visibility: hidden;
}

/* 完成动画后清除will-change */
.task-item:not(:hover),
.toast:not(.removing) {
    will-change: auto;
}
