/**
 * Woo Live Chat - 访客端样式 v3.2
 * 极简黑白UI - 48px边框按钮
 */

:root {
    --wlc-bg: #ffffff;
    --wlc-border: #e5e5e5;
    --wlc-text: #333333;
    --wlc-primary: #000000;
    --wlc-secondary: #666666;
    --wlc-light: #f5f5f5;
    --wlc-radius: 8px;
    --wlc-height: 48px;
    --wlc-transition: all 0.2s ease;
}

/* ========== 重置默认样式 ========== */
.wlc-widget,
.wlc-widget * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========== 聊天气泡按钮 ========== */
.wlc-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 999998;
}

.wlc-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--wlc-primary) !important;
    color: white !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--wlc-transition);
    border: 2px solid var(--wlc-primary) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wlc-bubble:hover {
    transform: scale(1.05);
}

.wlc-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c !important;
    color: white !important;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white !important;
}

/* 抖动动画 */
@keyframes wlc-shake {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(-12deg) scale(1.1); }
    20% { transform: rotate(12deg) scale(1.1); }
    30% { transform: rotate(-10deg) scale(1.05); }
    40% { transform: rotate(10deg) scale(1.05); }
    50% { transform: rotate(-6deg); }
    60% { transform: rotate(6deg); }
    70% { transform: rotate(-3deg); }
    80% { transform: rotate(3deg); }
    90% { transform: rotate(0deg); }
}

.wlc-bubble.wlc-shake {
    animation: wlc-shake 0.8s ease-in-out;
}

/* 未读消息时持续轻微抖动提醒 */
.wlc-bubble.wlc-has-unread {
    animation: wlc-gentle-shake 2s ease-in-out infinite;
}

@keyframes wlc-gentle-shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

/* 移动端隐藏聊天气泡（默认） */
@media (max-width: 768px) {
    .wlc-bubble {
        display: none !important;
    }
    
    /* 移动端有未读消息时显示气泡 */
    .wlc-bubble.wlc-has-unread {
        display: flex !important;
        bottom: 80px;
    }
}

/* ========== 聊天窗口 ========== */
.wlc-chat-window {
    position: fixed;
    bottom: 166px;
    right: 24px;
    width: 380px;
    min-height: 480px;
    max-height: calc(100vh - 200px);
    height: auto;
    background: var(--wlc-bg) !important;
    border-radius: 12px;
    border: 2px solid var(--wlc-border) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wlc-slide-up 0.25s ease;
}

/* 移动端全屏 */
@media (max-width: 768px) {
    .wlc-widget {
        bottom: 16px !important;
        right: 16px !important;
    }

    .wlc-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        z-index: 999999 !important;
    }
}

@keyframes wlc-slide-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 头部 */
.wlc-window-header {
    padding: 16px 20px;
    border-bottom: 2px solid var(--wlc-border) !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--wlc-bg) !important;
}

.wlc-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wlc-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--wlc-text) !important;
}

.wlc-header-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--wlc-secondary);
}

.wlc-online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: wlc-pulse 2s infinite;
}

@keyframes wlc-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.wlc-social-links {
    display: flex;
    gap: 8px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--wlc-border);
}

.wlc-social-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wlc-secondary);
    transition: var(--wlc-transition);
    border-radius: 4px;
}

.wlc-social-icon:hover {
    color: var(--wlc-primary);
    background: var(--wlc-light);
}

.wlc-social-whatsapp:hover {
    color: #25D366 !important;
}

.wlc-social-telegram:hover {
    color: #0088cc !important;
}

.wlc-social-messenger:hover {
    color: #006AFF !important;
}

.wlc-social-email:hover {
    color: #EA4335 !important;
}

.wlc-social-instagram:hover {
    color: #E4405F !important;
}

.wlc-social-tiktok:hover {
    color: #000 !important;
}

.wlc-social-icon svg {
    width: 16px;
    height: 16px;
}

/* 关闭按钮 */
.wlc-close-btn {
    width: var(--wlc-height) !important;
    height: var(--wlc-height) !important;
    min-width: var(--wlc-height) !important;
    min-height: var(--wlc-height) !important;
    border: 2px solid var(--wlc-border) !important;
    background: var(--wlc-bg) !important;
    border-radius: var(--wlc-radius) !important;
    cursor: pointer;
    font-size: 18px;
    color: var(--wlc-text) !important;
    transition: var(--wlc-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
}

.wlc-close-btn:hover {
    border-color: var(--wlc-primary) !important;
    background: var(--wlc-light) !important;
}

/* ========== 消息区域 ========== */
.wlc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--wlc-light) !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.wlc-message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wlc-message-visitor {
    align-self: flex-end;
}

.wlc-message-agent,
.wlc-message-system {
    align-self: flex-start;
}

.wlc-message-bubble {
    padding: 12px 16px;
    border-radius: var(--wlc-radius);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    border: 2px solid var(--wlc-border) !important;
}

.wlc-message-agent .wlc-message-bubble {
    background: var(--wlc-bg) !important;
    color: var(--wlc-text) !important;
}

.wlc-message-visitor .wlc-message-bubble {
    background: var(--wlc-primary) !important;
    color: white !important;
    border-color: var(--wlc-primary) !important;
}

.wlc-message-system .wlc-message-bubble {
    background: transparent !important;
    border: none !important;
    color: var(--wlc-secondary) !important;
    font-size: 12px;
    text-align: center;
    padding: 8px;
}

.wlc-message-time {
    font-size: 10px;
    color: var(--wlc-secondary) !important;
    padding: 0 4px;
}

.wlc-message-visitor .wlc-message-time {
    text-align: right;
}

/* 翻译内容样式 */
.wlc-translated-content {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--wlc-border);
    font-size: 13px;
    color: var(--wlc-secondary);
    line-height: 1.5;
}

.wlc-translated-label {
    font-size: 11px;
    opacity: 0.8;
}

/* 图片消息 */
.wlc-message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--wlc-radius);
    border: 2px solid var(--wlc-border) !important;
    cursor: pointer;
}

/* 卡片 */
.wlc-card {
    background: var(--wlc-bg) !important;
    border: 2px solid var(--wlc-border) !important;
    border-radius: var(--wlc-radius);
    overflow: hidden;
    max-width: 200px;
}

.wlc-card img {
    width: 100%;
    height: auto;
    max-height: 180px;
    object-fit: contain;
    background: #f8f8f8;
    border-bottom: 2px solid var(--wlc-border) !important;
    cursor: pointer;
}

.wlc-card-body {
    padding: 12px;
}

.wlc-card-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--wlc-text) !important;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wlc-card-meta {
    font-size: 14px;
    font-weight: 600;
    color: var(--wlc-primary) !important;
    margin-bottom: 10px;
}

.wlc-card-btn {
    display: block;
    width: 100%;
    height: 36px;
    line-height: 32px;
    background: var(--wlc-bg) !important;
    color: var(--wlc-primary) !important;
    border: 2px solid var(--wlc-primary) !important;
    border-radius: var(--wlc-radius) !important;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: var(--wlc-transition);
}

.wlc-card-btn:hover {
    background: var(--wlc-primary) !important;
    color: white !important;
}

/* ========== 当前商品 ========== */
.wlc-current-product {
    padding: 12px 16px;
    background: var(--wlc-bg) !important;
    border-top: 2px solid var(--wlc-border) !important;
}

.wlc-product-mini {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wlc-product-mini img {
    width: 48px;
    height: 48px;
    border-radius: var(--wlc-radius);
    border: 2px solid var(--wlc-border) !important;
    object-fit: cover;
}

.wlc-product-mini-info {
    flex: 1;
    min-width: 0;
}

.wlc-product-mini-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--wlc-text) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wlc-product-mini-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--wlc-primary) !important;
}

/* Ask按钮 - 48px边框 */
.wlc-btn-outline {
    width: var(--wlc-height) !important;
    height: var(--wlc-height) !important;
    min-width: 80px !important;
    padding: 0 20px !important;
    background: var(--wlc-bg) !important;
    color: var(--wlc-primary) !important;
    border: 2px solid var(--wlc-primary) !important;
    border-radius: var(--wlc-radius) !important;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wlc-transition);
}

.wlc-btn-outline:hover {
    background: var(--wlc-primary) !important;
    color: white !important;
}

/* ========== 工具栏 ========== */
.wlc-toolbar {
    display: none;
    /* 默认隐藏，有会话后通过JS显示 */
    gap: 12px;
    padding: 12px 20px;
    background: var(--wlc-bg) !important;
    border-top: 2px solid var(--wlc-border) !important;
}

.wlc-toolbar.wlc-show {
    display: flex;
}

/* 工具按钮 - 48px边框 + SVG图标 */
.wlc-tool-btn {
    width: var(--wlc-height) !important;
    height: var(--wlc-height) !important;
    min-width: var(--wlc-height) !important;
    min-height: var(--wlc-height) !important;
    border: 2px solid var(--wlc-border) !important;
    background: var(--wlc-bg) !important;
    border-radius: var(--wlc-radius) !important;
    cursor: pointer !important;
    transition: var(--wlc-transition);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    color: var(--wlc-text) !important;
    position: relative !important;
    z-index: 10 !important;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.wlc-tool-btn svg {
    width: 24px;
    height: 24px;
    stroke: var(--wlc-text);
    pointer-events: none;
}

.wlc-tool-btn:hover {
    border-color: var(--wlc-primary) !important;
    background: var(--wlc-light) !important;
}

.wlc-tool-btn:hover svg {
    stroke: var(--wlc-primary);
}

.wlc-tool-btn.active {
    border-color: var(--wlc-primary) !important;
    background: var(--wlc-primary) !important;
}

.wlc-tool-btn.active svg {
    stroke: white;
}

/* ========== Emoji选择器 ========== */
.wlc-emoji-picker {
    padding: 12px;
    background: var(--wlc-bg) !important;
    border-top: 2px solid var(--wlc-border) !important;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 160px;
    overflow-y: auto;
}

.wlc-emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: var(--wlc-radius);
    border: 2px solid transparent !important;
    transition: var(--wlc-transition);
    background: transparent !important;
}

.wlc-emoji-item:hover {
    background: var(--wlc-light) !important;
    border-color: var(--wlc-border) !important;
}

/* ========== 输入区域 ========== */
.wlc-input-area {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    background: var(--wlc-bg) !important;
    border-top: 2px solid var(--wlc-border) !important;
}

.wlc-input {
    flex: 1;
    height: var(--wlc-height) !important;
    padding: 0 16px !important;
    border: 2px solid var(--wlc-border) !important;
    border-radius: var(--wlc-radius) !important;
    font-size: 14px;
    background: var(--wlc-bg) !important;
    transition: var(--wlc-transition);
}

.wlc-input:focus {
    outline: none;
    border-color: var(--wlc-primary) !important;
}

.wlc-input::placeholder {
    color: #999;
}

/* Send按钮 - 48px边框 */
.wlc-send-btn {
    height: var(--wlc-height) !important;
    min-height: var(--wlc-height) !important;
    padding: 0 24px !important;
    background: var(--wlc-bg) !important;
    color: var(--wlc-primary) !important;
    border: 2px solid var(--wlc-primary) !important;
    border-radius: var(--wlc-radius) !important;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wlc-transition);
}

.wlc-send-btn:hover {
    background: var(--wlc-primary) !important;
    color: white !important;
}

/* ========== 邮箱表单 ========== */
.wlc-email-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--wlc-bg) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.wlc-email-form {
    text-align: center;
    padding: 32px;
    max-width: 280px;
    position: relative;
}

.wlc-email-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 36px;
    height: 36px;
    border: 2px solid var(--wlc-border) !important;
    background: var(--wlc-bg) !important;
    border-radius: var(--wlc-radius) !important;
    cursor: pointer;
    font-size: 16px;
    color: var(--wlc-secondary) !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wlc-email-close:hover {
    border-color: var(--wlc-primary) !important;
    color: var(--wlc-primary) !important;
}

.wlc-email-icon {
    font-size: 40px;
    margin-bottom: 16px;
}

.wlc-email-form h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--wlc-text) !important;
}

.wlc-email-form p {
    margin: 0 0 20px 0;
    font-size: 13px;
    color: var(--wlc-secondary) !important;
}

.wlc-email-input {
    width: 100%;
    height: var(--wlc-height) !important;
    padding: 0 16px !important;
    border: 2px solid var(--wlc-border) !important;
    border-radius: var(--wlc-radius) !important;
    font-size: 14px;
    margin-bottom: 12px;
    background: var(--wlc-bg) !important;
    transition: var(--wlc-transition);
}

.wlc-email-input:focus {
    outline: none;
    border-color: var(--wlc-primary) !important;
}

.wlc-email-submit {
    width: 100%;
    height: var(--wlc-height) !important;
    background: var(--wlc-bg) !important;
    color: var(--wlc-primary) !important;
    border: 2px solid var(--wlc-primary) !important;
    border-radius: var(--wlc-radius) !important;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wlc-transition);
}

.wlc-email-submit:hover {
    background: var(--wlc-primary) !important;
    color: white !important;
}

.wlc-email-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== 弹窗 - 在聊天窗口内 ========== */
.wlc-popup {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 180px;
    background: var(--wlc-bg) !important;
    border: 2px solid var(--wlc-border) !important;
    border-radius: var(--wlc-radius) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 100;
}

.wlc-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid var(--wlc-border) !important;
    font-weight: 600;
    font-size: 14px;
    background: var(--wlc-bg) !important;
}

.wlc-popup-close {
    width: 32px;
    height: 32px;
    border: 2px solid var(--wlc-border) !important;
    background: var(--wlc-bg) !important;
    border-radius: var(--wlc-radius) !important;
    cursor: pointer;
    font-size: 16px;
    color: var(--wlc-secondary) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
}

.wlc-popup-close:hover {
    border-color: var(--wlc-primary) !important;
    color: var(--wlc-primary) !important;
}

.wlc-popup-body {
    max-height: 200px;
    overflow-y: auto;
    background: var(--wlc-bg) !important;
}

.wlc-popup-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--wlc-border) !important;
    transition: var(--wlc-transition);
    background: var(--wlc-bg) !important;
}

.wlc-popup-item:hover {
    background: var(--wlc-light) !important;
}

.wlc-popup-item:last-child {
    border-bottom: none !important;
}

.wlc-popup-item-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--wlc-text) !important;
    margin-bottom: 2px;
}

.wlc-popup-item-meta {
    font-size: 12px;
    color: var(--wlc-secondary) !important;
}

.wlc-popup-empty {
    padding: 32px;
    text-align: center;
    color: var(--wlc-secondary) !important;
    font-size: 13px;
}

/* ========== 图片灯箱 ========== */
.wlc-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.wlc-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}

.wlc-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: white !important;
    border: none !important;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== 订单/商品弹窗 ========== */
.wlc-popup {
    position: absolute;
    bottom: 130px;
    left: 20px;
    right: 20px;
    background: var(--wlc-bg);
    border: 2px solid var(--wlc-border);
    border-radius: var(--wlc-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    max-height: 300px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.wlc-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid var(--wlc-border);
    background: var(--wlc-light);
    font-weight: 600;
    font-size: 14px;
}

.wlc-popup-close {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--wlc-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.wlc-popup-close:hover {
    background: var(--wlc-border);
    color: var(--wlc-text);
}

.wlc-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.wlc-popup-empty {
    text-align: center;
    padding: 20px;
    color: var(--wlc-secondary);
}

.wlc-popup-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--wlc-transition);
    border: 1px solid transparent;
}

.wlc-popup-item:hover {
    background: var(--wlc-light);
    border-color: var(--wlc-border);
}

.wlc-popup-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--wlc-text);
}

.wlc-popup-item-meta {
    font-size: 12px;
    color: var(--wlc-secondary);
    margin-top: 4px;
}

/* ========== 响应式 - 480px以下 ========== */
@media (max-width: 480px) {
    .wlc-bubble {
        width: 52px;
        height: 52px;
    }

    .wlc-emoji-picker {
        grid-template-columns: repeat(6, 1fr);
    }

    .wlc-toolbar {
        gap: 8px;
        padding: 10px 16px;
    }

    .wlc-tool-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }

    .wlc-popup {
        left: 10px;
        right: 10px;
        bottom: 120px;
    }
}

/* ========== Woodmart移动端导航按钮未读badge ========== */
.wlc-woodmart-unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e74c3c !important;
    color: white !important;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    border: 1.5px solid white !important;
    z-index: 10;
}

/* ========== 购物车打开时隐藏聊天图标（问题2修复） ========== */
body.cart-widget-open .wlc-widget,
body.wd-cart-opened .wlc-widget,
.wd-cart-design-side.wd-opened ~ .wlc-widget,
.wd-side-hidden.wd-opened ~ .wlc-widget,
.wlc-widget.wlc-cart-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease;
}