/* ========== 模态框聊天消息样式 ========== */
/* 参考chat.css的消息布局结构 */
.jl-modal-message {
    margin: 4px 0;
    padding: 8px;
    border-radius: 8px;
    animation: fadeInDown 0.3s ease-out;
}

/* 左右分布样式 */
.jl-modal-message.message-self {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
}

.jl-modal-message.message-other {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
}

/* 消息包装器 */
.jl-modal-message .message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 80%; /* 增加最大宽度，给消息更多空间 */
    width: fit-content;
}

.jl-modal-message.message-self .message-wrapper {
    flex-direction: row !important;
    justify-content: flex-end !important;
    margin-left: 20%; /* 增加左边距，更明显的右对齐 */
    margin-right: 0;
}

.jl-modal-message.message-other .message-wrapper {
    flex-direction: row !important;
    justify-content: flex-start !important;
    margin-left: 0;
    margin-right: 20%; /* 增加右边距，更明显的左对齐 */
}

/* 强化自己消息的右对齐 */
.jl-modal-message.message-self .message-content-area {
    order: 1;
}

.jl-modal-message.message-self .message-avatar {
    order: 2;
}

.jl-modal-message.message-other .message-avatar {
    order: 1;
}

.jl-modal-message.message-other .message-content-area {
    order: 2;
}

/* 消息内容区域 */
.jl-modal-message .message-content-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

/* 消息头部 */
.jl-modal-message .message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.75rem;
    opacity: 0.7;
    margin-bottom: 2px;
    min-height: 26px;
    line-height: 1.2;
}

.jl-modal-message .message-user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

/* 自己消息的头部布局 */
.jl-modal-message.message-self .message-header {
    color: #6c757d;
    flex-direction: row-reverse;
}

.jl-modal-message.message-self .message-user-info {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

/* 他人消息的头部布局 */
.jl-modal-message.message-other .message-header {
    color: #6c757d;
}

.jl-modal-message.message-other .message-user-info {
    justify-content: flex-start;
}

/* 头像样式 */
.jl-modal-message .message-avatar {
    flex-shrink: 0;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #dee2e6;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
    align-self: flex-start;
}

.jl-modal-message .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.jl-modal-message .message-avatar:hover img {
    transform: scale(1.1);
}

/* 消息气泡 */
.jl-modal-message .message-bubble {
    border-radius: 10px;
    padding: 8px 12px;
    position: relative;
    border: 1px solid #dee2e6;
    min-width: 30px;
    max-width: 100%;
    width: fit-content;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    font-size: 1rem;
}

/* 自己消息的气泡：浅蓝色 */
.jl-modal-message.message-self .message-bubble {
    background: #f0f8ff !important;
    color: #495057;
    border-color: #cce7ff;
    margin-left: auto;
    text-align: left !important;
}

/* 他人消息的气泡：白色 */
.jl-modal-message.message-other .message-bubble {
    background: #ffffff !important;
    color: #495057;
    border-color: #dee2e6;
    margin-right: auto;
}

/* 消息内容 */
.jl-modal-message .message-content {
    font-size: 1rem;
    line-height: 1.4;
    word-break: break-word;
    margin: 0;
    text-align: left !important;
    direction: ltr;
}

/* 用户名样式 */
.jl-modal-message .message-user {
    font-weight: 600;
    font-size: 0.8rem;
    color: #6c757d;
}

/* 时间样式 */
.jl-modal-message .message-time {
    font-size: 0.75rem;
    opacity: 0.6;
    color: #6c757d;
}

/* 保留旧样式类名以兼容现有代码 */
.jl-modal-message.self {
    flex-direction: row-reverse;
}

.jl-modal-message .jl-message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e8e8e8;
}

.jl-modal-message .jl-message-content {
    max-width: 80%; /* 增加最大宽度，与新样式保持一致 */
    display: flex;
    flex-direction: column;
}

.jl-modal-message.self .jl-message-content {
    align-items: flex-end;
}

.jl-modal-message .jl-message-bubble {
    background: #f5f5f5;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    margin-bottom: 5px;
    border: 1px solid #e8e8e8;
}

.jl-modal-message .jl-message-bubble.self {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.jl-modal-message .jl-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

/* 添加fadeInDown动画 */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ========== 聊天区域样式 ========== */
.jl-chat-area {
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    height: 500px;
}

.jl-chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
}

.jl-chat-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.jl-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
}

.jl-chat-name {
    font-weight: 500;
    color: #333;
    font-size: 15px;
}

.jl-chat-status {
    font-size: 12px;
    color: #999;
}

.jl-chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: #f8f8f8;
}

.jl-message {
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 100%;
    animation: slideIn 0.3s ease;
}

.jl-message.self {
    flex-direction: row-reverse;
    justify-content: flex-start;
    margin-left: 15%; /* 适度的左边距，保持右对齐但不过度压缩 */
    margin-right: 0;
}

/* 好友消息左对齐 */
.jl-message:not(.self) {
    justify-content: flex-start;
    margin-left: 0;
    margin-right: 15%; /* 适度的右边距，保持左对齐但不过度压缩 */
}

.jl-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
}

.jl-message-content {
    max-width: 75%; /* 增加最大宽度，给消息更多空间 */
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.jl-message-bubble {
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    border: 1px solid #e8e8e8;
}

.jl-message.self .jl-message-bubble {
    background: #1890ff;
    color: white;
    border: 1px solid #1890ff;
}

.jl-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.jl-message.self .jl-message-time {
    text-align: right;
}

.jl-chat-input {
    padding: 12px 16px;
    border-top: 1px solid #e8e8e8;
    background: white;
}

.jl-chat-input .input-group {
    border: 1px solid #e8e8e8;
    border-radius: 20px;
    overflow: hidden;
}

.jl-chat-input .form-control {
    border: none;
    padding: 8px 16px;
    outline: none;
    box-shadow: none;
}

.jl-chat-input .btn {
    border: none;
    padding: 8px 16px;
    background: #1890ff;
    color: white;
}


/* ========== 聊天模态框样式 ========== */
.jl-chat-modal {
    border-radius: 12px;
    border: none;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    background: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.jl-chat-modal-header {
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
    border-bottom: 1px solid #e8e8e8;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
}

.jl-chat-modal-header .jl-chat-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jl-chat-modal-header .jl-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

/* 让模态框头部的在线点显示在头像右下角 */
.jl-chat-modal-header .jl-avatar-wrap { position: relative; }
.jl-chat-modal-header .jl-status-dot { right: -2px; bottom: -2px; }

.jl-chat-modal-header .jl-chat-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
}

.jl-chat-modal-header .jl-chat-status {
    font-size: 0.85rem;
    color: #666;
}

.jl-chat-modal-body {
    padding: 0;
    height: 500px;
    overflow: hidden;
    position: relative; /* 让回到底部按钮绝对定位到此容器内 */
}

.jl-chat-modal-body .jl-chat-messages {
    height: 100%;
    padding: 20px;
    overflow-y: auto;
    background: #f8f8f8;
}

/* 回到底部悬浮按钮 */
.jl-scroll-bottom-btn {
    position: absolute;
    right: 16px;
    bottom: 76px; /* 避开底部输入区 */
    padding: 8px 12px;
    border-radius: 16px;
    border: 1px solid rgba(24,144,255,0.25);
    background: #1890ff;
    color: #fff;
    font-size: 12px;
    box-shadow: 0 6px 18px rgba(24,144,255,0.35);
    transition: transform .15s ease, opacity .15s ease;
}

.jl-scroll-bottom-btn:hover {
    transform: translateY(-1px);
}

.jl-chat-modal-footer {
    border-top: 1px solid #e8e8e8;
    background: white;
    padding: 16px 20px;
    border-radius: 0 0 12px 12px;
}

.jl-chat-modal-footer .input-group {
    border: 1px solid #e8e8e8;
    border-radius: 20px;
    overflow: hidden;
}

.jl-chat-modal-footer .form-control {
    border: none;
    padding: 10px 16px;
    outline: none;
    box-shadow: none;
}

.jl-chat-modal-footer .btn {
    border: none;
    padding: 10px 20px;
    background: #1890ff;
    color: white;
}

/* 模态框响应式 */
@media (max-width: 767px) {
    .jl-chat-modal .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .jl-chat-modal-body {
        height: 400px;
    }
}
