/**
 * Call App - 视频/语音通话样式
 * 基于用户提供的高保真设计
 */

/* ================= 通话界面容器 ================= */
.call-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none !important; /* 🔧 默认隐藏 */
    flex-direction: column;
    z-index: 100;
    color: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    background: #000;
}

.call-view.active {
    display: flex !important; /* 🔧 激活时显示 */
    opacity: 1;
    pointer-events: auto;
}

/* ================= 背景壁纸 ================= */
#call-view .bg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

#call-view .wallpaper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #222;
    object-fit: cover;
    transition: filter 0.5s, transform 0.5s;
    z-index: 0;
}

#call-view .bg-blur {
    filter: blur(30px) brightness(0.6);
    transform: scale(1.1);
}

#call-view .bg-clear {
    filter: blur(0) brightness(1);
    transform: scale(1);
}

/* ================= 顶部区域 ================= */
#call-view .call-top-area {
    position: absolute;
    top: 12vh;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    transition: 0.3s;
}

#call-view .call-top-area.video-mode {
    top: 7vh;
}

/* ================= 头像容器 ================= */
#call-view .avatar-container {
    position: relative;
    width: 130px;
    height: 130px;
    margin-bottom: 15px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transition: 0.3s;
}

#call-view .avatar-container.hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
    height: 0;
    margin: 0;
}

#call-view .avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 20px;
    position: relative;
    z-index: 2;
}

/* ================= AI 说话时的光晕波纹 ================= */
#call-view .ripple {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 20px;
    border: 3px solid #34C759;
    animation: rippleEffect 1.5s infinite ease-out;
    opacity: 0;
    display: none;
    z-index: 1;
}

#call-view .is-speaking .ripple {
    display: block;
    opacity: 1;
}

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

/* ================= 通话信息 ================= */
#call-view .call-name {
    font-size: 28px;
    font-weight: 500;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

#call-view .call-status {
    font-size: 14px;
    opacity: 0.8;
    margin-top: 5px;
    text-shadow: 0 1px 5px rgba(0,0,0,0.5);
}

#call-view .call-timer {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: none;
    margin-top: 5px;
}

#call-view.connected .call-timer {
    display: block;
}

#call-view.connected .call-status {
    display: none;
}

/* ================= 声波可视化 ================= */
#call-view .audio-visualizer {
    display: none;
    align-items: flex-end;
    gap: 4px;
    height: 18px;
    margin-top: 8px;
}

#call-view .video-speaking .audio-visualizer {
    display: flex;
}

#call-view .audio-visualizer .bar {
    width: 4px;
    background: #34C759;
    border-radius: 2px;
    animation: bounce 0.4s infinite alternate ease-in-out;
    animation-play-state: paused; /* 默认静止 */
}

/* 激活时跳动 */
#call-view .active-wave .bar {
    animation-play-state: running !important;
}

#call-view .audio-visualizer .bar:nth-child(1) {
    height: 60%;
    animation-delay: 0s;
}

#call-view .audio-visualizer .bar:nth-child(2) {
    height: 100%;
    animation-delay: 0.2s;
}

#call-view .audio-visualizer .bar:nth-child(3) {
    height: 40%;
    animation-delay: 0.4s;
}

#call-view .audio-visualizer .bar:nth-child(4) {
    height: 80%;
    animation-delay: 0.1s;
}

@keyframes bounce {
    0% {
        transform: scaleY(0.4);
    }
    100% {
        transform: scaleY(1);
    }
}

/* ================= 视频画中画 ================= */
#call-view .pip-layer {
    position: absolute;
    top: 8vh;
    right: 20px;
    width: 100px;
    height: 145px;
    background: black;
    border-radius: 14px;
    overflow: hidden;
    border: 1.5px solid rgba(255,255,255,0.4);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#call-view .pip-layer.show {
    opacity: 1;
    pointer-events: auto;
}

#call-view .flip-anim {
    animation: flipAnim 0.5s ease-in-out;
}

@keyframes flipAnim {
    0% {
        transform: scaleX(1);
    }
    50% {
        transform: scaleX(0);
    }
    100% {
        transform: scaleX(1);
    }
}

#call-view .pip-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255,255,255,0.6);
    font-size: 36px;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    z-index: 5;
}

#call-view .pip-layer.camera-off .pip-overlay {
    opacity: 1;
}

/* ================= 浮动字幕层 ================= */
#call-view .chat-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 320px 20px 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 15;
    pointer-events: none;
    mask-image: linear-gradient(to bottom, transparent 30%, black 45%, black 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 30%, black 45%, black 100%);
}

#call-view .chat-layer::-webkit-scrollbar {
    display: none;
}

#call-view .bubble-subtitle {
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 15px;
    max-width: 85%;
    line-height: 1.4;
    animation: slideUp 0.3s;
    color: white;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-self: flex-start;
    margin-bottom: 5px;
}

#call-view .bubble-subtitle.me {
    align-self: flex-end;
    background: rgba(52, 199, 89, 0.3);
}

#call-view .bubble-subtitle.system {
    align-self: center;
    background: rgba(255,255,255,0.1);
    font-size: 13px;
    opacity: 0.7;
}

/* ================= 底部控制区 ================= */
#call-view .dock-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0 0 calc(40px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#call-view .dock-area.slide-out {
    transform: translateY(150%);
}

/* ================= 控制按钮网格 ================= */
#call-view .controls-grid {
    display: grid;
    align-items: center;
    justify-items: center;
    padding: 0 10px;
    width: 100%;
    transition: 0.3s;
}

#call-view .control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#call-view .c-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: none;
    color: white;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    pointer-events: auto;
}

#call-view .c-btn:active {
    transform: scale(0.9);
}

#call-view .btn-label {
    font-size: 13px;
    margin-top: 8px;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

#call-view .btn-hangup-final {
    width: 72px;
    height: 72px;
    border-radius: 50% !important;
    background-color: #FF3B30;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 20px rgba(255, 59, 48, 0.4);
    cursor: pointer;
    transition: transform 0.1s;
    pointer-events: auto;
}

#call-view .btn-hangup-final i {
    font-size: 36px;
    color: white;
    line-height: 1;
}

#call-view .btn-hangup-final:active {
    transform: scale(0.92);
}

#call-view .btn-accept-final {
    width: 72px;
    height: 72px;
    border-radius: 50% !important;
    background-color: #34C759;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 20px rgba(52, 199, 89, 0.4);
    cursor: pointer;
    transition: transform 0.1s;
    pointer-events: auto;
    animation: pulse 1.5s infinite;
}

#call-view .btn-accept-final i {
    font-size: 36px;
    color: white;
    line-height: 1;
}

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

/* ================= Toast 提示 - 极光幻白珍珠水滴样式 ================= */
#call-view .toast {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    padding: 6px 24px 6px 6px;
    gap: 12px;
    border-radius: 99px 24px 8px 99px;
    background: linear-gradient(110deg, rgba(255,255,255,0.95), rgba(245,235,250,0.85), rgba(225,245,255,0.85));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 
        inset 0 2px 3px rgba(255,255,255,0.9), 
        inset 0 -1px 2px rgba(0,0,0,0.02),
        0 6px 16px rgba(180, 190, 210, 0.25);
    border: 1px solid rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.8px;
    white-space: nowrap;
    background-clip: text;
    -webkit-background-clip: text;
    color: #6B728E;
    opacity: 0;
    pointer-events: none;
    z-index: 2000;
    transition: opacity 0.3s, transform 0.3s;
}

#call-view .toast::before {
    content: '';
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, #faeef5 30%, #dcd2dd 80%, #aeb4c5 100%);
    box-shadow: 
        inset -3px -3px 6px rgba(0,0,0,0.1), 
        inset 2px 2px 4px rgba(255,255,255,0.9), 
        0 2px 5px rgba(0,0,0,0.15);
}

#call-view .toast.show {
    opacity: 1;
    animation: sayooCallToastIn 0.5s ease-out forwards;
}

@keyframes sayooCallToastIn {
    0% { opacity: 0; transform: translate(-50%, -50%) translateY(8px); }
    100% { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
}

/* ================= 结束画面 ================= */
#view-ended {
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.7);
    display: none !important; /* 🔧 默认隐藏 */
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    color: white;
}

#view-ended.active {
    display: flex !important; /* 🔧 激活时显示 */
    opacity: 1;
    pointer-events: auto;
}

#view-ended h2 {
    font-size: 24px;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

#view-ended p {
    opacity: 0.8;
    margin-top: 8px;
    font-size: 16px;
}

/* ================= 动画 ================= */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
