/**
 * 聊天窗口样式 - 绿色简洁风格
 */

/* 聊天窗口遮罩层 */
.onlinelive-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483647 !important; /* 最高优先级，确保在移动端图标之上 */
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.onlinelive-chat-overlay.active {
    display: flex;
}

/* 聊天窗口主容器 */
.onlinelive-chat-window {
    width: 90%;
    max-width: 800px;
    height: 85vh;
    max-height: 700px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    min-height: 0;
    margin: 0;
    padding: 0;
    position: relative;
    box-sizing: border-box; /* 确保 padding 不影响尺寸 */
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 顶部标题栏 */
.onlinelive-chat-header {
    background: #10b981;
    color: #ffffff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    flex-grow: 0;
    position: relative;
    z-index: 10005;
    min-height: 56px;
    height: auto;
}

.onlinelive-chat-back {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    /* 移动端：确保按钮可点击 */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
}

.onlinelive-chat-back:hover {
    background: rgba(255, 255, 255, 0.1);
}

.onlinelive-chat-back:active {
    background: rgba(255, 255, 255, 0.2);
}

.onlinelive-chat-header-avatar {
    flex-shrink: 0;
}

.onlinelive-chat-avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #10b981;
    overflow: hidden;
}

.onlinelive-chat-avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.onlinelive-chat-header-info {
    flex: 1;
    min-width: 0;
    overflow: hidden; /* 确保子元素单行截断生效 */
}

.onlinelive-chat-header-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.onlinelive-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.onlinelive-chat-menu {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.onlinelive-chat-menu:hover {
    background: rgba(255, 255, 255, 0.1);
}

.onlinelive-chat-menu:active {
    background: rgba(255, 255, 255, 0.2);
}

/* 消息显示区域 */
.onlinelive-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f9fafb;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.onlinelive-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 消息项 */
.onlinelive-chat-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 75%;
}

.onlinelive-chat-message-left {
    align-self: flex-start;
}

.onlinelive-chat-message-right {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* 消息头像 */
.onlinelive-chat-message-avatar {
    flex-shrink: 0;
}

.onlinelive-chat-avatar-circle-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #10b981;
    overflow: hidden;
}

.onlinelive-chat-avatar-circle-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 用户头像（绿色圆形，白色字母） */
.onlinelive-user-avatar {
    background: #10b981 !important;
    color: #ffffff !important;
    border: none !important;
    font-weight: 600;
    font-size: 14px;
}

/* 消息气泡 */
.onlinelive-chat-message-bubble {
    background: #ffffff;
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.onlinelive-chat-message-bubble-right {
    background: #10b981;
    color: #ffffff;
    border: none;
}

.onlinelive-chat-message-name {
    font-size: 12px;
    font-weight: 600;
    color: #10b981;
    margin-bottom: 4px;
}

.onlinelive-chat-message-text {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
    color: #374151;
}

.onlinelive-chat-message-bubble-right .onlinelive-chat-message-text {
    color: #ffffff;
}

/* 消息内链接：可点击，新窗口打开 */
.onlinelive-chat-message-text .chat-message-link {
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
    word-break: break-all;
}
.onlinelive-chat-message-bubble-right .chat-message-link {
    color: rgba(255,255,255,0.95);
}
.onlinelive-chat-message-bubble:not(.onlinelive-chat-message-bubble-right) .chat-message-link {
    color: #059669;
}

/* 本站链接预览卡片：缩略图 + 标题 + 链接，点击名称或图片可打开链接 */
.onlinelive-chat-link-preview {
    display: flex;
    align-items: stretch;
    margin-bottom: 8px;
    padding: 0;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    max-width: 300px;
    cursor: pointer;
}
.onlinelive-chat-link-preview:hover {
    border-color: #059669;
    background: #ecfdf5;
}
.onlinelive-chat-link-preview:hover .onlinelive-chat-link-preview-title {
    color: #047857;
}
.onlinelive-chat-link-preview-img {
    width: 90px;
    min-height: 60px;
    flex-shrink: 0;
    background: #e5e7eb;
}
.onlinelive-chat-link-preview-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.onlinelive-chat-link-preview-body {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.onlinelive-chat-link-preview-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.onlinelive-chat-link-preview-url {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 表情消息样式 - 显示大一号 */
.onlinelive-chat-message-emoji {
    font-size: 32px !important;
    line-height: 1.2 !important;
    text-align: center;
    padding: 4px 0;
}

/* 临时消息样式（发送中） */
.onlinelive-chat-message.temp-message {
    opacity: 0.7;
    transition: opacity 0.3s;
}

/* 点赞消息 */
.onlinelive-chat-like-message {
    font-size: 24px;
    padding: 8px;
    text-align: center;
}

/* 图片消息 */
.onlinelive-chat-message-image {
    margin: -10px -14px;
    position: relative;
}

.onlinelive-chat-message-image img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* 文件消息 */
.onlinelive-chat-message-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    max-width: 300px;
    transition: background 0.2s ease;
    margin: -10px -14px;
}

.onlinelive-chat-message-file:hover {
    background: rgba(255, 255, 255, 0.15);
}

.onlinelive-chat-message-bubble-right .onlinelive-chat-message-file {
    background: rgba(255, 255, 255, 0.2);
}

.onlinelive-chat-message-bubble-right .onlinelive-chat-message-file:hover {
    background: rgba(255, 255, 255, 0.25);
}

.onlinelive-chat-message-file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.onlinelive-chat-message-file-link {
    color: #ffffff;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    font-size: 14px;
}

.onlinelive-chat-message-bubble:not(.onlinelive-chat-message-bubble-right) .onlinelive-chat-message-file-link {
    color: #374151;
}

/* 缩略图样式 */
.onlinelive-chat-image-thumbnail {
    max-width: 150px !important;
    max-height: 150px !important;
    width: auto;
    height: auto;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.onlinelive-chat-image-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* 图片加载失败提示 */
.onlinelive-image-error {
    color: #999;
    padding: 10px;
    font-size: 12px;
    text-align: center;
    background: #f5f5f5;
    border-radius: 8px;
}

/* 图片预览层：必须在聊天窗口之上，浏览器正中间 */
.onlinelive-image-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2147483647 !important; /* 与聊天窗口同值，预览后插入 DOM 故显示在上层，勿改小否则会被聊天窗口挡住 */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.onlinelive-image-preview-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    display: block;
    /* 直接显示图片，无白色画布效果，图片大小适应浏览器窗口 */
}

/* 底部输入区域 */
.onlinelive-chat-footer {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    flex-shrink: 0;
    flex-grow: 0;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 10002;
    min-height: auto;
    height: auto;
}

.onlinelive-chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.onlinelive-chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 14px;
    font-size: 14px;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.onlinelive-chat-input:focus {
    outline: none;
    border-color: #10b981;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.onlinelive-chat-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.onlinelive-chat-tool-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    color: #6b7280;
}

.onlinelive-chat-tool-btn:hover {
    background: #f3f4f6;
}

.onlinelive-chat-tool-btn:active {
    background: #e5e7eb;
}

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

.onlinelive-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.onlinelive-chat-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.onlinelive-chat-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .onlinelive-chat-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 2147483647 !important; /* 最高优先级，确保在移动端图标（2147483000）之上 */
    }
    
    .onlinelive-chat-overlay.active {
        display: flex !important;
    }
    
    .onlinelive-chat-window {
        width: 90% !important;
        max-width: 500px !important;
        height: 80vh !important;
        max-height: 600px !important;
        border-radius: 12px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        position: relative !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
    }
    
    .onlinelive-chat-header {
        flex-shrink: 0 !important;
        min-height: 56px !important;
        height: auto !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    /* 手机端：公司名称栏限制一行显示 */
    .onlinelive-chat-header-name {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
    
    .onlinelive-chat-header-subtitle {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
    
    .onlinelive-chat-body {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .onlinelive-chat-footer {
        flex-shrink: 0 !important;
        height: auto !important;
        border-radius: 0 0 12px 12px !important;
    }
    
    .onlinelive-chat-message {
        max-width: 85%;
    }
    
    .onlinelive-chat-message-image img {
        max-width: 150px;
        max-height: 150px;
    }
}

@media (max-width: 480px) {
    .onlinelive-chat-window {
        width: 95% !important;
        height: 85vh !important;
        max-height: 600px !important;
        border-radius: 12px !important;
    }
}

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

.onlinelive-chat-message {
    animation: fadeIn 0.3s ease;
}

/* 表情选择器 */
.onlinelive-emoji-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    max-height: 300px;
    overflow-y: auto;
    display: none !important;
    z-index: 10003;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    -webkit-overflow-scrolling: touch;
    margin-bottom: 8px;
}

.onlinelive-emoji-picker.active {
    display: block !important;
}

.onlinelive-emoji-picker-content {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 12px;
}

.onlinelive-emoji-item {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    background: transparent;
    user-select: none;
}

.onlinelive-emoji-item:hover {
    background: #f3f4f6;
    transform: scale(1.1);
}

.onlinelive-emoji-item:active {
    background: #e5e7eb;
    transform: scale(0.95);
}

.onlinelive-chat-tool-btn.active {
    background: #10b981;
    color: #ffffff;
}

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

.onlinelive-emoji-picker::-webkit-scrollbar-track {
    background: #f9fafb;
}

.onlinelive-emoji-picker::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.onlinelive-emoji-picker::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}
