/* CSS 样式开始 */
:root {
    /* 颜色变量 - 暗黑主题/类 Discord */
    --bg-dark: #1e1f26; /* 主背景 */
    --bg-secondary: #282a36; /* 聊天主区背景 */
    --text-primary: #f8f8f2;
    --text-secondary: #90939b;
    --accent-color: #6272a4; /* 紫色/蓝色调，用于强调 */
    
    /* 毛玻璃效果背景 */
    --frosted-bg: rgba(40, 42, 54, 0.6); 
    --frosted-border: rgba(255, 255, 255, 0.1);
    
    /* 消息气泡 */
    --bubble-sent: #6272a4; /* 发送方气泡颜色 (强调色) */
    --bubble-received: #44475a; /* 接收方气泡颜色 */
}

body, html {
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden; 
}

.app-container {
    display: flex;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ---------------- 毛玻璃卡片基类 ---------------- */
.glass-panel {
    background-color: var(--frosted-bg);
    backdrop-filter: blur(15px);
    border-right: 1px solid var(--frosted-border);
    transition: all 0.3s ease; /* 平滑切换动效 */
}

/* ---------------- 侧边栏 (联系人) ---------------- */
.sidebar {
    width: 300px;
    min-width: 200px;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 10px;
    border-bottom: 1px solid var(--frosted-border);
    font-weight: bold;
    color: var(--accent-color);
}

.contact-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 5px 0;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin: 5px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.contact-item:hover, .contact-item.active {
    background-color: var(--bubble-received);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-color);
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    color: var(--text-primary);
}

/* ---------------- 聊天主窗口 ---------------- */
.chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary); 
}

.chat-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--frosted-border);
    background-color: var(--frosted-bg);
    backdrop-filter: blur(15px);
}

.chat-header h2 {
    margin: 0;
    font-size: 1.2em;
}

.message-area {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 消息气泡 */
.message-bubble {
    max-width: 70%;
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
    position: relative;
    animation: fadeIn 0.3s ease-out; /* 动效 */
}

.message-bubble.received {
    align-self: flex-start;
    background-color: var(--bubble-received);
    border-top-left-radius: 4px; /* 逼真的消息气泡形状 */
}

.message-bubble.sent {
    align-self: flex-end;
    background-color: var(--bubble-sent);
    border-top-right-radius: 4px; /* 逼真的消息气泡形状 */
}

.message-bubble.system {
    align-self: center;
    background: none;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9em;
}

.message-meta {
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 输入区域 */
.input-area {
    min-height: 60px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    border-top: 1px solid var(--frosted-border);
    background-color: var(--frosted-bg);
    backdrop-filter: blur(15px);
}

.input-area input[type="text"] {
    flex-grow: 1;
    padding: 10px 15px;
    border-radius: 20px;
    border: none;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 1em;
    margin-right: 10px;
    transition: background-color 0.2s;
}

.input-area input[type="text"]:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.2);
}

.action-button {
    width: 44px; /* 适合手指点击 */
    height: 44px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--text-primary);
    border: none;
    margin-left: 8px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.action-button:hover {
    background-color: #7a8ecf;
}

.action-button:active {
    transform: scale(0.95);
}

/* 语音输入按钮长按效果 */
#voice-input-btn.recording {
    background-color: #ff5555;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 85, 85, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 85, 85, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 85, 85, 0); }
}

/* ---------------- 右侧栏 (详情/视频) ---------------- */
.right-panel {
    width: 300px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

/* 详情视图 (默认) */
.detail-view {
    padding: 20px;
    flex-grow: 1;
}

/* 视频视图 */
.video-view {
    flex-grow: 1;
    display: none; 
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: #000;
}

.video-view.active {
    display: flex;
}

#remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #000;
}

#local-video {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 120px;
    height: 90px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid var(--accent-color);
    z-index: 10;
}

.video-controls {
    position: absolute;
    bottom: 20px;
    display: flex;
    gap: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 30px;
    z-index: 20;
}

.video-controls .action-button {
    width: 50px;
    height: 50px;
    font-size: 1.3em;
    margin: 0;
}

.video-controls .action-button#hangup-btn {
    background-color: #ff5555;
}

.video-controls .action-button.disabled {
    background-color: #555;
}

/* ---------------- 响应式设计 ---------------- */
.hamburger-menu {
    display: none;
    cursor: pointer;
    font-size: 1.5em;
    margin-right: 15px;
    color: var(--text-primary);
}

/* 1024px 以下：手机/平板布局 */
@media (max-width: 1024px) {
    .app-container {
        border-radius: 0;
    }
    
    /* 侧边栏和右侧面板绝对定位并隐藏 */
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
        width: 280px;
    }
    .sidebar.visible {
        transform: translateX(0);
    }
    
    .right-panel {
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        z-index: 90;
        transform: translateX(100%);
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
        width: 280px;
        border-right: none;
        border-left: 1px solid var(--frosted-border);
    }
    
    .right-panel.visible {
        transform: translateX(0);
    }
    .chat-main {
        width: 100%;
    }
    
    .chat-header {
        justify-content: space-between;
    }
    .hamburger-menu {
        display: block;
    }
    
    /* 手机端默认隐藏右侧栏，仅在激活视频时，或用户点击时显示 */
    .right-panel:not(.visible) {
        width: 0;
        opacity: 0;
        pointer-events: none;
    }
}

/* 用于呼叫邀请的按钮 (新增) */
.call-action-btn {
    padding: 5px 10px;
    margin: 0 5px;
    border: 1px solid var(--accent-color);
    background-color: var(--bubble-sent);
    color: var(--text-primary);
    border-radius: 5px;
    cursor: pointer;
}
.call-action-btn:hover {
    opacity: 0.8;
}

/* 语音消息样式 (微信风格) */
.voice-message {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.voice-message i {
    font-size: 1.2em;
    color: var(--text-primary);
}

.voice-duration {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.message-bubble.sent .voice-message {
    flex-direction: row-reverse;
}

.message-bubble.sent .voice-duration {
    color: rgba(255, 255, 255, 0.8);
}
