/**
 * Enhanced Voice Input Styles
 * 微信风格的语音输入交互
 */

/* 语音按钮增强状态 */
.voice-button {
    position: relative;
    transition: all 0.2s ease;
}

/* 文字模式：小按钮 */
.voice-button.text-mode {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

/* 语音模式：大按钮，占据剩余空间 */
.voice-button.voice-mode {
    flex: 1;
    height: 56px !important;
    min-height: 56px !important;
    border-radius: 28px;
    background-color: #f5f5f5;
    border: 2px solid #e0e0e0;
}

.voice-button.voice-mode .hold-to-talk {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 100%;
}

.voice-button.voice-mode .hold-text {
    font-size: 16px;
    font-weight: 500;
    color: #666;
}

/* 键盘切换按钮（语音模式下显示） */
.keyboard-switch-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    border-radius: 4px;
    background-color: var(--background-light);
    color: var(--text-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.keyboard-switch-button:hover {
    background-color: #e8e8e8;
}

.keyboard-switch-button:active {
    transform: scale(0.95);
}

.voice-button.pressed {
    transform: scale(0.95);
    background-color: var(--primary-dark);
    color: white;
}

.voice-button.recording {
    background-color: var(--accent-red);
    color: white;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 录音遮罩层 - 灰色渐变 */
.voice-recording-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(240, 240, 240, 0.3) 35%, 
        rgba(220, 220, 220, 0.7) 55%, 
        rgba(200, 200, 200, 0.9) 75%, 
        rgba(180, 180, 180, 0.95) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding-bottom: 80px;
}

.voice-recording-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 录音内容区域 */
.recording-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding-bottom: 40px;
}

/* 波纹动画容器 */
.recording-wave-container {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    filter: drop-shadow(0 0 20px rgba(150, 150, 150, 0.3));
}

/* 中心圆点 */
.recording-center-dot {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: white;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px rgba(180, 180, 180, 0.5), 
                0 0 50px rgba(200, 200, 200, 0.3),
                0 4px 16px rgba(0, 0, 0, 0.15);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 25px rgba(180, 180, 180, 0.5), 
                    0 0 50px rgba(200, 200, 200, 0.3),
                    0 4px 16px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 0 35px rgba(160, 160, 160, 0.7), 
                    0 0 70px rgba(180, 180, 180, 0.5),
                    0 4px 20px rgba(0, 0, 0, 0.2);
    }
}

/* 麦克风图标 */
.recording-mic-icon {
    width: 35px;
    height: 35px;
    color: #888;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* 波纹圆环 - 灰白色调 */
.recording-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 3px solid rgba(160, 160, 160, 0.6);
    box-shadow: 0 0 15px rgba(180, 180, 180, 0.5),
                inset 0 0 15px rgba(200, 200, 200, 0.3);
    animation: ripple-enhanced 2s ease-out infinite;
}

.recording-ripple:nth-child(2) {
    animation-delay: 0.5s;
}

.recording-ripple:nth-child(3) {
    animation-delay: 1s;
}

.recording-ripple:nth-child(4) {
    animation-delay: 1.5s;
}

@keyframes ripple-enhanced {
    0% {
        width: 70px;
        height: 70px;
        opacity: 1;
        border-width: 3px;
        box-shadow: 0 0 15px rgba(180, 180, 180, 0.5),
                    inset 0 0 15px rgba(200, 200, 200, 0.3);
    }
    50% {
        opacity: 0.6;
        border-width: 2px;
        box-shadow: 0 0 25px rgba(160, 160, 160, 0.7),
                    inset 0 0 25px rgba(180, 180, 180, 0.5);
    }
    100% {
        width: 160px;
        height: 160px;
        opacity: 0;
        border-width: 1px;
        box-shadow: 0 0 30px rgba(200, 200, 200, 0.3),
                    inset 0 0 30px rgba(220, 220, 220, 0.2);
    }
}

/* 录音时长显示 */
.recording-duration {
    font-size: 28px;
    font-weight: 300;
    color: #333;
    margin-bottom: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 1px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 松手发送提示 */
.release-hint {
    font-size: 15px;
    color: #666;
    font-weight: 400;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* 切换提示Toast */
.switch-hint-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 16px 32px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.switch-hint-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* 取消Toast */
.cancel-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 16px 32px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    z-index: 9998;
    opacity: 0;
    transition: all 0.3s ease;
}

.cancel-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 输入区域布局优化 */
.input-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 当语音模式时，输入区域只显示语音按钮 */
.input-area.voice-only {
    justify-content: center;
}

/* 文字输入容器动画 */
.text-input-container {
    animation: fadeIn 0.3s ease;
}

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

/* 触摸反馈优化 */
@media (hover: none) and (pointer: coarse) {
    .voice-button {
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
        touch-action: none;
    }
}


/* 移动端优化 */
@media (max-width: 768px) {
    .voice-button.voice-mode {
        height: 52px !important;
        min-height: 52px !important;
        border-radius: 26px;
    }
    
    .voice-button.voice-mode .hold-text {
        font-size: 15px;
    }
    
    .voice-button.text-mode,
    .keyboard-switch-button {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .voice-recording-overlay {
        padding-bottom: 60px;
    }
    
    .recording-wave-container {
        width: 140px;
        height: 140px;
        margin-bottom: 25px;
        filter: drop-shadow(0 0 15px rgba(150, 150, 150, 0.3));
    }
    
    .recording-center-dot {
        width: 60px;
        height: 60px;
        box-shadow: 0 0 20px rgba(180, 180, 180, 0.5), 
                    0 0 40px rgba(200, 200, 200, 0.3),
                    0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    @keyframes pulse-glow {
        0%, 100% {
            box-shadow: 0 0 20px rgba(180, 180, 180, 0.5), 
                        0 0 40px rgba(200, 200, 200, 0.3),
                        0 4px 12px rgba(0, 0, 0, 0.15);
        }
        50% {
            box-shadow: 0 0 30px rgba(160, 160, 160, 0.7), 
                        0 0 60px rgba(180, 180, 180, 0.5),
                        0 4px 16px rgba(0, 0, 0, 0.2);
        }
    }
    
    .recording-mic-icon {
        width: 30px;
        height: 30px;
    }
    
    @keyframes ripple-enhanced {
        0% {
            width: 60px;
            height: 60px;
            opacity: 1;
            border-width: 3px;
            box-shadow: 0 0 15px rgba(180, 180, 180, 0.5),
                        inset 0 0 15px rgba(200, 200, 200, 0.3);
        }
        50% {
            opacity: 0.6;
            border-width: 2px;
            box-shadow: 0 0 25px rgba(160, 160, 160, 0.7),
                        inset 0 0 25px rgba(180, 180, 180, 0.5);
        }
        100% {
            width: 140px;
            height: 140px;
            opacity: 0;
            border-width: 1px;
            box-shadow: 0 0 30px rgba(200, 200, 200, 0.3),
                        inset 0 0 30px rgba(220, 220, 220, 0.2);
        }
    }
    
    .recording-duration {
        font-size: 24px;
        margin-bottom: 12px;
    }
    
    .release-hint {
        font-size: 14px;
    }
    
    .switch-hint-toast,
    .cancel-toast {
        font-size: 14px;
        padding: 14px 28px;
    }
}

/* PC端优化 */
@media (min-width: 769px) {
    .voice-button.voice-mode {
        height: 60px !important;
        min-height: 60px !important;
        border-radius: 30px;
    }
    
    .voice-button.voice-mode .hold-text {
        font-size: 17px;
    }
    
    .voice-button.text-mode,
    .keyboard-switch-button {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }
    
    .voice-button.voice-mode:hover {
        background-color: #eeeeee;
        border-color: #d0d0d0;
    }
    
    .voice-button.text-mode:hover,
    .keyboard-switch-button:hover {
        background-color: #e8e8e8;
    }
    
    .voice-recording-overlay {
        padding-bottom: 100px;
    }
    
    .recording-wave-container {
        width: 180px;
        height: 180px;
        margin-bottom: 35px;
        filter: drop-shadow(0 0 25px rgba(150, 150, 150, 0.4));
    }
    
    .recording-center-dot {
        width: 80px;
        height: 80px;
        box-shadow: 0 0 30px rgba(180, 180, 180, 0.6), 
                    0 0 60px rgba(200, 200, 200, 0.4),
                    0 4px 20px rgba(0, 0, 0, 0.2);
    }
    
    @keyframes pulse-glow {
        0%, 100% {
            box-shadow: 0 0 30px rgba(180, 180, 180, 0.6), 
                        0 0 60px rgba(200, 200, 200, 0.4),
                        0 4px 20px rgba(0, 0, 0, 0.2);
        }
        50% {
            box-shadow: 0 0 40px rgba(160, 160, 160, 0.8), 
                        0 0 80px rgba(180, 180, 180, 0.6),
                        0 4px 24px rgba(0, 0, 0, 0.25);
        }
    }
    
    .recording-mic-icon {
        width: 40px;
        height: 40px;
    }
    
    @keyframes ripple-enhanced {
        0% {
            width: 80px;
            height: 80px;
            opacity: 1;
            border-width: 3px;
            box-shadow: 0 0 15px rgba(180, 180, 180, 0.5),
                        inset 0 0 15px rgba(200, 200, 200, 0.3);
        }
        50% {
            opacity: 0.6;
            border-width: 2px;
            box-shadow: 0 0 25px rgba(160, 160, 160, 0.7),
                        inset 0 0 25px rgba(180, 180, 180, 0.5);
        }
        100% {
            width: 180px;
            height: 180px;
            opacity: 0;
            border-width: 1px;
            box-shadow: 0 0 30px rgba(200, 200, 200, 0.3),
                        inset 0 0 30px rgba(220, 220, 220, 0.2);
        }
    }
    
    .recording-duration {
        font-size: 32px;
        margin-bottom: 18px;
    }
    
    .release-hint {
        font-size: 16px;
    }
}
