/* ============================================
   优稳AI助手 - 聊天浮窗样式
   品牌色系：#354157 深蓝灰 | #6495ED 蓝 | #F0B90B 品牌金 | #E5BF5F 浅金
   ============================================ */

/* 浮动按钮 */
.yw-chat-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #354157, #6495ED);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(53, 65, 87, 0.4);
    z-index: 99999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.yw-chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(53, 65, 87, 0.5);
}

.yw-chat-trigger.active {
    transform: scale(0.9) rotate(90deg);
}

.yw-chat-trigger svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: transform 0.3s ease;
}

/* 未读消息提示 */
.yw-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #F0B90B;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

/* 聊天窗口容器 */
.yw-chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 420px;
    height: 600px;
    max-height: calc(100vh - 120px); /* 防止在小屏幕上顶部溢出视口 */
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.yw-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* 聊天窗口头部 */
.yw-chat-header {
    background: linear-gradient(135deg, #354157, #4a5a72);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.yw-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F0B90B, #E5BF5F);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.yw-chat-avatar svg {
    width: 22px;
    height: 22px;
    fill: #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.yw-chat-header-info {
    flex: 1;
}

.yw-chat-header-title {
    font-size: 16px;
    font-weight: 600;
    font-family: "Microsoft YaHei", Arial, sans-serif;
}

.yw-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

.yw-chat-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 4px;
}

.yw-chat-header-close:hover {
    opacity: 1;
}

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

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

.yw-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* 消息气泡 */
.yw-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: yw-msg-in 0.3s ease;
}

@keyframes yw-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.yw-msg.assistant {
    align-self: flex-start;
}

.yw-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.yw-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
}

.yw-msg-avatar svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

.yw-msg.assistant .yw-msg-avatar {
    background: linear-gradient(135deg, #F0B90B, #E5BF5F);
}

.yw-msg.user .yw-msg-avatar {
    background: #6495ED;
    color: #fff;
    font-size: 12px;
}

.yw-msg-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    font-family: "Microsoft YaHei", Arial, sans-serif;
    color: #333;
}

.yw-msg.assistant .yw-msg-bubble {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-top-left-radius: 4px;
}

.yw-msg.user .yw-msg-bubble {
    background: #354157;
    color: #fff;
    border-top-right-radius: 4px;
}

/* 打字指示器 */
.yw-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-items: center;
}

.yw-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: yw-typing-bounce 1.4s infinite ease-in-out;
}

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

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

/* 认证引导卡片 */
.yw-cert-card {
    background: linear-gradient(135deg, #fefbf0, #fff9e6);
    border: 1px solid #F0B90B;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}

.yw-cert-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #354157;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.yw-cert-card-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: #F0B90B;
    border-radius: 2px;
}

.yw-cert-card-body {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 12px;
}

.yw-cert-card-features {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.yw-cert-card-tag {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(240, 185, 11, 0.15);
    color: #8a6d00;
}

.yw-cert-card-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #F0B90B, #E5BF5F);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s;
    font-family: "Microsoft YaHei", Arial, sans-serif;
}

.yw-cert-card-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(240, 185, 11, 0.4);
}

/* 快捷问题按钮 */
.yw-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.yw-quick-btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 14px;
    border: 1px solid #6495ED;
    background: rgba(100, 149, 237, 0.08);
    color: #6495ED;
    cursor: pointer;
    transition: all 0.2s;
    font-family: "Microsoft YaHei", Arial, sans-serif;
}

.yw-quick-btn:hover {
    background: #6495ED;
    color: #fff;
}

/* 输入区域 */
.yw-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}

.yw-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: "Microsoft YaHei", Arial, sans-serif;
    outline: none;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.yw-chat-input:focus {
    border-color: #6495ED;
}

.yw-chat-input::placeholder {
    color: #bbb;
}

.yw-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #354157;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.yw-chat-send:hover {
    background: #6495ED;
}

.yw-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.yw-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* 底部品牌标识 */
.yw-chat-footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: #bbb;
    background: #fff;
    flex-shrink: 0;
}

.yw-chat-footer a {
    color: #999;
    text-decoration: none;
}

/* 响应式适配 */
@media (max-width: 480px) {
    .yw-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 70px;
        right: 10px;
        border-radius: 12px;
    }

    .yw-chat-trigger {
        bottom: 15px;
        right: 15px;
        width: 54px;
        height: 54px;
    }
}
