/**
 * WP Smart Assistant - 前台样式
 * Apple 设计风格：明亮留白、圆角、柔和阴影、spring easing 动画
 */

/* ===== CSS 变量 ===== */
:root {
    --wp-smart-theme: #007AFF;
    --wp-smart-theme-rgb: 0, 122, 255;
    --wp-smart-bg: #FFFFFF;
    --wp-smart-bg-secondary: #F2F2F7;
    --wp-smart-text: #1C1C1E;
    --wp-smart-text-secondary: #8E8E93;
    --wp-smart-border: #E5E5EA;
    --wp-smart-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --wp-smart-shadow-md: 0 8px 32px rgba(0, 0, 0, 0.08);
    --wp-smart-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
    --wp-smart-easing: cubic-bezier(0.25, 0.1, 0.25, 1.0);
    --wp-smart-easing-spring: cubic-bezier(0.42, 0.0, 0.58, 1.0);
    --wp-smart-radius: 16px;
    --wp-smart-radius-sm: 8px;
    --wp-smart-font-size: 14px;
}

/* ===== 悬浮按钮 ===== */
.wp-smart-floating-btn {
    position: fixed;
    bottom: 24px;
    z-index: 99998;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s var(--wp-smart-easing-spring),
                box-shadow 0.3s var(--wp-smart-easing);
    animation: wpSmartFloatIn 0.5s var(--wp-smart-easing-spring);
}

.wp-smart-floating-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.wp-smart-floating-btn:active {
    transform: scale(0.95);
}

.wp-smart-floating-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
}

.wp-smart-floating-icon-img {
    width: 60%;
    height: 60%;
    object-fit: contain;
    border-radius: 50%;
}

/* 脉冲动画 */
.wp-smart-floating-pulse {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: inherit;
    opacity: 0;
    animation: wpSmartPulse 2.5s ease-out infinite;
    z-index: 1;
}

@keyframes wpSmartPulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.8); opacity: 0; }
}

@keyframes wpSmartFloatIn {
    from { transform: scale(0) rotate(-20deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ===== 对话窗口 ===== */
.wp-smart-chat-window {
    position: fixed;
    bottom: 100px;
    z-index: 99997;
    background-color: var(--wp-smart-bg);
    box-shadow: var(--wp-smart-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wpSmartWindowIn 0.35s var(--wp-smart-easing-spring);
    transform-origin: bottom right;
}

.wp-smart-pos-left .wp-smart-chat-window {
    transform-origin: bottom left;
}

.wp-smart-chat-window.wp-smart-closing {
    animation: wpSmartWindowOut 0.2s var(--wp-smart-easing) forwards;
}

@keyframes wpSmartWindowIn {
    from { opacity: 0; transform: translateY(20px) scale(0.92); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes wpSmartWindowOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(20px) scale(0.92); }
}

/* ===== 对话窗口头部 ===== */
.wp-smart-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    color: #FFFFFF;
    flex-shrink: 0;
}

.wp-smart-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wp-smart-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-smart-chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wp-smart-chat-title {
    font-size: 15px;
    font-weight: 600;
}

.wp-smart-chat-status {
    font-size: 11px;
    opacity: 0.8;
}

.wp-smart-chat-header-right {
    display: flex;
    gap: 6px;
}

.wp-smart-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s var(--wp-smart-easing);
}

.wp-smart-chat-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ===== 消息区域 ===== */
.wp-smart-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #F9F9FB;
}

.wp-smart-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.wp-smart-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wp-smart-chat-messages::-webkit-scrollbar-thumb {
    background: #D1D1D6;
    border-radius: 4px;
}

/* ===== 消息气泡 ===== */
.wp-smart-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: wpSmartMsgIn 0.3s var(--wp-smart-easing);
    animation-fill-mode: both;
}

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

.wp-smart-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.wp-smart-message-assistant {
    align-self: flex-start;
}

.wp-smart-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.wp-smart-message-assistant .wp-smart-message-avatar {
    background-color: #E8E8ED;
}

.wp-smart-message-user .wp-smart-message-avatar {
    background-color: var(--wp-smart-theme);
}

.wp-smart-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: var(--wp-smart-font-size);
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.wp-smart-message-assistant .wp-smart-message-bubble {
    background-color: var(--wp-smart-bg);
    color: var(--wp-smart-text);
    border: 1px solid var(--wp-smart-border);
    border-top-left-radius: 4px;
}

.wp-smart-message-user .wp-smart-message-bubble {
    background-color: var(--wp-smart-theme);
    color: #FFFFFF;
    border-top-right-radius: 4px;
}

/* ===== 打字指示器 ===== */
.wp-smart-typing {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
}

.wp-smart-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #C7C7CC;
    animation: wpSmartTypingBounce 1.4s var(--wp-smart-easing) infinite;
}

.wp-smart-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.wp-smart-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes wpSmartTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ===== 输入区域 ===== */
.wp-smart-chat-input-area {
    padding: 10px 14px;
    background-color: var(--wp-smart-bg);
    border-top: 1px solid var(--wp-smart-border);
    flex-shrink: 0;
}

.wp-smart-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.wp-smart-chat-input {
    flex: 1;
    border: 1px solid var(--wp-smart-border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: var(--wp-smart-font-size);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Helvetica Neue', sans-serif;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.5;
    background-color: #F9F9FB;
    transition: border-color 0.2s var(--wp-smart-easing), background-color 0.2s var(--wp-smart-easing);
}

.wp-smart-chat-input:focus {
    border-color: var(--wp-smart-theme);
    background-color: var(--wp-smart-bg);
}

.wp-smart-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s var(--wp-smart-easing), opacity 0.2s var(--wp-smart-easing);
}

.wp-smart-chat-send-btn:hover {
    transform: scale(1.06);
}

.wp-smart-chat-send-btn:active {
    transform: scale(0.94);
}

.wp-smart-chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== 底部工具栏 ===== */
.wp-smart-chat-toolbar {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-top: 8px;
}

.wp-smart-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 12px;
    color: var(--wp-smart-text-secondary);
    background: transparent;
    border: 1px solid var(--wp-smart-border);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s var(--wp-smart-easing), color 0.2s var(--wp-smart-easing);
}

.wp-smart-toolbar-btn:hover {
    background-color: var(--wp-smart-bg-secondary);
    color: var(--wp-smart-text);
}

/* ===== 人工客服卡片 ===== */
.wp-smart-human-card {
    background: linear-gradient(135deg, #FFFFFF, #F2F2F7);
    border: 1px solid var(--wp-smart-border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 4px;
    text-align: center;
    animation: wpSmartMsgIn 0.3s var(--wp-smart-easing);
}

.wp-smart-human-card p {
    margin: 0 0 8px;
    font-size: var(--wp-smart-font-size);
    color: var(--wp-smart-text);
}

.wp-smart-human-card a {
    display: inline-block;
    background-color: var(--wp-smart-theme);
    color: #FFFFFF;
    padding: 8px 20px;
    border-radius: 18px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s var(--wp-smart-easing), transform 0.2s var(--wp-smart-easing);
}

.wp-smart-human-card a:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ===== 二维码弹窗 ===== */
.wp-smart-qrcode-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: wpSmartFadeIn 0.25s var(--wp-smart-easing);
}

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

.wp-smart-qrcode-modal-content {
    background: var(--wp-smart-bg);
    border-radius: 16px;
    padding: 24px;
    max-width: 300px;
    width: 90%;
    text-align: center;
    box-shadow: var(--wp-smart-shadow-lg);
    animation: wpSmartScaleIn 0.3s var(--wp-smart-easing-spring);
}

@keyframes wpSmartScaleIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.wp-smart-qrcode-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.wp-smart-qrcode-modal-header span {
    font-size: 16px;
    font-weight: 600;
    color: var(--wp-smart-text);
}

.wp-smart-qrcode-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--wp-smart-text-secondary);
    padding: 0;
    line-height: 1;
    transition: color 0.2s var(--wp-smart-easing);
}

.wp-smart-qrcode-modal-close:hover {
    color: var(--wp-smart-text);
}

.wp-smart-qrcode-modal-body img {
    max-width: 200px;
    border-radius: var(--wp-smart-radius-sm);
}

.wp-smart-qrcode-modal-body p {
    margin-top: 12px;
    font-size: 13px;
    color: var(--wp-smart-text-secondary);
}

/* ===== 回到顶部按钮 ===== */
.wp-smart-back-to-top {
    position: fixed;
    z-index: 99996;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--wp-smart-shadow-md);
    transition: transform 0.3s var(--wp-smart-easing-spring),
                opacity 0.3s var(--wp-smart-easing),
                box-shadow 0.3s var(--wp-smart-easing);
    animation: wpSmartFloatIn 0.5s var(--wp-smart-easing-spring);
}

.wp-smart-back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: var(--wp-smart-shadow-lg);
}

.wp-smart-back-to-top:active {
    transform: translateY(0) scale(0.95);
}

.wp-smart-btt-circle {
    border-radius: 50%;
}

.wp-smart-btt-rounded {
    border-radius: 12px;
}

/* ===== 响应式 - 移动端 ===== */
@media (max-width: 768px) {
    .wp-smart-chat-window {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        animation: wpSmartMobileIn 0.3s var(--wp-smart-easing-spring);
    }

    .wp-smart-chat-header {
        border-radius: 0 !important;
    }

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

    .wp-smart-floating-btn {
        bottom: 16px;
    }

    .wp-smart-pos-right .wp-smart-floating-btn {
        right: 16px;
    }

    .wp-smart-pos-left .wp-smart-floating-btn {
        left: 16px;
    }
}

/* ===== 留资表单卡片 ===== */
.wp-smart-lead-form {
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    max-width: 300px;
    padding: 20px;
}

.wp-smart-lead-form h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0 0 14px 0;
    text-align: center;
}

.wp-smart-lead-form input {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #d2d2d7;
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 10px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s var(--wp-smart-easing);
    font-family: inherit;
}

.wp-smart-lead-form input:focus {
    border-color: var(--wp-smart-theme, #007AFF);
    box-shadow: 0 0 0 3px rgba(var(--wp-smart-theme-rgb, 0, 122, 255), 0.1);
}

.wp-smart-lead-form .lead-submit-btn {
    width: 100%;
    border-radius: 12px;
    background: var(--wp-smart-theme, #007AFF);
    color: #FFFFFF;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s var(--wp-smart-easing);
    margin-top: 4px;
    font-family: inherit;
}

.wp-smart-lead-form .lead-submit-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.wp-smart-lead-form .lead-submit-btn:active {
    transform: scale(0.98);
}

.wp-smart-lead-form .lead-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===== 企业微信卡片 ===== */
.wp-smart-wework-card {
    background: linear-gradient(135deg, #07C160, #06AD56);
    color: #FFFFFF;
    border-radius: 16px;
    padding: 16px;
    max-width: 300px;
    text-align: center;
}

.wp-smart-wework-card .wework-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
}

.wp-smart-wework-card .wework-text {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    line-height: 1.4;
}

.wp-smart-wework-card .wework-btn {
    display: inline-block;
    background: #FFFFFF;
    color: #07C160;
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s var(--wp-smart-easing);
    border: none;
    cursor: pointer;
}

.wp-smart-wework-card .wework-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: #06AD56;
}

/* ===== 系统消息 ===== */
.wp-smart-message-system .wp-smart-message-bubble {
    text-align: center;
    font-size: 12px;
    color: #86868b;
    background: transparent !important;
    padding: 4px 0 !important;
    max-width: 100%;
}