/**
 * 灵翼交互系统 - LingYi Gesture Interaction Styles
 */

/* ============ 全局状态 ============ */
body.lingyi-active {
    cursor: none !important;
}

body.lingyi-active * {
    cursor: none !important;
}

/* ============ 光标样式 ============ */
.lingyi-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    pointer-events: none;
    z-index: 100000;
    opacity: 0;
    transition: opacity 0.3s ease;
    will-change: transform;
}

.lingyi-cursor.active {
    opacity: 1;
}

/* 光标点 */
.lingyi-cursor-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background: rgba(180, 180, 180, 0.85);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.15s ease;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.2);
}

/* 光标环（悬停时显示） */
.lingyi-cursor-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(100, 180, 255, 0);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    transition: all 0.2s ease;
    opacity: 0;
}

/* ============ 悬停状态 ============ */
.lingyi-cursor.hovering .lingyi-cursor-dot {
    background: rgba(100, 180, 255, 0.9);
    box-shadow: 0 0 12px rgba(100, 180, 255, 0.5);
}

.lingyi-cursor.hovering .lingyi-cursor-ring {
    border-color: rgba(100, 180, 255, 0.6);
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    animation: lingyi-ring-pulse 1.5s ease-in-out infinite;
}

@keyframes lingyi-ring-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.6;
    }
}

/* ============ 点击状态 ============ */
.lingyi-cursor.clicked .lingyi-cursor-dot {
    transform: translate(-50%, -50%) scale(0.7);
}

/* ============ 调节大小状态 ============ */
.lingyi-cursor.resizing .lingyi-cursor-dot {
    background: rgba(100, 180, 255, 0.9);
    box-shadow: 0 0 12px rgba(100, 180, 255, 0.5);
}

/* 方向箭头样式 */
.lingyi-cursor.resize-n .lingyi-cursor-dot,
.lingyi-cursor.resize-s .lingyi-cursor-dot {
    width: 6px;
    height: 16px;
    border-radius: 3px;
}

.lingyi-cursor.resize-e .lingyi-cursor-dot,
.lingyi-cursor.resize-w .lingyi-cursor-dot {
    width: 16px;
    height: 6px;
    border-radius: 3px;
}

.lingyi-cursor.resize-nw .lingyi-cursor-dot,
.lingyi-cursor.resize-se .lingyi-cursor-dot {
    width: 16px;
    height: 6px;
    border-radius: 3px;
    transform: translate(-50%, -50%) rotate(-45deg);
}

.lingyi-cursor.resize-ne .lingyi-cursor-dot,
.lingyi-cursor.resize-sw .lingyi-cursor-dot {
    width: 16px;
    height: 6px;
    border-radius: 3px;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* 活跃调节状态 */
.lingyi-cursor.active-resize .lingyi-cursor-dot {
    background: rgba(80, 160, 255, 1);
    box-shadow: 0 0 16px rgba(80, 160, 255, 0.7);
}

/* ============ 波纹效果 ============ */
.lingyi-ripple {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    width: 60px;
    height: 60px;
    transform: translate(-50%, -50%);
}

.lingyi-ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border: 2px solid rgba(100, 180, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.lingyi-ripple.active::before {
    animation: lingyi-ripple-expand 0.6s ease-out forwards;
}

/* 右键点击使用橙色波纹 */
.lingyi-ripple.right-click::before {
    border-color: rgba(255, 160, 80, 0.9);
}

@keyframes lingyi-ripple-expand {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 60px;
        height: 60px;
        opacity: 0;
    }
}

/* 三指闭合时的光标样式 */
.lingyi-cursor.three-finger .lingyi-cursor-dot {
    background: rgba(255, 160, 80, 0.9);
    box-shadow: 0 0 12px rgba(255, 160, 80, 0.5);
}

/* ============ 滚动模式光标样式 ============ */
.lingyi-cursor.scroll-mode .lingyi-cursor-dot {
    background: rgba(0, 255, 100, 0.9);
    box-shadow: 0 0 16px rgba(0, 255, 100, 0.6);
    width: 16px;
    height: 16px;
}

.lingyi-cursor.scroll-mode .lingyi-cursor-ring {
    border-color: rgba(0, 255, 100, 0.5);
    width: 32px;
    height: 32px;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    animation: scroll-ring-pulse 0.8s ease-in-out infinite;
}

@keyframes scroll-ring-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.4;
    }
}

/* 滚动方向指示器 */
.lingyi-cursor.scroll-mode::after {
    content: '⇕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: rgba(0, 255, 100, 0.9);
    pointer-events: none;
}

/* ============ 代码面板 - 黑客帝国风格 ============ */
.lingyi-code-panel {
    position: fixed;
    bottom: 80px;
    left: 16px;
    width: 420px;
    max-height: 450px;
    background: rgba(0, 10, 0, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 65, 0.3);
    box-shadow: 0 0 30px rgba(0, 255, 65, 0.2), inset 0 0 60px rgba(0, 20, 0, 0.5);
    z-index: 99998;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.lingyi-code-panel.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.lingyi-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(0, 255, 65, 0.1);
    border-bottom: 1px solid rgba(0, 255, 65, 0.3);
    color: #00ff41;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.lingyi-code-close {
    background: none;
    border: none;
    color: rgba(0, 255, 65, 0.6);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.lingyi-code-close:hover {
    color: #00ff41;
    text-shadow: 0 0 10px #00ff41;
}

.lingyi-code-content {
    padding: 12px;
    max-height: 390px;
    overflow-y: auto;
    overflow-x: hidden;
}

.lingyi-code-content pre,
#lingyi-code-data {
    margin: 0;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 10px;
    line-height: 1.5;
    color: #00ff41;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Matrix 风格元素 */
.matrix-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 8px;
    font-size: 11px;
    color: #00ff41;
}

.matrix-status {
    color: #666;
    transition: color 0.2s;
}

.matrix-status.active {
    color: #00ff41;
    text-shadow: 0 0 8px #00ff41;
    animation: matrix-blink 1s ease-in-out infinite;
}

@keyframes matrix-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.matrix-frame {
    color: #008f11;
    font-size: 10px;
}

.matrix-divider {
    color: #004400;
    font-size: 9px;
    letter-spacing: -1px;
    margin-bottom: 8px;
    overflow: hidden;
}

.matrix-line {
    padding: 2px 0;
    font-size: 10px;
    transition: opacity 0.3s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matrix-line.matrix-highlight {
    color: #00ffff;
    text-shadow: 0 0 6px #00ffff;
}

.matrix-type {
    color: #008f11;
    font-weight: bold;
}

.matrix-code {
    color: #00ff41;
}

.matrix-event {
    color: #ffff00;
    background: rgba(255, 255, 0, 0.05);
    padding: 2px 4px;
    border-radius: 2px;
}

.matrix-event-type {
    color: #ff6600;
    font-weight: bold;
}

/* 滚动条样式 */
.lingyi-code-content::-webkit-scrollbar {
    width: 4px;
}

.lingyi-code-content::-webkit-scrollbar-track {
    background: rgba(0, 255, 65, 0.05);
}

.lingyi-code-content::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 65, 0.3);
    border-radius: 2px;
}

.lingyi-code-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 65, 0.5);
}

/* ============ 摄像头预览 ============ */
.lingyi-camera-preview {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 280px;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 99998;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.lingyi-camera-preview.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.lingyi-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
}

.lingyi-preview-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.lingyi-preview-close:hover {
    color: #fff;
}

.lingyi-preview-content {
    padding: 8px;
}

#lingyi-preview-canvas {
    width: 100%;
    height: auto;
    border-radius: 6px;
    transform: scaleX(-1); /* 镜像显示 */
}

/* ============ 隐藏元素 ============ */
#lingyi-video,
#lingyi-canvas {
    display: none;
}

/* ============ 深色模式适配 ============ */
.dark-mode .lingyi-cursor-dot {
    background: rgba(200, 200, 200, 0.85);
}

.dark-mode .lingyi-cursor.hovering .lingyi-cursor-dot {
    background: rgba(100, 180, 255, 0.9);
}

/* ============ 拖拽提示 ============ */
.lingyi-drag-hint {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 13px;
    z-index: 99997;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.lingyi-drag-hint.visible {
    opacity: 1;
}

.lingyi-drag-hint::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    background: radial-gradient(circle, rgba(100, 180, 255, 1) 0%, rgba(100, 180, 255, 0) 70%);
    border-radius: 50%;
    vertical-align: middle;
    animation: lingyi-hint-pulse 1s ease-in-out infinite;
}

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

/* ============ 设置面板中的灵翼选项样式 ============ */
.lingyi-options-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
}

.lingyi-option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.lingyi-option-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.lingyi-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.lingyi-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9e9e9e;
}

.lingyi-status-dot.active {
    background: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

/* ============ 调试模式下窗口边框高亮 ============ */
body.lingyi-debug .window {
    outline: 1px dashed rgba(100, 180, 255, 0.3);
}

body.lingyi-debug .window:hover {
    outline-color: rgba(100, 180, 255, 0.6);
}

/* ============ 握拳拖动窗口样式 ============ */
/* 握拳拖动时的光标样式 */
.lingyi-cursor.fist-drag .lingyi-cursor-dot {
    background: rgba(255, 100, 100, 0.9);
    box-shadow: 0 0 16px rgba(255, 100, 100, 0.7);
    width: 18px;
    height: 18px;
    border-radius: 4px;
}

.lingyi-cursor.fist-drag .lingyi-cursor-ring {
    border-color: rgba(255, 100, 100, 0.6);
    width: 36px;
    height: 36px;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    animation: fist-ring-pulse 0.5s ease-in-out infinite;
}

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

/* 握拳拖动波纹效果 */
.lingyi-ripple.fist-drag::before {
    border-color: rgba(255, 100, 100, 0.9);
    border-width: 3px;
}

/* 被拖动的窗口样式 */
.window.fist-dragging {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(255, 100, 100, 0.5);
    transform: scale(1.01);
    z-index: 100001 !important;
}

.window.fist-dragging::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px dashed rgba(255, 100, 100, 0.4);
    border-radius: inherit;
    pointer-events: none;
    animation: fist-drag-border 1s linear infinite;
}

@keyframes fist-drag-border {
    0% {
        border-color: rgba(255, 100, 100, 0.4);
    }
    50% {
        border-color: rgba(255, 100, 100, 0.8);
    }
    100% {
        border-color: rgba(255, 100, 100, 0.4);
    }
}
