/* 在线客服小组件（前台访客侧）—— 原生 CSS，caschat- 前缀避免冲突 */

.caschat-btn {
    position: fixed;
    right: 20px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #07C160;
    box-shadow: 0 4px 14px rgba(7, 193, 96, .45);
    z-index: 99990;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, box-shadow .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.caschat-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 18px rgba(7, 193, 96, .55);
}

.caschat-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.caschat-panel {
    position: fixed;
    right: 20px;
    bottom: 92px;
    width: 340px;
    height: 480px;
    max-height: calc(100vh - 120px);
    background: #F5F5F5;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
    z-index: 99991;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Microsoft YaHei", sans-serif;
    text-align: left;
    line-height: 1.5;
}

.caschat-panel.caschat-open {
    display: flex;
}

/* 头部 */
.caschat-head {
    background: #07C160;
    color: #fff;
    padding: 12px 14px;
    font-weight: 500;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.caschat-head .caschat-head-title {
    display: flex;
    align-items: center;
    min-width: 0;
}

.caschat-head .caschat-head-sub {
    font-size: 12px;
    font-weight: 400;
    opacity: .85;
    margin-left: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.caschat-close {
    cursor: pointer;
    opacity: .85;
    font-size: 20px;
    line-height: 1;
    padding: 2px 4px;
}

.caschat-close:hover {
    opacity: 1;
}

/* 消息区 */
.caschat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    background: #F5F5F5;
    -webkit-overflow-scrolling: touch;
}

.caschat-time {
    text-align: center;
    color: #B2B2B2;
    font-size: 12px;
    margin: 8px 0 12px;
}

.caschat-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
}

.caschat-row.caschat-self {
    justify-content: flex-end;
}

.caschat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    flex: none;
    background: #fff;
    border: 1px solid #E8E8E8;
    box-sizing: border-box;
    object-fit: contain;
}

.caschat-avatar-space {
    width: 36px;
    flex: none;
}

.caschat-bubble {
    position: relative;
    max-width: 225px;
    padding: 9px 12px;
    border-radius: 5px;
    background: #fff;
    margin: 0 10px;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.caschat-bubble::before {
    content: "";
    position: absolute;
    top: 12px;
    border: 5px solid transparent;
}

.caschat-row .caschat-bubble::before {
    left: -9px;
    border-right-color: #fff;
}

.caschat-row.caschat-self .caschat-bubble {
    background: #95EC69;
}

.caschat-row.caschat-self .caschat-bubble::before {
    left: auto;
    right: -9px;
    border-right-color: transparent;
    border-left-color: #95EC69;
}

/* 图片 / 文件消息 */
.caschat-bubble.caschat-bubble-media {
    padding: 4px;
}

.caschat-msgimg {
    display: block;
    max-width: 180px;
    max-height: 180px;
    border-radius: 3px;
    cursor: zoom-in;
}

.caschat-file {
    display: flex;
    align-items: center;
    color: #333;
    text-decoration: none;
    padding: 5px 7px;
    min-width: 130px;
}

.caschat-file .fa {
    font-size: 20px;
    margin-right: 7px;
    color: #4A90D9;
}

.caschat-file:hover {
    text-decoration: none;
    background: rgba(0, 0, 0, .04);
    border-radius: 3px;
}

.caschat-filename {
    word-break: break-all;
    font-size: 13px;
}

/* 欢迎语气泡（仅客户端渲染，不落库） */
.caschat-welcome {
    color: #999;
    font-size: 12px;
    text-align: center;
    margin: 4px 0 12px;
}

/* 访客信息栏（首次可填称呼/联系方式） */
.caschat-info {
    display: none;
    flex: none;
    padding: 8px 10px;
    background: #F7F7F7;
    border-top: 1px solid #E5E5E5;
    gap: 6px;
}

.caschat-info.caschat-show {
    display: flex;
}

.caschat-info input {
    flex: 1;
    min-width: 0;
    border: 1px solid #E0E0E0;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.caschat-info input:focus {
    border-color: #07C160;
}

/* 底部输入条 */
.caschat-foot {
    flex: none;
    background: #F7F7F7;
    border-top: 1px solid #E5E5E5;
    padding: 8px 10px;
    display: flex;
    align-items: flex-end;
}

.caschat-input {
    flex: 1;
    min-width: 0;
    height: 56px;
    resize: none;
    border: none;
    outline: none;
    background: #fff;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
}

.caschat-send {
    flex: none;
    margin-left: 8px;
    background: #07C160;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity .15s ease;
}

.caschat-send:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.caschat-error {
    color: #FA5151;
    font-size: 12px;
    padding: 0 12px 6px;
    background: #F7F7F7;
    display: none;
    flex: none;
}

/* 移动端自适应 */
@media (max-width: 480px) {
    .caschat-btn {
        right: 14px;
        bottom: 16px;
        width: 52px;
        height: 52px;
    }

    .caschat-panel {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: 80px;
        height: 72vh;
        max-height: none;
    }
}
