/**
 * 公共聊天室样式
 */

/* 聊天窗口容器 - 右侧浮窗，底部对齐，自适应高度 */
.chat-widget {
    position: fixed;
    right: 10px;
    bottom: 10px;
    top: auto;
    width: 190px;
    /* 最大高度 = 视窗高度 - 道具栏下方位置(350px) - 底部边距(10px) */
    max-height: calc(100vh - 360px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    animation: chatSlideIn 0.3s ease-out;
}

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

/* 聊天头部 */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.chat-header:hover {
    opacity: 0.95;
}

.chat-title {
    font-size: 12px;
    font-weight: bold;
}

.chat-toggle {
    font-size: 14px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: background 0.2s;
}

.chat-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 聊天主体 */
.chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* 消息列表区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    min-height: 150px;
    max-height: 200px;
    background: #f8f9fa;
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 加载中提示 */
.chat-loading {
    text-align: center;
    color: #888;
    padding: 20px;
    font-size: 13px;
}

/* 空消息提示 */
.chat-empty {
    text-align: center;
    color: #888;
    padding: 40px 20px;
    font-size: 13px;
}

/* 单条消息 */
.chat-message {
    margin-bottom: 8px;
    padding: 6px 8px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 自己的消息 */
.chat-message-me {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

/* 消息头部 */
.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-username {
    font-size: 10px;
    font-weight: bold;
    color: #667eea;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-message-me .chat-username {
    color: #2e7d32;
}

.chat-time {
    font-size: 9px;
    color: #999;
}

/* 消息内容 */
.chat-message-content {
    font-size: 11px;
    color: #333;
    line-height: 1.4;
    word-break: break-word;
}

/* 加载更多按钮 */
.chat-load-more {
    padding: 8px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.chat-load-more-btn {
    background: transparent;
    border: 1px solid #667eea;
    color: #667eea;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-load-more-btn:hover {
    background: #667eea;
    color: white;
}

.chat-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 输入区域 - 窄版垂直布局 */
.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    background: white;
    border-top: 1px solid #eee;
}

.chat-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 11px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.chat-input:focus {
    border-color: #667eea;
}

.chat-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 100%;
    padding: 6px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

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

/* 响应式样式 */

/* 平板端 - 聊天室位于右侧边栏下方 */
@media (max-width: 1024px) {
    .chat-widget {
        width: 180px;
        right: 5px;
        bottom: 10px;
        top: auto;
        max-height: calc(100vh - 320px);
    }
    
    .chat-messages {
        min-height: 120px;
        max-height: 180px;
    }
    
    .chat-header {
        padding: 8px 10px;
    }
    
    .chat-title {
        font-size: 12px;
    }
    
    .chat-input-area {
        flex-direction: column;
        gap: 5px;
        padding: 8px;
    }
    
    .chat-input {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .chat-send-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* 手机端 - 聊天室移到底部 */
@media (max-width: 767px) {
    .chat-widget {
        width: calc(100% - 20px);
        max-width: 320px;
        right: 10px;
        top: auto;
        bottom: 10px;
        max-height: 350px;
    }
    
    .chat-messages {
        min-height: 120px;
        max-height: 180px;
    }
    
    .chat-input-area {
        flex-direction: row;
        gap: 8px;
        padding: 8px;
    }
    
    .chat-input {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .chat-send-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* 非常小的手机 */
@media (max-width: 375px) {
    .chat-widget {
        width: calc(100% - 16px);
        right: 8px;
        bottom: 8px;
    }
}
