/* chat-sdk.css - 样式文件 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-sdk-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.chat-sdk-container a {
    color: inherit;
    text-decoration: none;
}

.chat-sdk-container button {
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.chat-widget {
    animation: slideIn 0.3s ease-out;
}

.chat-toggle-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.chat-toggle-btn:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2) !important;
}

.chat-toggle-btn:active {
    transform: scale(0.95) !important;
}

.notification-badge {
    animation: pulse 2s infinite;
}

.chat-header:hover {
    background: linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05));
}

.chat-send-btn:hover {
    filter: brightness(1.1) !important;
    transform: translateY(-1px);
}

.chat-send-btn:active {
    transform: translateY(0);
}

.chat-input:focus {
    border-color: #489775 !important;
    box-shadow: 0 0 0 2px rgba(24, 244, 25, 0.2);
}

.chat-body {
    scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.message {
    animation: fadeIn 0.3s ease;
}

.message.user .message-content {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #a7f3d0;
    color: #1f2937;
    position: relative;
}

.message.user .message-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid #489775;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.message.agent .message-content {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    color: #1f2937;
    position: relative;
}

.message.agent .message-content::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-right: 8px solid white;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.message.system .message-content {
    position: absolute;
    background: #f6ffed ;
    border: 1px solid #b7eb8f ;
    color: #135200 ;
    align-self: flex-start ;
    max-width: 95% ;
    text-align: center;
}

.message-content a {
    word-break: break-all;
}

.message-content a:hover {
    text-decoration: underline;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 18px;
    align-self: flex-start;
    margin-bottom: 8px;
    max-width: 85%;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 响应式设计 */
@media (max-width: 480px) {
    .chat-widget {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }

    .chat-body {
        height: calc(100vh - 140px) !important;
    }

    .chat-toggle-btn {
        width: 50px !important;
        height: 50px !important;
        bottom: 15px !important;
        right: 15px !important;
    }
}

/* 暗色主题支持 */
@media (prefers-color-scheme: dark) {
    .chat-widget {
        background: #1f1f1f !important;
        color: #e0e0e0 !important;
    }

    .chat-header {
        background: #262626 !important;
    }

    .chat-body {
        background: #141414 !important;
    }

    .chat-footer {
        background: #1f1f1f !important;
        border-top-color: #333 !important;
    }

    .chat-input {
        background: #262626 !important;
        border-color: #434343 !important;
        color: #e0e0e0 !important;
    }

    .message.agent .message-content {
        background: #262626 !important;
        border-color: #434343 !important;
        color: #e0e0e0 !important;
    }

    .message.agent .message-content::before {
        border-right-color: #262626 !important;
    }

    .message-meta {
        color: #8c8c8c !important;
    }

    .chat-body::-webkit-scrollbar-track {
        background: #262626;
    }

    .chat-body::-webkit-scrollbar-thumb {
        background: #434343;
    }

    .chat-body::-webkit-scrollbar-thumb:hover {
        background: #595959;
    }
}

/* ========================================
   渠道选择器样式
   ======================================== */

.channel-selector-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: channelFadeIn 0.3s ease;
}

.channel-selector {
    background: #ffffff;
    border-radius: 20px;
    padding: 28px 24px 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: channelSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.channel-selector-header {
    text-align: center;
    margin-bottom: 24px;
}

.channel-selector-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

/* 头像容器 - 覆盖原有的紫色渐变 */
.channel-selector-avatar {
    background: transparent !important; /* 去掉紫色背景 */
    box-shadow: none !important;
}

/* 头像图片 */
.channel-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 20px; /* 与容器圆角保持一致 */
    object-fit: cover;   /* 确保图片不变形铺满 */
    display: block;
}

.channel-selector-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 6px;
}

.channel-selector-subtitle {
    font-size: 14px;
    color: #718096;
    line-height: 1.5;
}

/* 渠道选项 */
.channel-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.channel-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    background: #fafbfc;
    position: relative;
    overflow: hidden;
}

.channel-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.channel-option.whatsapp::before {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.08), rgba(37, 211, 102, 0.02));
}

.channel-option.chat::before {
    background: linear-gradient(135deg, rgba(72, 151, 117, 0.08), rgba(72, 151, 117, 0.02));
}

.channel-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.channel-option.whatsapp:hover {
    border-color: #25D366;
}

.channel-option.chat:hover {
    border-color: #489775;
}

.channel-option:hover::before {
    opacity: 1;
}

.channel-option:active {
    transform: translateY(0);
}

.channel-option-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.channel-option-icon.whatsapp {
    background: #dcf8c6;
    color: #25D366;
}

.channel-option-icon.chat {
    background: #e8f5e9;
    color: #489775;
}

.channel-option-content {
    flex: 1;
    position: relative;
    z-index: 1;
}

.channel-option-label {
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 2px;
}

.channel-option-desc {
    font-size: 12px;
    color: #a0aec0;
    line-height: 1.4;
}

.channel-option-arrow {
    font-size: 18px;
    color: #cbd5e0;
    position: relative;
    z-index: 1;
    transition: all 0.25s ease;
}

.channel-option:hover .channel-option-arrow {
    transform: translateX(4px);
    color: #718096;
}

/* 记住选择 */
.channel-remember {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: #a0aec0;
    cursor: pointer;
    user-select: none;
}

.channel-remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #489775;
    cursor: pointer;
}

.channel-remember:hover {
    color: #718096;
}

/* 关闭按钮 */
.channel-selector-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f7fafc;
    color: #a0aec0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.channel-selector-close:hover {
    background: #edf2f7;
    color: #4a5568;
}

/* 动画 */
@keyframes channelFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes channelSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 响应式 */
@media (max-width: 480px) {
    .channel-selector {
        padding: 24px 16px 20px;
        border-radius: 16px;
    }

    .channel-selector-icon {
        width: 52px;
        height: 52px;
        font-size: 26px;
        border-radius: 16px;
    }

    .channel-option {
        padding: 14px;
        gap: 10px;
    }

    .channel-option-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
        border-radius: 12px;
    }
}