/**
 * 按住说话交互组件（VoiceHoldInteraction）
 * 波纹录音态、拖动取消/发送区域高亮
 */

/* ── 按住按钮 ── */
.vhi-hold-btn {
    position: relative;
    overflow: visible;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.vhi-hold-btn[hidden] {
    display: none !important;
}

.vhi-hold-btn:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vhi-hold-btn__label {
    position: relative;
    z-index: 2;
}

.vhi-hold-btn__ripples {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}

.vhi-hold-btn.is-vhi-recording .vhi-hold-btn__ripples {
    display: block;
}

.vhi-hold-btn__ripple {
    position: absolute;
    left: 0;
    top: 0;
    width: 120px;
    height: 120px;
    margin-left: -60px;
    margin-top: -60px;
    border-radius: 50%;
    border: 2px solid rgba(25, 195, 125, 0.75);
    background: rgba(25, 195, 125, 0.15);
    box-shadow: 0 0 12px rgba(25, 195, 125, 0.25);
    animation: vhi-ripple-expand 1.8s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
    opacity: 0;
    will-change: transform, opacity;
}

.vhi-hold-btn__ripple:nth-child(2) {
    animation-delay: 0.6s;
}

.vhi-hold-btn__ripple:nth-child(3) {
    animation-delay: 1.2s;
}

.vhi-hold-btn.is-vhi-recording {
    background: rgba(25, 195, 125, 0.12);
    color: var(--c-success);
    box-shadow: inset 0 0 0 1px rgba(25, 195, 125, 0.25);
    animation: vhi-hold-glow 1.6s ease-in-out infinite;
}

.vhi-hold-btn.is-vhi-zone-cancel {
    background: rgba(248, 81, 73, 0.14);
    color: #feb2b2;
    animation: none;
    box-shadow: inset 0 0 0 1px rgba(248, 81, 73, 0.35);
}

.vhi-hold-btn.is-vhi-zone-cancel .vhi-hold-btn__ripple {
    border-color: rgba(248, 81, 73, 0.55);
    background: rgba(248, 81, 73, 0.08);
}

.vhi-hold-btn.is-vhi-zone-send {
    background: rgba(25, 195, 125, 0.18);
    color: #c6f6d5;
    animation: none;
    box-shadow: inset 0 0 0 1px rgba(25, 195, 125, 0.5);
}

@keyframes vhi-ripple-expand {
    0% {
        transform: scale(0.35);
        opacity: 0.85;
    }
    60% {
        opacity: 0.35;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

@keyframes vhi-hold-glow {
    0%, 100% {
        box-shadow: inset 0 0 0 1px rgba(25, 195, 125, 0.2);
    }
    50% {
        box-shadow: inset 0 0 0 1px rgba(25, 195, 125, 0.45), 0 0 18px rgba(25, 195, 125, 0.12);
    }
}

/* ── 录音遮罩层 ── */
.vhi-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    border-radius: inherit;
}

.vhi-overlay[hidden] {
    display: none !important;
}

.vhi-overlay__backdrop {
    position: absolute;
    inset: -120px -24px 0;
    background: linear-gradient(
        180deg,
        rgba(52, 53, 65, 0.92) 0%,
        rgba(52, 53, 65, 0.55) 45%,
        transparent 100%
    );
    border-radius: 14px 14px 0 0;
}

.vhi-overlay__hint {
    position: absolute;
    top: -88px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(64, 65, 79, 0.95);
    border: 1px solid var(--c-border);
    color: #c5c5d2;
    font-size: 13px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.vhi-overlay.is-vhi-zone-cancel .vhi-overlay__hint {
    color: #feb2b2;
    border-color: rgba(248, 81, 73, 0.5);
    background: rgba(248, 81, 73, 0.12);
}

.vhi-overlay.is-vhi-zone-send .vhi-overlay__hint {
    color: var(--c-success);
    border-color: rgba(25, 195, 125, 0.5);
    background: rgba(25, 195, 125, 0.12);
}

/* ── 取消区域（左上角） ── */
.vhi-zone--cancel {
    position: absolute;
    top: -108px;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid var(--c-border);
    background: rgba(64, 65, 79, 0.9);
    color: var(--c-text);
    pointer-events: auto;
    transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.vhi-zone--cancel-icon {
    font-size: 22px;
    line-height: 1;
    font-weight: 300;
}

.vhi-zone--cancel-label {
    font-size: 11px;
    line-height: 1;
}

.vhi-zone--cancel.is-vhi-active,
.vhi-overlay.is-vhi-zone-cancel .vhi-zone--cancel {
    border-color: var(--c-danger);
    background: rgba(248, 81, 73, 0.22);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(248, 81, 73, 0.18);
    transform: scale(1.06);
}

/* ── 发送目标高亮（外部按钮） ── */
.vhi-send-target.is-vhi-active {
    background: var(--c-accent) !important;
    box-shadow: 0 0 0 4px rgba(25, 195, 125, 0.35);
    transform: scale(1.08);
}

.vhi-send-target.is-vhi-active:hover:not(:disabled) {
    background: var(--c-accent-hover) !important;
}

/* 录音时允许遮罩层溢出输入区域 */
.is-vhi-recording-active {
    overflow: visible !important;
    position: relative;
    z-index: 30;
}

body.is-vhi-recording-active {
    overflow: hidden;
    touch-action: none;
}

@media (max-width: 768px) {
    body.is-vhi-recording-active .input-area {
        z-index: 200;
    }

    .vhi-overlay {
        position: fixed;
        inset: 0;
        z-index: 190;
        border-radius: 0;
    }

    .vhi-overlay__backdrop {
        inset: 0;
        border-radius: 0;
        background: rgba(32, 33, 35, 0.55);
    }

    .vhi-overlay__hint {
        top: auto;
        bottom: calc(148px + env(safe-area-inset-bottom, 0px) + 56px);
        left: 50%;
        transform: translateX(-50%);
        font-size: 13px;
        z-index: 2;
    }

    .vhi-zone--cancel {
        position: fixed;
        top: auto;
        left: 24px;
        bottom: calc(148px + env(safe-area-inset-bottom, 0px) + 72px);
        width: 68px;
        height: 68px;
        z-index: 2;
    }

    .vhi-zone--cancel-icon {
        font-size: 22px;
    }

    .vhi-zone--cancel-label {
        font-size: 12px;
    }
}
