/* ========================================
   AI 聊天助手浮窗样式
   ======================================== */

/* 浮动按钮 */
.chat-widget-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color, #2563eb);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-widget-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.chat-widget-bubble svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* 聊天窗口 */
.chat-widget-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1500;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chat-widget-window.open {
    display: flex;
}

/* 窗口头部 */
.chat-widget-header {
    background: var(--primary-color, #2563eb);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-widget-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.chat-widget-header-text h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: white;
}

.chat-widget-header-text p {
    font-size: 12px;
    opacity: 0.8;
    margin: 0;
}

/* 关闭按钮 */
.chat-widget-close {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
}

.chat-widget-close:hover {
    opacity: 1;
}

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

/* 消息气泡 */
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: white;
    color: var(--text-color, #1f2937);
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary-color, #2563eb);
    color: white;
    border-bottom-right-radius: 4px;
}

/* 消息中的链接 */
.chat-msg a {
    color: var(--primary-color, #2563eb);
    text-decoration: underline;
}

.chat-msg.user a {
    color: white;
}

/* 打字指示器 */
.chat-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: none;
    gap: 4px;
    align-items: center;
}

.chat-typing.show {
    display: flex;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: chatBounce 1.4s infinite ease-in-out;
}

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

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

@keyframes chatBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* 快捷问题 */
.chat-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    background: #f8fafc;
}

.chat-quick-btn {
    padding: 5px 10px;
    font-size: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    cursor: pointer;
    color: var(--primary-color, #2563eb);
    transition: background 0.2s, border-color 0.2s;
}

.chat-quick-btn:hover {
    background: #eff6ff;
    border-color: var(--primary-color, #2563eb);
}

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

.chat-widget-input textarea {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    max-height: 80px;
    min-height: 36px;
    line-height: 1.4;
    font-family: inherit;
    outline: none;
}

.chat-widget-input textarea:focus {
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.chat-widget-send {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary-color, #2563eb);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.chat-widget-send:hover {
    background: #1d4ed8;
}

.chat-widget-send:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.chat-widget-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ========================================
   移动端响应式
   ======================================== */
@media (max-width: 768px) {
    .chat-widget-bubble {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }

    .chat-widget-bubble svg {
        width: 24px;
        height: 24px;
    }

    .chat-widget-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100vh;
        max-height: 100dvh;
    }
}

@media (max-width: 480px) {
    .chat-widget-header {
        padding: 14px 16px;
    }

    .chat-msg {
        max-width: 90%;
    }
}

/* ========================================
   DeepMech 橙色变体（仅 body.deepmech-page 生效）
   ======================================== */
body.deepmech-page .chat-widget-bubble {
    background: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

body.deepmech-page .chat-widget-bubble:hover {
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

body.deepmech-page .chat-widget-header {
    background: #f59e0b;
}

body.deepmech-page .chat-msg.user {
    background: #f59e0b;
}

body.deepmech-page .chat-msg a {
    color: #d97706;
}

body.deepmech-page .chat-msg.user a {
    color: white;
}

body.deepmech-page .chat-quick-btn {
    color: #d97706;
}

body.deepmech-page .chat-quick-btn:hover {
    background: #fef3c7;
    border-color: #f59e0b;
}

body.deepmech-page .chat-widget-input textarea:focus {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

body.deepmech-page .chat-widget-send {
    background: #f59e0b;
}

body.deepmech-page .chat-widget-send:hover {
    background: #d97706;
}
