/* ========== 1. 公共基础与全局重置 ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮蓝框 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: #2b2b2b; /* PC 端背景色，突出中间应用卡片 */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh; /* 适配移动端动态地址栏 */
    overflow: hidden;
}


/* ========== 2. 登录页（login.html） ========== */
body.login-page {
    background: #f3f3f3;
}

.login-card {
    background: #fff;
    padding: 30px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    width: 320px;
    max-width: 90vw;
    text-align: center;
}

.login-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
}

.login-card button {
    width: 100%;
    padding: 12px;
    background: #07c160;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}


/* ========== 3. 房间列表页（list.html & 左滑抽屉/置顶） ========== */
body.list-page {
    background: #2b2b2b;
}

.container {
    width: 100%;
    max-width: 480px;
    background: #fff;
    height: 92vh;
    max-height: 840px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.header {
    background: #f5f5f5;
    padding: 12px 15px;
    text-align: center;
    font-weight: bold;
    border-bottom: 1px solid #e7e7e7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 110px;
    outline: none;
    font-size: 14px;
}

.header button {
    padding: 6px 12px;
    background: #07c160;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}

/* 列表项外层容器（抽屉舞台） */
.list-item-wrapper {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid #f0f0f0;
    background-color: #fff;
    user-select: none;
}

/* 置顶会话高亮背景 */
.list-item-wrapper.pinned {
    background-color: #f7f7f7;
}

/* 列表主内容层 */
.list-item-content {
    position: relative;
    z-index: 2;
    display: flex;
    padding: 12px 15px;
    align-items: center;
    background-color: inherit;
    transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    cursor: pointer;
}

/* 左滑展开操作菜单 */
.list-item-wrapper.swiped .list-item-content {
    transform: translateX(-140px);
}


.avatar {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #4a90e2;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.info {
    flex: 1;
    overflow: hidden;
}

.room-name {
    font-size: 16px;
    color: #333;
    margin-bottom: 4px;
}

.last-msg {
    font-size: 13px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.right-action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    height: 40px;
    margin-left: 10px;
}

.time {
    font-size: 12px;
    color: #b2b2b2;
}

/* 右侧抽屉动作按钮区 */
.list-item-actions {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 140px;
    display: flex;
    z-index: 1;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.action-btn:active {
    opacity: 0.8;
}

.action-btn.pin-btn {
    background-color: #2ba245; /* 微信绿 */
}

.action-btn.del-btn {
    background-color: #ff4d4f; /* 警告红 */
}


/* ========== 4. 聊天界面（chat.html） ========== */
body.chat-page {
    background: #2b2b2b;
}

.chat-container {
    width: 100%;
    max-width: 480px;
    height: 92vh;
    max-height: 840px;
    background: #f5f5f5;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    background: #f5f5f5;
    padding: 15px;
    text-align: center;
    font-weight: bold;
    border-bottom: 1px solid #e7e7e7;
    position: relative;
    flex-shrink: 0;
}

.back-btn {
    position: absolute;
    left: 15px;
    top: 15px;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    font-weight: normal;
}

.messages-box {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    width: 100%;
}

.message-row.self {
    flex-direction: row-reverse;
}

.message-row.other {
    flex-direction: row;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #ddd;
}

.msg-content {
    display: flex;
    flex-direction: column;
    max-width: 72%;
}

.message-row.self .msg-content {
    align-items: flex-end;
}

.message-row.other .msg-content {
    align-items: flex-start;
}

.sender-name {
    font-size: 12px;
    color: #b2b2b2;
    margin-bottom: 4px;
    padding: 0 2px;
}

.bubble {
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-all;
    border-radius: 6px;
    position: relative;
}

.message-row.self .bubble {
    background-color: #95ec69;
    color: #000;
}

.message-row.other .bubble {
    background-color: #ffffff;
    color: #000;
    border: 1px solid #e5e5e5;
}

.bubble img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
    display: block;
    cursor: pointer;
}

.bubble audio {
    max-width: 200px;
    display: block;
}

/* 图片与语音气泡：去背景、去内边距、去边框 */
.bubble.media-bubble {
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
}

.input-area {
    display: flex;
    padding: 10px 12px;
    background: #f7f7f7;
    border-top: 1px solid #eaeaea;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.input-area input[type="text"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
    font-size: 15px;
    background: #fff;
}

.tool-btn {
    background: #fff;
    border: 1px solid #ddd;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

.tool-btn:hover {
    background: #f0f0f0;
}

.tool-btn.recording {
    background: #ff4d4f;
    color: white;
    border-color: #ff4d4f;
}

.input-area button.send-btn {
    padding: 10px 14px;
    background: #07c160;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}


/* ========== 5. 个人信息修改弹窗 ========== */
.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.user-profile:hover {
    background-color: #e8e8e8;
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    background-color: #ddd;
}

.header-nickname {
    font-size: 15px;
    font-weight: bold;
    color: #333;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 280px;
    max-width: 85vw;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    text-align: center;
}

.modal-item {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #666;
}

.modal-item input[type="text"] {
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

.modal-item input[disabled] {
    background-color: #f2f2f2;
    color: #777;
    cursor: not-allowed;
    border: 1px solid #ddd;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 15px;
}

.modal-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: #07c160;
    color: white;
    cursor: pointer;
}

.modal-actions button.cancel-btn {
    background: #ccc;
}


/* ========== 6. 移动端响应式全屏覆盖（<= 768px） ========== */
@media screen and (max-width: 768px) {
    body, body.list-page, body.chat-page {
        background-color: #ececec;
    }

    .container, .chat-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* 无缝贴合移动端屏幕高 */
        max-width: 100%;
        max-height: 100%;
        border-radius: 0; /* 移动端取消圆角 */
        box-shadow: none;
    }

    /* 气泡放宽适配手机屏 */
    .msg-content {
        max-width: 80%;
    }

    /* 适配 iPhone 底部全面屏安全区（刘海屏/横条） */
    .input-area {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}