/**
 * B2综合插件 - 聊天室小工具样式
 * 参考微信/Telegram设计风格
 */

/* 聊天室容器 */
.b2-zonghe-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 通知提示 */
.b2-zonghe-chat-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    animation: slideInRight 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
}

.b2-zonghe-chat-notification.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.b2-zonghe-chat-notification.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 消息列表容器 */
.b2-zonghe-chat-messages {
    background: #f5f7fa;
    border-radius: 0;
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.06);
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f5f7fa;
}

/* 自定义滚动条 - Chrome/Safari */
.b2-zonghe-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.b2-zonghe-chat-messages::-webkit-scrollbar-track {
    background: #f5f7fa;
    border-radius: 0;
}

.b2-zonghe-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 0;
}

.b2-zonghe-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 单条消息 */
.b2-zonghe-chat-item {
    display: block;
    background: #ffffff;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    animation: slideIn 0.3s ease-out;
    font-size: 14px;
    line-height: 1.6;
    position: relative;
}

.b2-zonghe-chat-item:last-child {
    margin-bottom: 0;
}

.b2-zonghe-chat-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* 用户名 */
.b2-zonghe-chat-item .username {
    font-weight: 600;
    color: #1f2937;
    margin-right: 8px;
}

.b2-zonghe-chat-item .message-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}


/* 消息内容 */
.b2-zonghe-chat-item .message {
    color: #4b5563;
    word-wrap: break-word;
    word-break: break-all;
    flex: 1;
    min-width: 0;
}

/* 留言时间 */
.b2-zonghe-chat-item .time {
    font-size: 12px;
    color: #9ca3af;
    text-align: right;
    align-self: flex-end;
    padding-left: 12px;
}



/* 输入区域 */
.b2-zonghe-chat-input {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
}

.b2-zonghe-chat-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    background: #f9fafb;
    resize: vertical;
    transition: all 0.2s ease;
    font-family: inherit;
}

.b2-zonghe-chat-textarea:focus {
    outline: none;
    border-color: var(--b2-chat-primary, #667eea);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--b2-chat-primary-alpha, rgba(102, 126, 234, 0.1));
}

.b2-zonghe-chat-textarea::placeholder {
    color: #9ca3af;
}

/* 发送按钮 */
.b2-zonghe-chat-submit {
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--b2-chat-primary, #667eea) 0%, var(--b2-chat-secondary, #764ba2) 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    margin-left: auto;
}

.b2-zonghe-chat-submit:hover {
    background: linear-gradient(135deg, var(--b2-chat-primary, #667eea) 0%, var(--b2-chat-secondary, #764ba2) 100%);
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.b2-zonghe-chat-submit:active {
    filter: brightness(0.95);
}

.b2-zonghe-chat-submit:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    box-shadow: none;
}

/* 聊天室下方自定义文本 */
.b2-zonghe-chat-custom-text {
    margin-top: 16px;
    padding: 12px 16px;
    background: #f9fafb;
    border-left: 3px solid var(--b2-chat-primary, #667eea);
    border-radius: 4px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.6;
}

.b2-zonghe-chat-custom-text:empty {
    display: none;
}

/* 动画效果 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 滚动时的动画 */
.b2-zonghe-chat-messages.scrolling {
    animation: none;
}

/* 暂无留言提示 */
.b2-zonghe-chat-list .empty-message {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
    background: #ffffff;
    border-radius: 12px;
    border: 2px dashed #e5e7eb;
}

.b2-zonghe-chat-list .empty-message::before {
    content: '💬';
    display: block;
    font-size: 48px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

/* 加载状态 */
.b2-zonghe-chat-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.b2-zonghe-chat-loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .b2-zonghe-chat-messages {
        max-height: 300px;
        padding: 12px;
    }

    .b2-zonghe-chat-item {
        padding: 10px 12px;
        margin-bottom: 8px;
    }

    .b2-zonghe-chat-input {
        padding: 12px;
    }

    .b2-zonghe-chat-textarea {
        min-height: 60px;
        font-size: 14px;
    }

    .b2-zonghe-chat-input-toolbar {
        flex-wrap: nowrap;
    }

    .b2-zonghe-chat-submit {
        padding: 10px 16px;
        font-size: 14px;
        flex: 1;
    }

    .b2-zonghe-chat-emoji-btn {
        padding: 4px 8px;
        font-size: 20px;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .b2-zonghe-chat-messages {
        background: #1f2937;
        box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
        scrollbar-color: #4b5563 #1f2937;
    }

    .b2-zonghe-chat-messages::-webkit-scrollbar-track {
        background: #1f2937;
    }

    .b2-zonghe-chat-messages::-webkit-scrollbar-thumb {
        background: #4b5563;
    }

    .b2-zonghe-chat-item {
        background: #374151;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }

    .b2-zonghe-chat-item:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .b2-zonghe-chat-item .username {
        color: #f3f4f6;
    }

    .b2-zonghe-chat-item .message {
        color: #e5e7eb;
        background: linear-gradient(135deg, #667eea20 0%, #764ba220 100%);
    }

    .b2-zonghe-chat-item .time {
        color: #9ca3af;
    }

    .b2-zonghe-chat-input {
        background: #374151;
    }

    .b2-zonghe-chat-textarea {
        background: #1f2937;
        border-color: #4b5563;
        color: #e5e7eb;
    }

    .b2-zonghe-chat-textarea:focus {
        border-color: #667eea;
        background: #374151;
    }

    .b2-zonghe-chat-textarea::placeholder {
        color: #6b7280;
    }

    /* 表情选择器暗色模式 */
    .b2-zonghe-chat-emoji-picker {
        background: #374151;
        border-color: #4b5563;
    }

    .b2-zonghe-chat-emoji-item:hover {
        background: #4b5563;
    }
}

/* 表情选择器工具栏 - 放在发送按钮和表情按钮之间 */
.b2-zonghe-chat-input-toolbar {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 10;
    width: 100%;
}

/* 表情按钮容器 */
.b2-zonghe-chat-emoji-btn-wrapper {
    position: relative;
    z-index: 20;
}

.b2-zonghe-chat-emoji-btn {
    background: transparent;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 22px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.b2-zonghe-chat-emoji-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.b2-zonghe-chat-emoji-btn:active {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(0.95);
}

/* 表情选择器 - 相对于表情按钮wrapper定位 */
.b2-zonghe-chat-emoji-picker {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 320px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 10px;
    z-index: 30;
    max-height: 320px;
    overflow-y: auto;
    user-select: none;
    display: none;
}

/* 当表情选择器显示时 */
.b2-zonghe-chat-emoji-picker.show {
    display: block;
}

/* 表情网格 - 使用grid布局实现横排 */
.b2-zonghe-chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    width: 100%;
}

/* 表情项 */
.b2-zonghe-chat-emoji-item {
    font-size: 20px;
    text-align: center;
    padding: 4px 2px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    line-height: 1;
    height: 32px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
}

/* 调试：高亮表情网格边界 */
.b2-zonghe-chat-emoji-grid {
    background: #f9fafb;
    border: 1px dashed #ddd;
    padding: 6px;
    border-radius: 4px;
}

.b2-zonghe-chat-emoji-item {
    background: #fff;
    border: 1px solid #eee;
}

.b2-zonghe-chat-emoji-item:hover {
    background: #f5f5f5;
    transform: scale(1.1);
}

.b2-zonghe-chat-emoji-item:active {
    background: #e8e8e8;
    transform: scale(0.95);
}

/* 表情选择器滚动条 */
.b2-zonghe-chat-emoji-picker::-webkit-scrollbar {
    width: 6px;
}

.b2-zonghe-chat-emoji-picker::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.b2-zonghe-chat-emoji-picker::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 3px;
}

.b2-zonghe-chat-emoji-picker::-webkit-scrollbar-thumb:hover {
    background: #b8b8b8;
}
