/* 微信风格 - 白色系私信对话界面 */

/* CSS变量定义 - 微信配色 */
:root {
    --primary-white: #ffffff;
    --bg-gray: #ededed;
    --bg-light: #f7f7f7;
    --wechat-green: #07c160;
    --wechat-green-light: #95ec69;
    --text-primary: #000000;
    --text-secondary: #888888;
    --text-muted: #b2b2b2;
    --border-light: #e6e6e6;
    --border-subtle: #d9d9d9;
    --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-gray);
    height: 100vh;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.5;
}

/* 顶部品牌展示区域 */
.header-image {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: auto;
    min-height: 60px;
    max-height: 180px;
    z-index: 100;
    background: var(--primary-white);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-soft);
}

.header-image img {
    width: 100%;
    height: auto;
    max-height: 180px;
    object-fit: cover;
    display: block;
}

/* 聊天容器 */
.chat-container {
    position: fixed;
    top: 140px;
    left: 0;
    right: 0;
    bottom: 60px;
    padding: 16px 12px;
    overflow-y: auto;
    background: var(--bg-gray);
    -webkit-overflow-scrolling: touch;
}

.chat-container::-webkit-scrollbar {
    width: 4px;
}

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

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 2px;
}

/* 消息通用样式 */
.message {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
    gap: 10px;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message.system {
    justify-content: flex-start;
}

.message.user {
    justify-content: flex-end;
}

/* 顾问头像 - 微信风格圆角 */
.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--primary-white);
    box-shadow: var(--shadow-soft);
}

.message-avatar img,
.message-avatar {
    border-radius: 4px;
}

.message.user .message-avatar {
    display: none;
}

/* 消息内容 - 微信气泡样式 */
.message-content {
    max-width: 70%;
    padding: 10px 14px;
    font-size: 16px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

/* 对方消息 - 白色气泡 */
.message.system .message-content {
    background: var(--primary-white);
    color: var(--text-primary);
    border-radius: 0 8px 8px 8px;
    box-shadow: var(--shadow-soft);
}

/* 气泡小三角 - 对方 */
.message.system .message-content::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 10px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 6px 6px 0;
    border-color: transparent var(--primary-white) transparent transparent;
}

/* 用户消息 - 微信绿色气泡 */
.message.user .message-content {
    background: var(--wechat-green-light);
    color: var(--text-primary);
    border-radius: 8px 0 8px 8px;
    box-shadow: var(--shadow-soft);
}

/* 气泡小三角 - 用户 */
.message.user .message-content::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 10px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 0 6px 6px;
    border-color: transparent transparent transparent var(--wechat-green-light);
}

/* 消息内富文本样式 */
.message-content b,
.message-content strong {
    font-weight: 600;
}

.message-content i,
.message-content em {
    font-style: italic;
}

.message-content u {
    text-decoration: underline;
}

.message-content a {
    color: #576b95;
    text-decoration: none;
}

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

.message.user .message-content a {
    color: #1a6d3b;
}

/* 产品卡片 - 微信风格 */
.card-message {
    background: var(--primary-white);
    border-radius: 8px;
    overflow: hidden;
    max-width: 280px;
    display: flex;
    align-items: stretch;
    text-decoration: none;
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
}

.card-message:active {
    transform: scale(0.98);
}

.card-cover {
    width: 100px;
    min-width: 100px;
    height: 100px;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.card-cover::after {
    display: none;
}

.card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.card-message:active .card-cover img {
    transform: scale(1.02);
}

.card-cover-icon {
    font-size: 24px;
    color: var(--text-muted);
}

.card-body {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.card-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 6px;
    line-height: 1.4;
}

.card-footer {
    border-top: none;
    padding: 0;
}

.card-link {
    display: inline-block;
    padding: 4px 40px;
    background: var(--wechat-green);
    color: var(--primary-white);
    font-size: 12px;
    text-decoration: none;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.card-link:active {
    opacity: 0.9;
}

/* 选项容器 - 微信风格按钮组 */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 240px;
}

.options-title {
    display: none;
}

.option-button {
    background: var(--primary-white);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    font-weight: 400;
}

/* 第一个选项作为标题 */
.option-button:first-child {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 0 0 6px 0;
    cursor: default;
    pointer-events: none;
    font-weight: 400;
}

.option-button:not(:first-child):active {
    background: var(--bg-light);
    border-color: var(--wechat-green);
}

.option-button.selected {
    background: var(--wechat-green);
    color: var(--primary-white);
    border-color: var(--wechat-green);
    font-weight: 500;
}

.option-button.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* 隐藏控制按钮 */
.script-control-btn {
    display: none;
}

/* 输入框区域 - 微信风格底栏 */
.input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-light);
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    display: flex;
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--border-light);
    z-index: 100;
}

#messageInput {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    background: var(--primary-white);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

#messageInput:focus {
    box-shadow: 0 0 0 1px var(--wechat-green);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

#sendBtn {
    padding: 10px 16px;
    background: var(--wechat-green);
    color: var(--primary-white);
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    min-width: 60px;
    transition: all 0.2s ease;
}

#sendBtn:active {
    opacity: 0.9;
}

/* 输入中提示 - 微信风格 */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--primary-white);
    border-radius: 0 8px 8px 8px;
    gap: 5px;
    box-shadow: var(--shadow-soft);
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 80%, 100% {
        opacity: 0.4;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 移动端适配 */
@media (max-width: 480px) {
    .message-content {
        max-width: 75%;
    }

    .card-message {
        max-width: 85%;
    }

    .options-container {
        max-width: 85%;
    }

    .chat-container {
        padding: 12px 10px;
    }
}

/* 大屏适配 */
@media (min-width: 768px) {
    .chat-container {
        max-width: 500px;
        margin: 0 auto;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        width: 100%;
    }

    .input-container {
        max-width: 500px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        border-radius: 0;
        margin: 0;
    }
}

/* 文本选择样式 */
::selection {
    background: var(--wechat-green);
    color: var(--primary-white);
}

/* 移除底部渐变遮罩 */
.chat-container::after {
    display: none;
}

/* 价格标签样式 */
.card-price {
    font-size: 16px;
    font-weight: 600;
    color: #fa5151;
    margin-bottom: 6px;
}

.card-price::before {
    content: '¥';
    font-size: 12px;
    margin-right: 1px;
}

/* 标签样式 */
.card-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.card-tag {
    padding: 2px 6px;
    background: rgba(7, 193, 96, 0.1);
    border-radius: 2px;
    font-size: 11px;
    color: var(--wechat-green);
}
