/* 动画效果 - 流畅过渡和细腻动效 */

/* 基础动画关键帧 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

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

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translateY(0);
    }
    40%, 43% {
        transform: translateY(-8px);
    }
    70% {
        transform: translateY(-4px);
    }
    90% {
        transform: translateY(-2px);
    }
}

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

/* 页面加载动画 */
.page-enter {
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.page-exit {
    animation: fadeOut var(--duration-normal) var(--ease-out);
}

/* 组件动画类 */
.animate-fade-in {
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.animate-slide-in-left {
    animation: slideInFromLeft var(--duration-normal) var(--ease-out);
}

.animate-slide-in-right {
    animation: slideInFromRight var(--duration-normal) var(--ease-out);
}

.animate-pulse {
    animation: pulse 1.5s infinite;
}

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

.animate-bounce {
    animation: bounce 1s infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

/* 主题切换动画 */
[data-theme="light"] {
    transition: all var(--duration-normal) var(--ease-in-out);
}

[data-theme="dark"] {
    transition: all var(--duration-normal) var(--ease-in-out);
}

/* 按钮点击动画 */
.btn-click {
    animation: bounce 0.3s ease-in-out;
}

/* 加载状态动画 */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::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: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* 错误状态动画 */
.error-shake {
    animation: shake 0.5s ease-in-out;
}

/* 成功状态动画 */
.success-bounce {
    animation: bounce 0.6s ease-in-out;
}

/* 悬浮效果 */
.hover-lift {
    transition: transform var(--duration-fast) var(--ease-out);
}

.hover-lift:hover {
    transform: translateY(-2px);
}

/* 缩放效果 */
.hover-scale {
    transition: transform var(--duration-fast) var(--ease-out);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* 渐变背景动画 */
.gradient-animation {
    background: linear-gradient(-45deg, #007AFF, #5AC8FA, #34C759, #FF9500);
    background-size: 400% 400%;
    animation: gradient-shift 15s ease infinite;
}

@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 连接状态动画 */
.status-connecting .status-indicator {
    animation: pulse 1.5s infinite;
}

/* 记录项动画 */
.record-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn var(--duration-normal) var(--ease-out) forwards;
}

.record-item:nth-child(1) { animation-delay: 0.1s; }
.record-item:nth-child(2) { animation-delay: 0.2s; }
.record-item:nth-child(3) { animation-delay: 0.3s; }
.record-item:nth-child(4) { animation-delay: 0.4s; }
.record-item:nth-child(5) { animation-delay: 0.5s; }
.record-item:nth-child(n+6) { animation-delay: 0.6s; }

/* 按钮点击波纹效果 */
.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

/* 门锁图标旋转动画 */
.lock-icon {
    transition: transform var(--duration-normal) var(--ease-out);
}

.lock-icon.unlocking {
    animation: lockRotate 0.8s var(--ease-out);
}

@keyframes lockRotate {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
    100% { transform: rotate(0deg); }
}

/* 主题切换图标动画 */
.theme-icon {
    transition: transform var(--duration-normal) var(--ease-out);
}

.theme-toggle:hover .theme-icon {
    transform: rotate(180deg);
}

/* 连接状态指示器呼吸动画 */
@keyframes breathe {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.status-connecting .status-indicator {
    animation: breathe 2s ease-in-out infinite;
}

/* 输入框聚焦动画 */
.input:focus {
    animation: inputFocus 0.3s var(--ease-out);
}

@keyframes inputFocus {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.3);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    }
}

/* 卡片悬浮动画 */
.card {
    transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
    animation: cardHover 0.3s var(--ease-out) forwards;
}

@keyframes cardHover {
    0% {
        transform: translateY(0);
        box-shadow: var(--shadow-small);
    }
    100% {
        transform: translateY(-4px);
        box-shadow: var(--shadow-large);
    }
}

/* 提示消息滑入动画 */
.toast {
    animation: toastSlideIn 0.3s var(--ease-out);
}

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

/* 加载状态脉冲动画 */
.loading-pulse {
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 页面切换动画 */
.page-transition-enter {
    animation: pageEnter 0.5s var(--ease-out);
}

.page-transition-exit {
    animation: pageExit 0.3s var(--ease-out);
}

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

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

/* 模态框动画 */
.modal-enter {
    animation: modalFadeIn var(--duration-normal) var(--ease-out);
}

.modal-exit {
    animation: modalFadeOut var(--duration-normal) var(--ease-out);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
}

/* 胁迫报警紧急状态脉冲动画 */
@keyframes criticalPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 59, 48, 0.5);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(255, 59, 48, 0.8);
    }
}

/* 减少动画的媒体查询 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
