/* chat-module/chat-styles.css - 大厂风格升级版 */

/* 聊天容器 - 增加微信/钉钉背景色 */
.chat-module-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #F0F0F0; /* 微信风格背景色 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    overflow: hidden;
}

/* 聊天头部 - 微信风格 */
.chat-module-header {
    background: #FFFFFF;
    padding: 12px 16px;
    border-bottom: 1px solid #E5E5E5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-module-header-title {
    font-size: 17px;
    font-weight: 600;
    color: #000000;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-module-back-btn {
    background: none;
    border: none;
    color: #666666;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
}

.chat-module-back-btn:hover {
    color: #000000;
}

/* 信息栏 - 更紧凑 */
.chat-module-info-bar {
    background: #FFFFFF;
    padding: 10px 16px;
    border-bottom: 1px solid #F0F0F0;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
}

.chat-module-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-module-info-label {
    color: #666666;
    font-size: 12px;
}

.chat-module-info-value {
    color: #000000;
    font-weight: 500;
}

/* 消息区域 - 优化背景和滚动 */
.chat-module-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #F0F0F0;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

.chat-module-messages::-webkit-scrollbar {
    width: 4px; /* 更细的滚动条 */
}

.chat-module-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-module-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.chat-module-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* 欢迎消息 */
.chat-module-welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #999999;
    font-size: 14px;
}

/* 日期分隔符 - 微信风格 */
.chat-module-date-divider {
    text-align: center;
    margin: 16px 0;
    position: relative;
}

.chat-module-date-divider span {
    background: #F0F0F0;
    padding: 4px 12px;
    color: #999999;
    font-size: 11px;
    position: relative;
    z-index: 1;
    border-radius: 12px;
    border: 1px solid #E5E5E5;
}

.chat-module-date-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #E5E5E5;
    z-index: 0;
}

/* ========== 消息气泡全面升级 ========== */

/* 消息容器 */
.chat-module-message {
    margin: 6px 0;
    animation: fadeInUp 0.25s ease-out;
    display: flex;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 我的消息 - 右侧对齐，绿色气泡 */
.chat-module-message-my {
    justify-content: flex-end;
}

.chat-module-message-my .chat-module-message-bubble {
    background: #07C160; /* 绿色 */
    color: #FFFFFF;
    border-radius: 10px 6px 10px 10px;
    padding: 12px 12px;
    box-shadow: 0 1px 3px rgba(7, 193, 96, 0.3);
    max-width: 75%;
    position: relative;
    margin: 3px 0; 
}

/* 对方消息 - 左侧对齐，白色气泡 */
.chat-module-message-other {
    justify-content: flex-start;
}

.chat-module-message-other .chat-module-message-bubble {
    background: #FFFFFF;
    color: #000000;
    border-radius: 6px 10px 10px 10px;
    padding: 12px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    max-width: 75%;
    position: relative;
    margin: 3px 0;                      /* ← 减小外边距 */
}

/* 系统消息 */
.chat-module-message-system {
    justify-content: center;
    margin: 4px 0;
}

.chat-module-message-system .chat-module-message-bubble {
    background: rgba(0, 0, 0, 0.05);
    color: #666666;
    border-radius: 12px;
    padding: 6px 14px;
    display: inline-block;
    max-width: 80%;
    font-size: 12px;
}

/* 消息内容 */
.chat-module-message-content {
    font-size: 14px;
    line-height: 1.4;                   /* ← 减小行高 */
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;                   /* ← 强制左对齐 */
}

/* 强制消除所有可能的缩进和空格影响 */
.chat-module-message-content {
    text-align: left !important;
    line-height: 1.4 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    text-indent: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    /* 新增：处理文本内容的空白字符 */
    white-space-collapse: collapse !important;
    text-wrap-mode: wrap !important;
}

/* 针对首行的特殊处理 */
.chat-module-message-content::first-line {
    text-indent: 0 !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* 对方消息头像 - 应该是橙色 */
.chat-module-message-other::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #FF9500; /* 🔧 改为橙色 - 对方 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4' fill='white'/%3E%3Cpath fill='white' d='M12 14c-4.42 0-8 1.79-8 4v2h16v-2c0-2.21-3.58-4-8-4z'/%3E%3C/svg%3E");
    background-size: 16px;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 我的消息头像 - 应该是绿色 */
.chat-module-message-my::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #07C160; /* 🔧 改为绿色 - 自己 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4' fill='white'/%3E%3Cpath fill='white' d='M12 14c-4.42 0-8 1.79-8 4v2h16v-2c0-2.21-3.58-4-8-4z'/%3E%3C/svg%3E");
    background-size: 16px;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 为头像留出空间 */
.chat-module-message-other {
    position: relative;
    padding-left: 36px;
    margin-left: 0 !important;
}

.chat-module-message-my {
    position: relative;
    padding-right: 36px;
    margin-right: 0 !important;
}

/* 隐藏原来的发送者名字 */
.chat-module-sender-name {
    display: none;
}

/* 消息时间 - 风格 */
.chat-module-message-time {
    font-size: 10px !important;
    margin-top: 3px !important;  /* ← 从3px改为2px */
    margin-bottom: 0 !important;
    padding: 0 !important;
    opacity: 0.7 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 4px !important;
    line-height: 1 !important;
}

.chat-module-message-my .chat-module-message-time {
    color: rgba(255, 255, 255, 0.8);
}

.chat-module-message-other .chat-module-message-time {
    color: #999999;
    justify-content: flex-start;
}

/* 已读状态 - 微信的双勾 */
.chat-module-read-status {
    display: inline-flex;
    align-items: center;
}

.chat-module-read-status .unread {
    color: #FFFFFF;
}

.chat-module-read-status .read {
    color: #07C160;
}

/* 发送者名称 */
.chat-module-sender-name {
    font-size: 11px;
    color: #666666;
    margin-bottom: 4px;
    padding-left: 12px;
}

/* ========== 文件消息升级 ========== */
.chat-module-file-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    max-width: 280px;
    transition: all 0.2s ease;
}

.chat-module-file-message:hover {
    background: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-module-file-icon {
    font-size: 24px;
    color: #07C160; /* 微信绿色 */
    flex-shrink: 0;
}

.chat-module-file-info {
    flex: 1;
    min-width: 0;
}

.chat-module-file-name {
    font-weight: 500;
    font-size: 14px;
    color: #000000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-module-file-size {
    font-size: 11px;
    color: #999999;
    margin-top: 2px;
}

.chat-module-file-download {
    color: #07C160;
    text-decoration: none;
    font-size: 18px;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.chat-module-file-download:hover {
    background: rgba(7, 193, 96, 0.1);
}

/* ========== 图片消息升级 ========== */
.chat-module-image-message {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 200px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.chat-module-image-message:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.chat-module-image-message img {
    width: 100%;
    height: auto;
    display: block;
}

/* ========== 输入区域升级 ========== */
.chat-module-input-area {
    background: #FFFFFF;
    padding: 12px 16px;
    border-top: 1px solid #E5E5E5;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    position: sticky;
    bottom: 0;
    z-index: 100;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
}

.chat-module-input {
    flex: 1;
    border: 1px solid #E0E0E0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    background: #F5F5F5;
    min-height: 40px;
    max-height: 100px;
    font-family: inherit;
}

.chat-module-input:focus {
    border-color: #07C160;
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.1);
}

.chat-module-send-button {
    background: #07C160;
    color: #FFFFFF;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(7, 193, 96, 0.3);
    font-size: 18px;
    flex-shrink: 0;
}

.chat-module-send-button:hover {
    background: #06AB56;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.4);
}

.chat-module-send-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(7, 193, 96, 0.3);
}

.chat-module-send-button:disabled {
    background: #CCCCCC;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 底部状态栏 */
.chat-module-footer {
    background: #FFFFFF;
    padding: 8px 16px;
    border-top: 1px solid #F0F0F0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #999999;
}

.chat-module-connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.status-connected {
    color: #07C160;
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-connected::before {
    content: '●';
    font-size: 8px;
}

.status-connecting {
    color: #FAAD14;
}

.status-disconnected {
    color: #FF4D4F;
}

/* 空消息状态 */
.chat-module-empty-message {
    text-align: center;
    color: #999999;
    padding: 60px 20px;
    font-size: 14px;
}

/* 模态框动画 */
@keyframes modalFadeIn {
    from { 
        opacity: 0; 
        transform: translateY(-20px) scale(0.98); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .chat-module-container {
        height: calc(100vh - 60px);
    }
    
    .chat-module-header {
        padding: 10px 12px;
    }
    
    .chat-module-info-bar {
        padding: 8px 12px;
        gap: 12px;
        font-size: 12px;
    }
    
    .chat-module-messages {
        padding: 12px;
    }
    
    .chat-module-input-area {
        padding: 10px 12px;
    }
    
    .chat-module-message-bubble {
        max-width: 85%;
    }
    
    .chat-module-image-message {
        max-width: 180px;
    }
    
    .chat-module-file-message {
        max-width: 240px;
    }
}

/* 新增：消息加载动画 */
.chat-module-loading-messages {
    text-align: center;
    padding: 12px;
    color: #999999;
    font-size: 13px;
}

/* 新增：消息发送状态 */
.chat-module-message-status {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.7;
}

/* 新增：时间戳分隔线 */
.chat-module-timestamp {
    font-size: 11px;
    color: #999999;
    text-align: center;
    margin: 8px 0;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    display: inline-block;
    align-self: center;
}
