/* KakaoTalk Style v2.0 - 完全仿真版 */

/* 主容器 - 自适应高度 */
.k-box {
    width: 375px;
    min-height: 200px;
    max-width: 100%;
    background: #b2c7da;
    border-radius: 0;
    font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
    box-shadow: none;
    margin: 0 auto;
    position: relative;
}

/* 头部 */
.k-h {
    height: 54px;
    background: white;
    color: #333;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* 聊天区域 - 自适应高度 */
.k-bd {
    min-height: 100px;
    padding: 10px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #b2c7da;
}

/* 日期分割线 */
.k-dt {
    text-align: center;
    margin: 16px 0 12px;
}

.k-p {
    background: rgba(0,0,0,0.15);
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 10px;
    color: #555;
    display: inline-block;
}

/* 消息行 */
.k-r {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    max-width: 80%;
    margin: 2px 0;
}

/* 我的消息 (右侧) */
.k-r.m {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* 其他人消息 (左侧) */
.k-r.v {
    align-self: flex-start;
}

/* 头像 */
.k-av {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #333;
    background: #f0f0f0;
    flex-shrink: 0;
    margin-bottom: 0;
    border: 1px solid rgba(0,0,0,0.1);
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

/* 头像图片样式 */
.k-av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* 隐藏的头像占位符 */
.k-av-hidden {
    opacity: 0;
    visibility: hidden;
}

/* 未知sender的灰色头像 */
.k-av-unknown {
    background: #999 !important;
    color: white;
}

/* 昵称包装容器 */
.k-nickname-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: -18px;
    padding-left: 0;
}

/* 昵称样式 */
.k-nickname {
    font-size: 9px;
    color: #888;
    font-weight: normal;
    line-height: 1.2;
    margin-top: 0;
}

/* 有昵称时的头像样式 */
.k-nickname-wrapper .k-av {
    margin-top: 0;
    margin-bottom: 0;
    flex-shrink: 0;
}

/* 连续消息样式调整 */
.k-r-continuation {
    margin-top: 1px;
}

/* BTS成员头像特殊样式 - 更真实的颜色 */
.k-r[data-sender="jin"] .k-av { background: #ffb3ba; }
.k-r[data-sender="suga"] .k-av { background: #bae1ff; }
.k-r[data-sender="jh"] .k-av { background: #ffffba; }
.k-r[data-sender="rm"] .k-av { background: #ffdfba; }
.k-r[data-sender="jm"] .k-av { background: #baffc9; }
.k-r[data-sender="v"] .k-av { background: #d4baff; }
.k-r[data-sender="jk"] .k-av { background: #ffb3ef; }

/* 消息气泡 */
.k-b {
    background: #ffffff;
    padding: 6px 10px;
    border-radius: 14px;
    max-width: 220px;
    word-wrap: break-word;
    font-size: 11px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
}

/* 我的消息气泡 */
.k-r.m .k-b {
    background: #fee500;
    border-bottom-right-radius: 4px;
}

/* 其他人消息气泡 */
.k-r.v .k-b {
    border-bottom-left-radius: 4px;
}

/* 时间戳 */
.k-tm {
    font-size: 9px;
    color: #888;
    align-self: flex-end;
    margin-top: auto;
    margin-bottom: 2px;
    white-space: nowrap;
    font-weight: 400;
}

/* 系统动作消息 */
.k-action {
    align-self: center;
    margin: 6px 0;
}

.k-action-text {
    background: rgba(0,0,0,0.15);
    color: #666;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 10px;
    text-align: center;
    display: inline-block;
}

/* 图片消息占位符 - 仿照片样式 */
.k-b-image {
    background: #e9e9e9;
    width: 180px;
    height: 180px;
    padding: 12px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    position: relative;
    color: #555;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid rgba(0,0,0,0.1);
    box-sizing: border-box; /* 确保padding不影响宽高 */
}

/* 我的图片消息 - 覆盖默认气泡颜色，保持图片占位符样式 */
.k-r.m .k-b-image {
    background: #e9e9e9;
    color: #555;
    border-bottom-right-radius: 6px;
}

/* 其他人图片消息 */
.k-r.v .k-b-image {
    border-bottom-left-radius: 6px;
}

/* 语音消息气泡 */
.k-b-voice {
    background: #ffffff;
    padding: 8px 12px;
    border-radius: 14px;
    max-width: 220px;
    word-wrap: break-word;
    font-size: 11px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 我的语音消息气泡 */
.k-r.m .k-b-voice {
    background: #fee500;
    border-bottom-right-radius: 4px;
}

/* 其他人的语音消息气泡 */
.k-r.v .k-b-voice {
    border-bottom-left-radius: 4px;
}

/* 语音条样式 */
.k-voice-bar {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 18px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.k-voice-bar:hover {
    background: rgba(0, 0, 0, 0.12);
}

/* 我的语音条 */
.k-r.m .k-voice-bar {
    background: rgba(0, 0, 0, 0.08);
}

.k-r.m .k-voice-bar:hover {
    background: rgba(0, 0, 0, 0.12);
}

/* 播放按钮 */
.k-voice-play {
    width: 14px;
    height: 14px;
    background: #4a4a4a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 7px;
    flex-shrink: 0;
}

/* 语音波形（装饰性） */
.k-voice-wave {
    flex: 1;
    height: 12px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 12"><rect x="2" y="5" width="1.5" height="2" fill="%23666"/><rect x="5" y="3" width="1.5" height="6" fill="%23666"/><rect x="8" y="2" width="1.5" height="8" fill="%23666"/><rect x="11" y="4" width="1.5" height="4" fill="%23666"/><rect x="14" y="3" width="1.5" height="6" fill="%23666"/><rect x="17" y="5" width="1.5" height="2" fill="%23666"/><rect x="20" y="3" width="1.5" height="6" fill="%23666"/><rect x="23" y="5" width="1.5" height="2" fill="%23666"/><rect x="26" y="2" width="1.5" height="8" fill="%23666"/><rect x="29" y="4" width="1.5" height="4" fill="%23666"/><rect x="32" y="3" width="1.5" height="6" fill="%23666"/><rect x="35" y="5" width="1.5" height="2" fill="%23666"/><rect x="38" y="3" width="1.5" height="6" fill="%23666"/><rect x="41" y="5" width="1.5" height="2" fill="%23666"/><rect x="44" y="2" width="1.5" height="8" fill="%23666"/><rect x="47" y="4" width="1.5" height="4" fill="%23666"/><rect x="50" y="3" width="1.5" height="6" fill="%23666"/><rect x="53" y="5" width="1.5" height="2" fill="%23666"/><rect x="56" y="3" width="1.5" height="6" fill="%23666"/><rect x="59" y="5" width="1.5" height="2" fill="%23666"/><rect x="62" y="2" width="1.5" height="8" fill="%23666"/><rect x="65" y="4" width="1.5" height="4" fill="%23666"/><rect x="68" y="3" width="1.5" height="6" fill="%23666"/><rect x="71" y="5" width="1.5" height="2" fill="%23666"/><rect x="74" y="3" width="1.5" height="6" fill="%23666"/><rect x="77" y="5" width="1.5" height="2" fill="%23666"/><rect x="80" y="2" width="1.5" height="8" fill="%23666"/><rect x="83" y="4" width="1.5" height="4" fill="%23666"/><rect x="86" y="3" width="1.5" height="6" fill="%23666"/><rect x="89" y="5" width="1.5" height="2" fill="%23666"/><rect x="92" y="3" width="1.5" height="6" fill="%23666"/><rect x="95" y="5" width="1.5" height="2" fill="%23666"/></svg>') center/contain no-repeat;
    opacity: 0.6;
}

/* 语音时长 */
.k-voice-duration {
    font-size: 9px;
    color: #666;
    flex-shrink: 0;
    font-weight: normal;
}

/* 语音转文字内容 */
.k-voice-text {
    font-size: 11px;
    line-height: 1.4;
    color: #333;
    margin-top: 2px;
}

/* 语音转文字前的小图标 */
.k-voice-text::before {
    content: " ";
    font-size: 9px;
    opacity: 0.7;
}

/* 错误消息 */
.k-error {
    background: #ffcdd2;
    color: #d32f2f;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    margin: 5px 0;
    text-align: center;
}

/* 如果需要滚动时的样式优化 */
.k-bd {
    overflow-x: hidden;
}

/* 平滑过渡效果 */
.k-r {
    transition: all 0.2s ease;
}

.k-b {
    transition: all 0.15s ease;
}

/* 响应式设计 */
@media (max-width: 400px) {
    .k-box {
        width: 100%;
        border-radius: 0;
        margin: 0;
    }
    
    .k-r {
        max-width: 85%;
    }
    
    .k-b {
        max-width: 280px;
    }
}

/* 自适应宽度支持 */
@media (min-width: 401px) {
    .k-box {
        max-width: 375px;
    }
}
