/* ===================== 全局基础样式 ===================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 让 html/body 不可滚动 */
html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding-top: 10px !important; /* 顶部间距避开状态栏 */
    /* 移除 padding-bottom，因为输入栏 fixed 不再需要 body 垫高 */
    padding-bottom: 0 !important;
    box-sizing: border-box !important; /* 防止内边距撑大页面 */
}

/* 通用隐藏滚动条 */
.hide-scrollbar::-webkit-scrollbar { 
    display: none; 
}
.hide-scrollbar { 
    -ms-overflow-style: none; 
    scrollbar-width: none; 
    -webkit-overflow-scrolling: touch; /* 移动端顺滑滚动 */
}

/* 通用提示框样式 */
.tip-box, #tip {
    text-align: center;
    padding: 5px 10px;
    margin: 5px 0;
    border-radius: 5px;
    display: none;
}
.custom-tip {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    color: #666666;
    font-size: 14px;
    border-radius: 8px;
    box-shadow: 0 0 10px 2px rgba(0, 122, 255, 0.3);
    z-index: 99999;
    pointer-events: none;
    white-space: nowrap;
}

/* ===================== 登录页样式 ===================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container h4 {
    text-align: center;
    margin-bottom: 20px;
    color: #007AFF;
}

.login-container input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 16px;
    outline: none;  /* 去掉默认黑框 */
    transition: all 0.2s ease;  /* 平滑过渡 */
}

.login-container input:focus {
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.login-container button {
    width: 100%;
    padding: 12px;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

.error-message {
    color: #ff3b30;
    text-align: center;
    margin: 10px 0;
    display: none;
}

/* ===================== 聊天页样式 ===================== */
.chat-page {
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 400px;
    margin: 0 auto;
    padding: 10px 10px 0 10px;  /* 移除底部内边距，由消息框内边距负责 */
}

/* 状态栏 */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    flex-shrink: 0; /* 防止被压缩 */
}
.voice-bar {
    background-color:rgba(255, 255, 255, 0.508);
    height: 40px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    box-sizing: border-box;
}
#talk-bar {
    font-size: 14px;
    color: #333;
    text-align: center;
    font-family: "Microsoft Yahei", sans-serif;
    line-height: 1;
}

.user-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 在线/离线状态灯 */
.status-light {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}
.status-light.online, .online { 
    background: #34c759; 
}
.status-light.offline, .offline { 
    background: #8e8e93; 
}

.close-btn {
    padding: 8px 35px;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* 消息区域 - 使用 flex 布局自适应高度 */
#msg-box {
    flex: 1;                     /* 撑满剩余高度 */
    min-height: 0;               /* 防止 flex 溢出 */
    width: 100%;
    border: 1px solid #eee; 
    border-radius: 8px; 
    background: white;
    padding: 10px; 
    padding-bottom: 70px; /* 新增：为底部固定输入栏留出空间 */
    overflow-y: auto; 
    display: flex; 
    flex-direction: column;
    overscroll-behavior: contain; /* 阻止内部滚动触发页面刷新 */
    -webkit-overflow-scrolling: touch; /* 移动端顺滑滚动 */
    position: relative;
    z-index: 1;
    scroll-margin-bottom: 70px; /* 新增：确保滚动到底部时不被遮挡 */
}

/* 消息气泡 */
.msg-container {
    display: flex;
    align-items: flex-end;
    max-width: 80%;
    margin: 16px 0 6px 0 !important;  /* 上边距加大，为时间标签留空间 */
    position: relative;  /* 为时间标签的绝对定位提供参照 */
}
.me-container {
    align-self: flex-end;
    flex-direction: row-reverse;
    width: 100%;              /* 新增 */
}
.msg-bubble {
    padding: 10px 15px;
    border-radius: 5px;
    word-break: break-word;
}
.me-bubble {
    background: #03e82d;
    color: black;
}
.other-bubble {
    background: #E5E5EA;
    color: black;
}

/*每隔3钟显示时间*/
.msg-time {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin: 10px 0;
    width: 100%;
    clear: both;
    float: none;
    display: block;
}

/* 撤回按钮/提示 */
.recall-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    margin: 0 5px;
    opacity: 0;
}
.msg-container:hover .recall-btn {
    opacity: 1;
}
.recall-tip {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin: 5px 0;
}
.offline-time {
    font-size: 10px;
    color: #888;
    text-align: right;
    margin-bottom: 2px;
}

/* 底部输入区 */
#input-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 400px;
    margin: 0 auto;
    padding: 10px;
    background: #f7f8fa;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    box-sizing: border-box;
    z-index: 199;  /*原值是99*/
    transition: bottom 0.2s ease; /* 添加平滑过渡 */
}

/* 输入框 */
#input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    resize: none;
    overflow-y: auto;
    height: 40px;
    min-height: 40px;
    max-height: 200px;
    box-sizing: border-box;
    text-align: left;
    vertical-align: top;
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
}


/* 图片全屏预览层---------------------------------------------------------------------- */
.image-preview {
  display: none;               /* 默认隐藏 */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;              /* 足够高，盖住所有界面 */
  align-items: center;
  justify-content: center;
}
.image-preview img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;         /* 保持比例，完整显示图片 */
  border-radius: 4px;
}
/*-----------图片预览结束--------------------------------------*/


/* 功能按钮（图片/语音/发送） */
#img-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #007AFF;
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0; /* 防止被压缩 */
}
/* 语音按钮 */
#voice-btn, #voiceBtn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f0f0f0;
    color: #333;
    border: none;
    outline: none;
    padding: 0;
    margin: 0;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0; /* 防止被压缩 */
}
#voice-btn:hover, #voiceBtn:hover {
    background-color: #e0e0e0;
}
#voice-btn:active, #voiceBtn:active {
    background-color: #d0d0d0;
}

#sendBtn, #send {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #007aff;
    color: #fff;
    cursor: pointer;
    margin-top: 2px; /* 和输入框顶部对齐 */
    flex-shrink: 0; /* 防止被压缩 */
}
#sendBtn {
    width: 50px;
    height: 35px;
    border-radius: 5px;
}

#fileInput {
    display: none;
}

/* ===================== 语音通话样式 ===================== */
/* 语音呼叫层 */
.voice-call-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f5f7;
    z-index: 9999;
    display: none;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}
.voice-call-container {
    max-width: 400px;
    margin: 0 auto;
}

/* 语音层主体 */
.voice-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.main-button-container {
    display: flex;
    justify-content: center;
    margin: 40px 0;
}
/* 统一呼叫按钮样式 */
.voice-main-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #007AFF;
    color: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 10px 20px rgba(0,122,255,0.3);
}
.voice-main-btn span {
    font-size: 24px;
}

/* 音量控制 */
.voice-controls {
    display: none;
    background: white;
    border-radius: 32px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    /* 设置为垂直布局，让子元素上下排列 */
    
    flex-direction: column;
    gap: 8px; /* 控制两个元素之间的间距 */
}
.volume-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}
.volume-icon {
    color: #007AFF;
}
.volume-slider {
    flex: 1;
    height: 40px;
    cursor: pointer;
}
.volume-value {
    min-width: 30px;
    text-align: right;
}
.volume-tip {
    font-size: 11px;
    text-align: center;
    margin-top: 8px;
    position: static;
    top: auto;
}

/* 语音层底部/返回按钮（统一样式） */
.voice-footer, .back-button-container {
    text-align: center;
    margin-top: 20px;
    display: flex;
    justify-content: center;
}
.back-button {
    width: 90%;
    height: 56px;
    border-radius: 28px;
    background: rgba(255,255,255,0.8);
    border: 1px solid #ddd;
    color: #ff3b30;
    font-size: 16px;
    cursor: pointer;
}

/* 来电面板（保留带动画的完整样式，删除重复定义） */
.incoming-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: white;
    border-radius: 32px 32px 0 0;
    padding: 30px 20px;
    box-sizing: border-box;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 9998;
    display: none;
}
.incoming-overlay.show {
    display: block;
    transform: translateY(0);
}
.incoming-title {
    text-align: center;
    font-size: 18px;
    margin-bottom: 24px;
    color: #333;
}
.caller-name {
    font-weight: 600;
}
.incoming-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}
/* 接听/拒绝按钮（统一尺寸和样式） */
.answer-button {
    width: 120px;
    height: 56px;
    border-radius: 28px;
    border: none;
    background: #34c759;
    color: white;
    font-size: 16px;
    cursor: pointer;
}
.reject-button {
    width: 120px;
    height: 56px;
    border-radius: 28px;
    border: none;
    background: #ff3b30;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

/* 音频元素隐藏 */
.remote-audio {
    display: none;
}

/* ===================== 文件服务页样式 ===================== */
.file-page {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

.file-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.upload-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#file-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.file-btn {
    padding: 10px 20px;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.file-list {
    margin-top: 20px;
}

.file-header {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f5f5f5;
    border-radius: 8px 8px 0 0;
    font-weight: bold;
}

.file-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 15px;
    border: 1px solid #eee;
    border-top: none;
}

.file-item:last-child {
    border-radius: 0 0 8px 8px;
}

.file-actions {
    display: flex;
    gap: 10px;
}

.file-link {
    color: #007AFF;
    text-decoration: none;
    cursor: pointer;
}

.file-del {
    color: #ff3b30;
    cursor: pointer;
}

.empty-tip {
    text-align: center;
    padding: 30px;
    color: #999;
    border: 1px dashed #ddd;
    border-radius: 8px;
}

/* 提示框状态 */
.success-tip {
    background: #e8f5e9;
    color: #34c759;
    display: block;
}
.error-tip {
    background: #ffebee;
    color: #ff3b30;
    display: block;
}