/* ========================================
   智能体表单增强样式 - 微交互和动画
   ======================================== */

/* 输入框聚焦时的发光效果 */
@keyframes inputGlow {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1),
                    0 1px 2px 0 rgba(0, 0, 0, 0.05);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15),
                    0 2px 4px 0 rgba(0, 0, 0, 0.08);
    }
}

.agent-input-field:focus {
    animation: inputGlow 2s ease-in-out infinite;
}

/* 工具chip的动画 */
@keyframes chipSelect {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.agent-tool-chip.selected {
    animation: chipSelect 0.3s ease-out;
}

/* 头像上传区域的hover效果 */
@keyframes avatarPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.agent-avatar-preview:hover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
    border-radius: 1.25rem;
    animation: avatarPulse 2s ease-in-out infinite;
}

/* 按钮点击涟漪效果 */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.agent-btn {
    position: relative;
    overflow: hidden;
}

.agent-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    transition: transform 0.5s, opacity 1s;
}

.agent-btn:active::after {
    transform: translate(-50%, -50%) scale(40);
    opacity: 0;
    transition: transform 0s, opacity 0.5s;
}

/* 表单分区标题的渐入效果 */
@keyframes sectionFadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.agent-form-section {
    animation: sectionFadeIn 0.5s ease-out;
}

.agent-form-section:nth-child(1) { animation-delay: 0.1s; }
.agent-form-section:nth-child(2) { animation-delay: 0.2s; }
.agent-form-section:nth-child(3) { animation-delay: 0.3s; }
.agent-form-section:nth-child(4) { animation-delay: 0.4s; }

/* Toggle开关的平滑动画 */
.agent-toggle-slider {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.agent-toggle-slider:before {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.agent-toggle-switch input:checked + .agent-toggle-slider:before {
    box-shadow: 0 3px 6px rgba(16, 185, 129, 0.3), 0 2px 4px rgba(16, 185, 129, 0.2);
}

/* 头部标题的渐变闪烁 */
@keyframes titleShine {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

.agent-modal-title::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: titleShine 3s ease-in-out infinite;
}

/* 输入框的占位符动画 */
@keyframes placeholderShift {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.agent-input-field:focus::placeholder,
.agent-textarea-field:focus::placeholder {
    animation: placeholderShift 2s ease-in-out infinite;
}

/* 验证按钮的加载动画 */
@keyframes validatePulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

#btn-validate-class:disabled {
    animation: validatePulse 1s ease-in-out infinite;
}

/* 选择器的选中效果 */
.agent-input-field[readonly] {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    cursor: not-allowed;
}

/* 上传按钮的hover效果 */
@keyframes uploadFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

.agent-upload-btn:hover {
    animation: uploadFloat 0.6s ease-in-out infinite;
}

/* 表单成功提交的反馈动画 */
@keyframes successPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.agent-btn-primary.success {
    animation: successPulse 1s ease-out;
}

/* 表单错误时的震动效果 */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.agent-input-field.error {
    border-color: #ef4444;
    animation: shake 0.5s ease-in-out;
}

/* 工具chip的tooltip效果 */
.agent-tool-chip {
    position: relative;
}

.agent-tool-chip::before {
    content: attr(data-description);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0);
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.95);
    color: white;
    font-size: 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.agent-tool-chip:hover::before {
    transform: translateX(-50%) scale(1);
    opacity: 1;
}

/* 渐变背景的动态效果 */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.agent-modal-header {
    background-size: 200% 200%;
    animation: gradientFlow 8s ease infinite;
}

/* 提交按钮的进度加载效果 */
@keyframes buttonProgress {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 40px 0;
    }
}

.agent-btn-primary.loading {
    background: linear-gradient(
        135deg,
        #6366f1 25%,
        #7c3aed 25%,
        #7c3aed 50%,
        #6366f1 50%,
        #6366f1 75%,
        #7c3aed 75%,
        #7c3aed
    );
    background-size: 40px 40px;
    animation: buttonProgress 1s linear infinite;
}

/* 输入框标签的浮动效果 */
@keyframes labelFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

.agent-input-field:focus + .agent-input-label {
    animation: labelFloat 2s ease-in-out infinite;
}

/* 图标的旋转效果（用于刷新、加载等） */
@keyframes iconSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.icon-spin {
    animation: iconSpin 1s linear infinite;
}

/* 成功消息的淡入淡出 */
@keyframes messageFadeInOut {
    0%, 100% {
        opacity: 0;
        transform: translateY(-10px);
    }
    10%, 90% {
        opacity: 1;
        transform: translateY(0);
    }
}

.success-message {
    animation: messageFadeInOut 3s ease-in-out;
}

/* 响应式优化 */
@media (max-width: 768px) {
    @keyframes sectionFadeIn {
        from {
            opacity: 0;
            transform: translateY(-5px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* 移动端减少动画，提升性能 */
    .agent-input-field:focus {
        animation: none;
    }
    
    .agent-modal-header {
        animation: none;
    }
}

/* 暗色主题优化（未来扩展） */
@media (prefers-color-scheme: dark) {
    .agent-modal-content-wrapper {
        background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    }
    
    .agent-modal-header {
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
    }
    
    .agent-input-field {
        background: rgba(30, 41, 59, 0.5);
        border-color: rgba(71, 85, 105, 0.5);
        color: #f1f5f9;
    }
    
    .agent-input-field:focus {
        background: rgba(30, 41, 59, 0.8);
    }
}

/* 可访问性增强 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

