/* AI聊天页面样式 */

.ai-chat-page {
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    padding-bottom: var(--spacing-lg);
}

.ai-chat-tabs {
    flex-shrink: 0;
}

.ai-chat-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 500px;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.chat-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-secondary);
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
}

.welcome-message i {
    font-size: 64px;
    color: var(--primary-color);
    margin-bottom: 16px;
    display: block;
}

.welcome-message p {
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.6;
}

/* 消息气泡 */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
    color: var(--text-secondary);
}

.message.user .message-avatar {
    background: var(--primary-color);
    color: white;
}

.message.ai .message-avatar {
    background: var(--secondary-color);
    color: white;
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    background: white;
    word-wrap: break-word;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

.message.user .message-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.ai .message-bubble {
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
    padding: 0 4px;
}

/* 输入区域 */
.chat-input-container {
    border-top: 1px solid var(--border-color);
    padding: 16px;
    background: var(--bg-primary);
}

.quick-questions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.quick-questions::-webkit-scrollbar {
    height: 4px;
}

.quick-questions::-webkit-scrollbar-track {
    background: transparent;
}

.quick-questions::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.quick-btn {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 13px;
    white-space: nowrap;
    transition: var(--transition);
    cursor: pointer;
    color: var(--text-primary);
}

.quick-btn:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* 智能规划按钮区域（农事计划 / 病虫害诊断 / 施肥方案 / 灌溉决策） */
.smart-planning-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.smart-planning-btns .btn {
    flex: 1 1 140px;
}

/* AI问答页面专用模态框样式，避免被其他页面的模态样式干扰 */
.ai-chat-modal {
    align-items: center;
    justify-content: center;
}

.ai-chat-modal-content {
    width: 90%;
    max-width: 600px;
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .ai-chat-modal-content {
        width: 600px;
        max-width: 600px;
    }
}

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

.chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    transition: var(--transition);
}

.chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
    outline: none;
}

.send-btn {
    align-self: flex-end;
    padding: 12px 20px;
    white-space: nowrap;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ai-chat-page {
        min-height: calc(100vh - var(--header-height) - var(--footer-height));
        padding-bottom: var(--spacing-sm);
    }

    .chat-container {
        min-height: 400px;
    }

    .chat-messages {
        padding: 16px;
    }

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

    .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }

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

    .quick-questions {
        gap: 6px;
    }

    .quick-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .send-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: 90%;
    }

    .chat-header h2 {
        font-size: 16px;
    }

    .welcome-message i {
        font-size: 48px;
    }
}
