/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding-top: 10px !important; /* 加顶部间距，防止状态栏被顶 */
    padding-bottom: 80px !important;
    box-sizing: border-box !important; /* 防止内边距撑大页面 */
}

/* 登录页 */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.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 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;
}

.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 {
    max-width: 400px;
    margin: 0 auto;
    padding: 10px;
    padding-bottom: 80px;
}

/* 状态栏 */
.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);
}
.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; /* 文字大小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-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-name {
    font-weight: 600;
}

.status-light.offline {
    background: #b7b6b6;
}

.online { background: #34c759; }
.offline { background: #8e8e93; }

.close-btn {
    padding: 8px 35px;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* 消息区：核心修改 - 用calc计算高度，避开底部输入栏，适配输入法 */
#msg-box{
  width:100%; 
  height: 60vh !important; /* 比原来的65vh少5vh，给状态栏留空间 */
  margin-top: 10px !important; /* 再加顶部外边距，彻底避开状态栏 */
  max-height: calc(100vh - 80px);
  border:1px solid #eee; 
  border-radius:8px; 
  background:white;
  padding:10px; 
  overflow-y:auto; 
  display:flex; 
  flex-direction:column;
  overscroll-behavior-y: contain; 
  -webkit-overflow-scrolling: touch;
  /* 新增：固定顶部，防止被顶起 */
  position: relative;
  z-index: 1;
}

.msg-container {
    display: flex;
    align-items: flex-end;
    max-width: 80%;
    margin: 6px 0 !important; /* 上下8px间距，可按需调5px/10px */
}

.me-container {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-bubble {
    padding: 10px 15px;
    border-radius: 5px;
    word-break: break-word;
}

.me-bubble {
    background: #007AFF;
    color: white;
}

.other-bubble {
    background: #E5E5EA;
    color: black;
}

.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;
}

/* 底部输入区：微调，保留原有样式，仅加z-index兜底 */
/* 底部输入栏整体 - flex布局基础 */
#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; /* 核心！子元素垂直顶格，解决textarea居中 */
  box-sizing: border-box;
  z-index: 99;
}

/* 输入框 */
#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;
  /* 彻底解决光标居中：删除 align-self: flex-start; 改用下面两行 */
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
  /* 清除默认内边距/间距，避免光标前有空隙 */
  margin: 0;
  white-space: pre-wrap;
}
/* 隐藏滚动条样式保留 */
.hide-scrollbar {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}
/* 按钮样式微调，和输入框对齐 */
#send, #voice-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: #007aff;
  color: #fff;
  cursor: pointer;
  margin-top: 2px; /* 和输入框顶部对齐 */
}

#img-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #007AFF;
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
}
/* 语音按钮圆形样式 */
#voice-btn {
    /* 基础样式重置 */
    border: none;
    outline: none;
    padding: 0;
    margin: 0;
    /* 圆形核心样式 */
    width: 40px;    /* 圆形直径 */
    height: 40px;   /* 宽高一致形成圆形 */
    border-radius: 50%; /* 圆角50%变成圆形 */
    background-color: #f0f0f0; /* 圆形背景色 */
    color: #333;     /* 喇叭图标颜色 */
    font-size: 18px; /* 喇叭图标大小 */
    cursor: pointer; /* 鼠标悬浮手型 */
    display: flex;
    align-items: center;
    justify-content: center; /* 图标居中 */
    transition: background-color 0.2s; /* 点击过渡效果 */
}

/* 悬浮/点击效果（可选） */
#voice-btn:hover {
  background-color: #e0e0e0;
}

#voice-btn:active {
  background-color: #d0d0d0;
}

#sendBtn {
    width: 50px;
    height: 35px;
    border-radius: 5px;
    background: #007AFF;
    color: white;
    border: none;
    cursor: pointer;
}

#fileInput {
    display: none;
}

.tip-box {
    text-align: center;
    padding: 5px;
    margin: 5px 0;
    border-radius: 5px;
    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;
}

#tip {
    text-align: center;
    padding: 10px;
    margin: 10px 0;
    border-radius: 5px;
    display: none;
}

.success-tip {
    background: #e8f5e9;
    color: #34c759;
    display: block;
}

.error-tip {
    background: #ffebee;
    color: #ff3b30;
    display: block;
}
/* 通用隐藏滚动条样式：保留滚动功能，适配所有浏览器 */
.hide-scrollbar::-webkit-scrollbar { 
    display: none; 
}
.hide-scrollbar { 
    -ms-overflow-style: none; 
    scrollbar-width: none; 
}

#voiceBtn {
    width:32px;
    height:32px;
    border-radius:50%;
    background:#e0e0e0;
    border:none;
    font-size:20px;
    color:#666;
}

/* 语音部分 */
/* 主按钮区域 */
.main-button-container {
    display: flex;
    justify-content: center;
    margin: 40px 0;
}
.main-call-button {
    width: 120px;
    height: 120px;
    border-radius: 60px;
    background: #007AFF;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 10px 20px rgba(0,122,255,0.3);
}
.main-call-button 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);
}
.voice-call-layer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f7fa;
    z-index: 2000;
    overflow-y: auto;
    padding: 20px;
}

.voice-call-container {
    max-width: 400px;
    margin: 0 auto;
}

/* 音量控制 */
.volume-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}

.volume-slider {
    flex: 1;
    height: 40px;
    cursor: pointer;
}

.volume-icon {
    color: #007AFF;
}

.volume-value {
    min-width: 30px;
    text-align: right;
}
.volume-tip {
    font-size: 11px;
    text-align: center;
    margin-top: 8px;
    position: relative;
    top: 2px;
}

.close-button {
    border: none;
    background: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 5px;
}

/* 返回按钮 */
.back-button-container {
    margin-top: 24px;
    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;
    background: white;
    border-radius: 32px 32px 0 0;
    padding: 30px 20px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 2100;
}

.incoming-overlay.show {
    transform: translateY(0);
}

.incoming-title {
    text-align: center;
    font-size: 18px;
    margin-bottom: 24px;
}

.caller-name {
    font-weight: 600;
}

.incoming-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.reject-button {
    width: 120px;
    height: 56px;
    border-radius: 28px;
    border: none;
    background: #ff3b30;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

.answer-button {
    width: 120px;
    height: 56px;
    border-radius: 28px;
    border: none;
    background: #34c759;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

/* 音频元素 */
.remote-audio {
    display: none;
}

/* 通话提示框样式 - 对方拒绝通话 */
.call-tip {
    position: fixed;
    top: 70%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95); /* 高透白背景 */
    color: #333333; /* 深灰文字，不刺眼 */
    padding: 12px 24px;
    border-radius: 25px; /* 圆润圆角，更现代 */
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15); /* 轻阴影，有层次感 */
    z-index: 9999;
    pointer-events: none; /* 不阻挡底层操作 */
    white-space: nowrap; /* 防止文字换行 */
}