/**
 * Copyright (c) 河南锅锅岛科技有限公司
 * Website: ggdao.net | VX: IJG55555
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #1f2329;
}

.chat-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* 移动端浏览器地址栏/工具栏会动态收起，100vh在手机上会导致底部输入框被遮挡，100dvh更准确 */
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.06);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #4b7bec;
    color: #fff;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 17px;
    font-weight: 600;
}

.chat-header-nick {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.18);
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    user-select: none;
}

.chat-announcement {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(90deg, #eaf0ff, #f3f6ff);
    color: #3f5fd6;
    font-size: 13px;
    flex-shrink: 0;
    border-bottom: 1px solid #dbe4ff;
}

.chat-announcement-icon {
    flex-shrink: 0;
    color: #4b7bec;
}

.chat-announcement-marquee {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.chat-announcement-text {
    display: inline-block;
    white-space: nowrap;
    padding-left: 100%;
    animation-name: announcement-scroll;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.chat-announcement:hover .chat-announcement-text {
    animation-play-state: paused;
}

@keyframes announcement-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

.chat-mute-banner {
    padding: 8px 16px;
    background: #fdecea;
    color: #eb3b5a;
    font-size: 13px;
    text-align: center;
    flex-shrink: 0;
}

.chat-conn-banner {
    padding: 6px 16px;
    background: #fff3d6;
    color: #a5680b;
    font-size: 12px;
    text-align: center;
    flex-shrink: 0;
}

.upload-status {
    padding: 6px 16px;
    background: #eef2ff;
    color: #4b7bec;
    font-size: 12px;
    text-align: center;
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    -webkit-overflow-scrolling: touch;
}

.load-more {
    text-align: center;
    font-size: 13px;
    color: #8a8f99;
    padding: 6px 0 10px;
    cursor: pointer;
}

.msg-row {
    display: flex;
    align-items: flex-start; /* 头像要跟昵称那一行对齐，之前是flex-end会跟着气泡底部走，消息一多行就跟昵称错位 */
    gap: 8px;
    max-width: 100%;
}

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

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 17px;
    line-height: 1;
    font-weight: 600;
}

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

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

.msg-meta {
    font-size: 12px;
    color: #9aa0a8;
    margin-bottom: 4px;
    padding: 0 4px;
}

.msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    background: #f0f1f3;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.msg-row.self .msg-bubble {
    background: #4b7bec;
    color: #fff;
}

.msg-bubble.recalled {
    background: transparent;
    color: #9aa0a8;
    font-size: 13px;
    font-style: italic;
    padding: 4px 0;
}

.msg-bubble.media {
    background: transparent;
    padding: 0;
}

.msg-bubble.media img,
.msg-bubble.media video {
    max-width: 220px;
    max-height: 280px;
    border-radius: 12px;
    display: block;
    cursor: pointer;
}

.media-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.media-viewer.show {
    display: flex;
}

.media-viewer img,
.media-viewer video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 14px;
    border-top: 1px solid #ececec;
    background: #fff;
    flex-shrink: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.icon-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    background: #f0f1f3;
    color: #6b7280;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn:hover {
    background: #e5e7eb;
}

.icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-input-bar textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e0e2e6;
    border-radius: 18px;
    padding: 10px 16px;
    font-size: 15px;
    line-height: 1.4;
    max-height: 90px;
    font-family: inherit;
    outline: none;
}

.chat-input-bar textarea:focus {
    border-color: #4b7bec;
}

/* 排除 .icon-btn（上传按钮），避免这条通用样式的优先级把圆形图标按钮的形状/内边距冲掉，
   之前就是因为这里没排除，导致上传按钮显示成一个看不见图标的纯蓝色圆块 */
.chat-input-bar button:not(.icon-btn) {
    border: none;
    background: #4b7bec;
    color: #fff;
    padding: 0 18px;
    height: 40px;
    border-radius: 18px;
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-input-bar button:not(.icon-btn):disabled {
    background: #b7c6ec;
    cursor: not-allowed;
}

@media (max-width: 720px) {
    .chat-app {
        max-width: 100%;
        box-shadow: none;
    }
}
