/**
 * 狡兔星 - 语音助手UI样式 v4.0
 * 对标豆包App丝滑体验 - 浅紫马卡龙风格
 */

/* ==================== 悬浮语音按钮 ==================== */
.voice-fab {
    position: fixed;
    bottom: 120px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #B8A9E8 0%, #9B8ACF 100%);
    box-shadow: 0 4px 20px rgba(184, 169, 232, 0.4);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease,
                background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

/* 背景层 */
.voice-fab__bg {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0;
}

/* 内层图标 */
.voice-fab__inner {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 图标 */
.voice-fab__icon {
    font-size: 24px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
    transition: transform 0.2s ease;
}

/* 状态文字 */
.voice-fab__status {
    position: absolute;
    bottom: -22px;
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    text-align: center;
    width: 80px;
    left: 50%;
    transform: translateX(-50%);
}

/* 按下态 */
.voice-fab:active,
.voice-fab.pressed {
    transform: scale(0.92);
    box-shadow: 0 2px 10px rgba(184, 169, 232, 0.3);
}

.voice-fab.pressed .voice-fab__icon {
    transform: scale(0.9);
}

/* ==================== 状态：待机 ==================== */
.voice-fab.idle {
    background: linear-gradient(135deg, #6B6B8D 0%, #5A5A7A 100%);
    box-shadow: 0 4px 15px rgba(107, 107, 141, 0.3);
}

/* ==================== 状态：录音中 ==================== */
.voice-fab.recording,
.voice-fab.listening {
    background: linear-gradient(135deg, #FF7B7B 0%, #FF6B6B 100%);
    animation: fab-pulse-recording 1.5s ease-in-out infinite;
}

@keyframes fab-pulse-recording {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(255, 107, 107, 0.6), 0 0 0 12px rgba(255, 107, 107, 0.15);
    }
}

/* ==================== 状态：思考中 ==================== */
.voice-fab.thinking {
    background: linear-gradient(135deg, #FFD86B 0%, #F4C430 100%);
    animation: fab-pulse-thinking 1s ease-in-out infinite;
}

@keyframes fab-pulse-thinking {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==================== 状态：播报中 ==================== */
.voice-fab.speaking {
    background: linear-gradient(135deg, #B8A9E8 0%, #9B8ACF 100%);
    animation: fab-pulse-speaking 2s ease-in-out infinite;
}

@keyframes fab-pulse-speaking {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(184, 169, 232, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(184, 169, 232, 0.6), 0 0 0 10px rgba(184, 169, 232, 0.1);
    }
}

/* ==================== 状态：连接中 ==================== */
.voice-fab.connecting {
    background: linear-gradient(135deg, #D4C9F0 0%, #B8A9E8 100%);
    animation: fab-spin 1s linear infinite;
}

@keyframes fab-spin {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.05) rotate(90deg); }
    50% { transform: scale(1) rotate(180deg); }
    75% { transform: scale(1.05) rotate(270deg); }
    100% { transform: scale(1) rotate(360deg); }
}

/* ==================== 状态：重连中 ==================== */
.voice-fab.reconnecting {
    background: linear-gradient(135deg, #FFD86B 0%, #F4C430 100%);
    animation: fab-pulse-reconnect 2s ease-in-out infinite;
}

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

/* ==================== 状态：拒绝/错误 ==================== */
.voice-fab.error {
    background: linear-gradient(135deg, #8B8B8B 0%, #6B6B6B 100%);
    cursor: not-allowed;
}

.voice-fab.error:hover {
    transform: none;
}

/* ==================== 波纹动画 ==================== */
.voice-fab__ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(184, 169, 232, 0.5);
    opacity: 0;
    transform: scale(1);
    pointer-events: none;
}

.voice-fab.recording .voice-fab__ripple {
    animation: ripple 1.5s ease-out infinite;
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* ==================== 波形条 ==================== */
.voice-fab__wave {
    position: absolute;
    top: -28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 30px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.voice-fab__wave.active {
    opacity: 1;
}

.voice-fab__wave-bar {
    width: 3px;
    height: 10px;
    background: linear-gradient(to top, #FF6B6B, #FFB6C1);
    border-radius: 2px;
    transition: height 0.08s ease;
}

/* ==================== Safari提示 ==================== */
.voice-fab__safari-hint {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1001;
}

.voice-fab__safari-hint.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.voice-fab__safari-hint-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 20px;
    font-size: 13px;
    backdrop-filter: blur(10px);
}

.voice-fab__safari-hint-inner .icon {
    font-size: 16px;
}

/* ==================== 打断按钮 ==================== */
.voice-fab__interrupt {
    position: fixed;
    bottom: 130px;
    right: 90px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A5A 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    z-index: 9998;
}

.voice-fab__interrupt.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* ==================== 状态提示条 ==================== */
.voice-status-tips {
    position: fixed;
    top: env(safe-area-inset-top, 20px);
    left: 50%;
    transform: translateX(-50%) translateY(-50px);
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

.voice-status-tips.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.voice-status-tips.listening {
    background: rgba(255, 107, 107, 0.9);
}

.voice-status-tips.thinking {
    background: rgba(255, 217, 61, 0.95);
    color: #333;
}

.voice-status-tips.speaking {
    background: rgba(184, 169, 232, 0.9);
}

/* ==================== 响应式适配 ==================== */
@media (max-width: 375px) {
    .voice-fab {
        bottom: 100px;
        right: 15px;
        width: 52px;
        height: 52px;
    }

    .voice-fab__icon {
        font-size: 22px;
    }

    .voice-fab__status {
        font-size: 10px;
        bottom: -20px;
    }

    .voice-fab__interrupt {
        bottom: 110px;
        right: 80px;
    }
}

/* iPhone刘海屏适配 */
@supports (padding-top: env(safe-area-inset-top)) {
    .voice-fab {
        bottom: calc(120px + env(safe-area-inset-bottom));
    }
}

/* ==================== 深色模式支持 ==================== */
@media (prefers-color-scheme: dark) {
    .voice-fab__status {
        color: #aaa;
        text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    }
}
