/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

html, body {
    height: 100vh; /* 页面高度占满屏幕 */
    overflow: hidden; /* 禁止页面整体滚动 */
    background-color: #f0f2f5;
}

/* 聊天容器 - 自适应手机高度 */
.chat-container {
    background-color: white;
    width: 100%;
    height: 100vh; /* 占满屏幕高度 */
    display: flex;
    flex-direction: column;
    max-width: 100%; /* 移动端取消最大宽度限制 */
    max-height: 100vh;
}

.chat-header {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* 不压缩 */
}

.chat-header h3 {
    font-size: 16px;
    color: #333;
}

.logout-btn {
    color: #1a73e8;
    text-decoration: none;
    padding: 4px 8px;
    border: 1px solid #1a73e8;
    border-radius: 4px;
    font-size: 14px;
}

/* 筛选按钮 */
.filter-toggle-btn {
    padding: 8px 15px;
    background-color: #1a73e8;
    color: white;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
}

/* 筛选区域 */
.filter-container {
    padding: 8px 15px;
    border-bottom: 1px solid #eee;
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background-color: #f8f9fa;
    flex-shrink: 0;
}

.filter-container.show {
    display: flex;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.filter-select, .filter-input {
    padding: 4px 8px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 14px;
}

.filter-btn {
    padding: 4px 10px;
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.reset-btn {
    padding: 4px 10px;
    background-color: #f0f2f5;
    color: #5f6368;
    border: 1px solid #dadce0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

/* 聊天消息区域 - 自适应剩余高度 */
.chat-messages {
    flex: 1; /* 占满剩余高度 */
    padding: 15px;
    overflow-y: auto;
    background-color: #f9f9f9;
    display: flex;
    flex-direction: column-reverse;
    -webkit-overflow-scrolling: touch; /* 移动端顺滑滚动 */
}

.message-item {
    margin-bottom: 15px;
    background-color: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
    color: #5f6368;
}

.message-content {
    font-size: 14px;
    line-height: 1.4;
}

/* 图片消息优化 - 限制尺寸+预加载 */
.image-message img {
    max-width: 180px; /* 移动端缩小图片尺寸 */
    max-height: 180px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
    object-fit: cover; /* 保持比例 */
    image-rendering: -webkit-optimize-contrast; /* 优化图片渲染 */
}

.image-message img:hover {
    transform: scale(1.03);
}

/* 视频消息适配 */
.video-message video {
    max-width: 250px; /* 移动端视频尺寸 */
    max-height: 200px;
    border-radius: 4px;
    object-fit: cover;
}

.loading {
    text-align: center;
    color: #5f6368;
    padding: 8px;
    display: none;
    font-size: 14px;
}

.load-more {
    text-align: center;
    padding: 8px;
    color: #1a73e8;
    cursor: pointer;
    display: none;
    border-top: 1px solid #eee;
    font-size: 14px;
    flex-shrink: 0;
}

.load-more:hover {
    background-color: #f0f7ff;
}

/* 输入区域适配 */
.chat-input {
    padding: 15px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    background-color: white;
}

.input-group {
    margin-bottom: 12px;
}

#content {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    resize: none;
    font-size: 14px;
    min-height: 60px; /* 移动端输入框最小高度 */
}

/* 按钮组 */
.btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.file-upload label {
    display: inline-block;
    padding: 8px 12px;
    background-color: #f0f2f5;
    border: 1px solid #dadce0;
    border-radius: 4px;
    cursor: pointer;
    color: #5f6368;
    white-space: nowrap;
    font-size: 14px;
}

.file-upload input {
    display: none;
}

.send-btn {
    padding: 8px 16px;
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.send-btn:hover {
    background-color: #1557b0;
}

.no-data {
    text-align: center;
    color: #5f6368;
    padding: 20px;
    font-size: 14px;
}

/* 图片预览弹窗优化 */
.image-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* 完整显示图片 */
    -webkit-backface-visibility: hidden; /* 优化渲染 */
    transform: translateZ(0);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

/* 导航按钮简化 - 只显示图标 */
.nav-btn {
    position: absolute;
    color: white;
    background-color: rgba(0, 0, 0, 0.4);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

.nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.6);
}

/* 登录页面适配 */
.login-container {
    background-color: white;
    padding: 30px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 350px;
    margin: 50px auto;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #1a73e8;
    font-size: 18px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #5f6368;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 14px;
}

.form-group button {
    width: 100%;
    padding: 10px;
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
}

.flash-message {
    background-color: #fef0f0;
    color: #d93025;
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 15px;
    text-align: center;
    font-size: 14px;
}