/**
 * YRWP AI客服样式 (简化版)
 */

/* 后台设置样式 */
.yrwp-ai-chat-settings .form-table th {
    width: 200px;
}

.yrwp-ai-chat-settings .yrwp-section-title {
    margin-top: 30px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ccc;
    font-size: 16px;
}

.yrwp-ai-chat-settings .yrwp-help-text {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
}

.yrwp-ai-chat-settings textarea {
    width: 100%;
    max-width: 800px;
    min-height: 150px;
    box-sizing: border-box;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════
   前端聊天窗口样式 - 关键：所有元素使用 fixed 定位
   ═══════════════════════════════════════════════════════════════════════ */

/* 聊天窗口 - 默认右下角 */
#yrwp-ai-chat-window {
    position: fixed !important;
    bottom: 80px;
    right: 20px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#yrwp-ai-chat-window.show {
    display: flex;
}

#yrwp-ai-chat-header {
    background: linear-gradient(135deg, #0073aa, #005577);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#yrwp-ai-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

#yrwp-ai-chat-minimize {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

#yrwp-ai-chat-minimize:hover {
    opacity: 1;
}

/* 新对话按钮样式 */
.yrwp-chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.yrwp-new-chat-btn {
    border: 1px solid rgba(255,255,255,0.3);
    padding: 3px 10px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    background: transparent;
    color: #ffffff;
}

.yrwp-new-chat-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-1px);
}

#yrwp-ai-chat-visitor {
    background: #f8f9fa;
    padding: 8px 15px;
    font-size: 12px;
    color: #666;
    display: flex;
    justify-content: space-between;
    flex-shrink: 0;
}

#yrwp-ai-chat-visitor .visitor-id {
    font-family: monospace;
    background: rgba(0,0,0,0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

#yrwp-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f7fa;
    min-height: 0;
}

#yrwp-ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#yrwp-ai-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.yrwp-ai-message {
    margin-bottom: 15px;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

.yrwp-ai-message.user {
    margin-left: auto;
}

.yrwp-ai-message.user .content {
    background: #0073aa;
    color: white;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
    word-break: break-word;
}

.yrwp-ai-message.assistant {
    margin-right: auto;
}

.yrwp-ai-message.assistant .content {
    background: white;
    color: #333;
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    word-break: break-word;
}

.yrwp-ai-message .hint {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding-left: 4px;
    font-weight: normal;
}

/* 消息时间显示 */
.msg-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding-left: 4px;
    font-weight: normal;
}

.yrwp-ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.yrwp-ai-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.yrwp-ai-typing span:nth-child(1) { animation-delay: 0s; }
.yrwp-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.yrwp-ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* AI思考中提示样式（文字 + 动画） */
.yrwp-ai-thinking {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: white;
    border-radius: 18px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-size: 14px;
    color: #666;
}

.yrwp-ai-thinking span:first-child {
    color: #555;
}

.yrwp-ai-thinking .thinking-dots {
    display: inline-flex;
    gap: 2px;
}

.yrwp-ai-thinking .thinking-dots span {
    font-size: 18px;
    font-weight: bold;
    animation: thinkingPulse 1.4s infinite ease-in-out;
    color: #0073aa;
}

.yrwp-ai-thinking .thinking-dots span:nth-child(1) { animation-delay: 0s; }
.yrwp-ai-thinking .thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.yrwp-ai-thinking .thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingPulse {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

#yrwp-ai-chat-input-area {
    padding: 12px 15px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

#yrwp-ai-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    min-height: 40px;
}

#yrwp-ai-chat-input:focus {
    border-color: #0073aa;
}

#yrwp-ai-chat-send {
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

#yrwp-ai-chat-send:hover {
    background: #005577;
}

#yrwp-ai-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ═══════════════════════════════════════════════════════════════════════
   浮动图标 - 关键修复：固定尺寸，防止变形
   ═══════════════════════════════════════════════════════════════════════ */

#yrwp-ai-chat-float {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    max-width: 56px !important;
    max-height: 56px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 99998;
    overflow: hidden;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: linear-gradient(135deg, #0073aa, #005577) !important;
    /* 防止被其他样式覆盖 */
    float: none !important;
    clear: none !important;
}

#yrwp-ai-chat-float:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

#yrwp-ai-chat-float svg {
    width: 50%;
    height: 50%;
    fill: white;
    flex-shrink: 0;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════
   气泡提示 - 关键修复：固定定位
   ═══════════════════════════════════════════════════════════════════════ */

#yrwp-ai-chat-bubble {
    position: fixed !important;
    bottom: 85px;
    right: 20px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    font-size: 13px;
    max-width: 250px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 99997;
    word-break: break-word;
}

#yrwp-ai-chat-bubble.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#yrwp-ai-chat-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

/* ═══════════════════════════════════════════════════════════════════════
   响应式
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    #yrwp-ai-chat-window {
        width: 92vw !important;
        height: 70vh !important;
        max-height: 520px !important;
        bottom: 80px;
        left: auto;
        right: 20px;
        top: auto;
        border-radius: 12px;
    }

    #yrwp-ai-chat-float {
        bottom: 10px;
        right: 10px;
    }

    #yrwp-ai-chat-bubble {
        bottom: 75px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    #yrwp-ai-chat-bubble::after {
        right: 28px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   扫描进度条
   ═══════════════════════════════════════════════════════════════════════ */

.scan-progress {
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin: 15px 0;
}

.scan-progress-bar {
    background: linear-gradient(90deg, #0073aa, #00a3d9);
    height: 20px;
    width: 0%;
    transition: width 0.3s;
    text-align: center;
    color: white;
    line-height: 20px;
    font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════
   统计卡片样式
   ═══════════════════════════════════════════════════════════════════════ */

.yrwp-stats-card {
    background: linear-gradient(135deg, #0073aa 0%, #005577 100%);
    color: white;
    padding: 25px 30px;
    border-radius: 12px;
    text-align: center;
    flex: 1;
    min-width: 150px;
    box-shadow: 0 4px 15px rgba(0, 115, 170, 0.3);
}

.yrwp-stats-card .stat-number {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.yrwp-stats-card .stat-label {
    font-size: 14px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.yrwp-stats-card.secondary {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #333;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.yrwp-stats-card.secondary .stat-number {
    color: #0073aa;
}

.yrwp-stats-card.secondary .stat-label {
    color: #666;
}

/* ═══════════════════════════════════════════════════════════════════════
   统计表格样式
   ═══════════════════════════════════════════════════════════════════════ */

.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.stats-table th, .stats-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.stats-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-table tr:hover {
    background: #f8f9fa;
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table .rank-cell {
    text-align: center;
    font-weight: bold;
    color: #0073aa;
    width: 60px;
}

.stats-table .url-cell {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-table .url-cell a {
    color: #333;
    text-decoration: none;
}

.stats-table .url-cell a:hover {
    color: #0073aa;
    text-decoration: underline;
}

.stats-table .visits-cell {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: #0073aa;
    width: 100px;
}

.stats-table .sessions-cell {
    text-align: center;
    color: #666;
    width: 80px;
}

.stats-table .time-cell {
    text-align: center;
    color: #999;
    font-size: 12px;
    width: 120px;
}

/* ═══════════════════════════════════════════════════════════════════════
   聊天窗口头部扩展样式
   ═══════════════════════════════════════════════════════════════════════ */

.yrwp-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.yrwp-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.yrwp-chat-header-text {
    display: flex;
    flex-direction: column;
}

.yrwp-chat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.yrwp-chat-subtitle {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   联系客服按钮
   ═══════════════════════════════════════════════════════════════════════ */

#yrwp-ai-chat-contact-bar {
    padding: 8px 15px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.yrwp-contact-btn {
    width: 100%;
    padding: 8px 16px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.yrwp-contact-btn:hover {
    background: #e8e8e8;
}

.yrwp-inline-contact-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.yrwp-inline-contact-btn:hover {
    background: #005577;
}

/* ═══════════════════════════════════════════════════════════════════════
   联系客服弹窗
   ═══════════════════════════════════════════════════════════════════════ */

.yrwp-modal {
    position: fixed !important;
    bottom: 90px;
    right: 20px;
    z-index: 99996;
    display: none;
}

.yrwp-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0,0,0,0.2);
    width: 280px;
    overflow: hidden;
}

.yrwp-modal-header {
    background: linear-gradient(135deg, #0073aa, #005577);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.yrwp-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.yrwp-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.yrwp-modal-close:hover {
    opacity: 1;
}

.yrwp-modal-body {
    padding: 16px;
}

.yrwp-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.yrwp-contact-item:last-child {
    border-bottom: none;
}

.yrwp-contact-icon {
    font-size: 20px;
}

.yrwp-contact-item a {
    color: #0073aa;
    text-decoration: none;
    font-size: 14px;
}

.yrwp-contact-item a:hover {
    text-decoration: underline;
}

.yrwp-contact-qrcode {
    text-align: center;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.yrwp-contact-qrcode img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
}

.yrwp-contact-qrcode p {
    margin: 8px 0 0;
    font-size: 12px;
    color: #666;
}

/* ═══════════════════════════════════════════════════════════════════════
   富文本内容样式
   ═══════════════════════════════════════════════════════════════════════ */

.yrwp-rich-content {
    line-height: 1.7;
}

.yrwp-rich-content h2 {
    font-size: 18px;
    margin: 15px 0 10px 0;
    padding: 0;
    border: none;
}

.yrwp-rich-content h3 {
    font-size: 16px;
    margin: 12px 0 8px 0;
    padding: 0;
    border: none;
}

.yrwp-rich-content h4 {
    font-size: 15px;
    margin: 10px 0 6px 0;
    padding: 0;
    border: none;
}

.yrwp-rich-content p {
    margin: 8px 0;
    padding: 0;
}

.yrwp-rich-content ul, .yrwp-rich-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.yrwp-rich-content li {
    margin: 4px 0;
}

.yrwp-rich-content table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
    font-size: 13px;
}

.yrwp-rich-content table tr {
    border-bottom: 1px solid #eee;
}

.yrwp-rich-content table td {
    padding: 8px 12px;
    border: 1px solid #ddd;
}

.yrwp-rich-content a {
    color: #0073aa;
    text-decoration: none;
}

.yrwp-rich-content a:hover {
    text-decoration: underline;
}

.yrwp-rich-content code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-family: monospace;
}

.yrwp-rich-content strong {
    font-weight: 600;
}

.yrwp-rich-content em {
    font-style: italic;
}

/* 响应式：小屏幕下表格滚动 */
@media (max-width: 480px) {
    .yrwp-rich-content table {
        font-size: 12px;
    }
    
    .yrwp-rich-content table td {
        padding: 6px 8px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   联系方式卡片样式（用于关键词触发时显示）
   ═══════════════════════════════════════════════════════════════════════ */

.yrwp-contact-card {
    margin-top: 12px;
    padding: 14px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    width: 100%;
    box-sizing: border-box;
}

.yrwp-contact-card-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    flex-wrap: wrap;
}

.yrwp-contact-card-item:last-child {
    margin-bottom: 0;
}

.yrwp-contact-card-item:hover {
    background: #f0f7ff;
    color: #0073aa;
    transform: translateX(3px);
    box-shadow: 0 2px 6px rgba(0,115,170,0.15);
}

.yrwp-contact-card-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.yrwp-contact-card-label {
    font-size: 13px;
    color: #666;
    min-width: 60px;
    flex-shrink: 0;
}

.yrwp-contact-card-value {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    word-break: break-all;
}

.yrwp-contact-card-item:hover .yrwp-contact-card-value {
    color: #0073aa;
}

.yrwp-contact-card-qrcode {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-top: 8px;
    gap: 12px;
}

.yrwp-contact-card-qrcode img {
    max-width: 180px;
    max-height: 180px;
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid #eee;
}

/* 响应式：小屏幕下标签和号码分行显示 */
@media (max-width: 480px) {
    .yrwp-contact-card {
        padding: 10px;
    }

    .yrwp-contact-card-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 8px 10px;
    }

    .yrwp-contact-card-icon {
        font-size: 18px;
    }

    .yrwp-contact-card-label {
        font-size: 12px;
        color: #888;
    }

    .yrwp-contact-card-value {
        font-size: 15px;
        font-weight: 600;
    }

    .yrwp-contact-card-qrcode img {
        max-width: 140px;
        max-height: 140px;
    }
}
