/* English Buddy - 通话界面样式（重构版） */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

.container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    position: relative;
    background: rgba(255, 255, 255, 0.12);
}

/* M5: 后台配置入口（低调，不打扰孩子） */
.admin-entry {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    text-decoration: none;
    color: #fff;
    opacity: 0.6;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
}

.admin-entry:active { opacity: 1; }

/* ============ 屏幕切换 ============ */
.screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.screen.active {
    display: flex;
}

/* ============ 拨打界面 ============ */
#dial-screen .avatar-container {
    margin-bottom: 24px;
}

.avatar-container {
    position: relative;
}

.avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 60px;
    border: 3px solid rgba(255, 255, 255, 0.5);
    overflow: hidden;
}

.girl-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* M6: 强制 GPU 合成层，解决安卓 WebView 位图初始不绘制（需点击才显示） */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

.avatar-glow {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    animation: glow 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes glow {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.05); }
}

.title {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 40px;
}

.call-button {
    width: 180px;
    height: 64px;
    border: none;
    border-radius: 40px;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.call-button:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 28px rgba(34, 197, 94, 0.5);
}

.call-button:active {
    transform: scale(0.95);
}

/* ============ 通话界面 ============ */
#call-screen {
    justify-content: flex-start;
    padding-top: 60px;
}

.call-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
}

.caller-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 46px;
    border: 3px solid rgba(255, 255, 255, 0.5);
    overflow: hidden;
}

.call-status {
    text-align: center;
    color: #fff;
}

.call-status #status-text {
    display: block;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

/* M6.3: 倾听提示 */
.listening-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 15px;
    color: #fff;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}
.listening-indicator.active {
    display: flex;
}
.listening-indicator .mic-icon {
    display: inline-block;
    font-size: 16px;
    animation: mic-pulse 1s ease-in-out infinite;
}
.listening-indicator.thinking .mic-icon {
    animation: none;
    opacity: 0.5;
}
.listening-indicator.thinking {
    background: rgba(255, 255, 255, 0.10);
}

@keyframes mic-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.7; }
}

.timer {
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
}

/* 波形 */
.waveform-container {
    width: 100%;
    max-width: 380px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    margin-bottom: 24px;
}

.waveform {
    width: 100%;
    height: 100%;
    display: block;
}

.waveform-hint {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

/* 字幕 */
.caption-container {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
    min-height: 120px;
}

.caption-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 85%;
    /* 默认显示，避免 opacity transition 导致截屏/手机浏览器不显示 */
    display: block;
}

.child-caption {
    background: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-caption {
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.caption-text {
    font-size: 16px;
    line-height: 1.4;
    word-break: break-word;
}

/* 挂断按钮 */
.hangup-button {
    width: 120px;
    height: 60px;
    border: none;
    border-radius: 40px;
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
    transition: transform 0.2s;
}

.hangup-button:hover { transform: scale(1.05); }
.hangup-button:active { transform: scale(0.95); }

/* 呼叫中动画 */
#call-screen.calling .caller-avatar {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

/* 平板/桌面适配 */
@media (min-width: 768px) {
    .container {
        min-height: 90vh;
        border-radius: 24px;
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
}
