/* 🤖 AI客服聊天界面样式 */

/* 聊天容器 */
#ai-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* 聊天触发按钮 */
.ai-chat-toggle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    user-select: none;
    min-width: 140px;
    justify-content: center;
}

.ai-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

.ai-chat-toggle .chat-icon {
    font-size: 24px;
    animation: bounce 2s infinite;
}

/* AI客服图标样式 */
.ai-logo-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.ai-avatar-icon {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.ai-chat-toggle .chat-text {
    font-weight: 500;
    font-size: 16px;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
    60% {
        transform: translateY(-2px);
    }
}

/* 聊天窗口 */
.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 80px;
        right: 20px;
        left: 20px;
    }
    
    #ai-chat-container {
        right: 20px;
        left: 20px;
    }
    
    .ai-chat-toggle {
        width: 100%;
        justify-content: center;
    }
}

/* 聊天头部 */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.chat-title .hotel-name {
    display: block;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-title .ai-name {
    display: block;
    font-size: 13px;
    opacity: 0.9;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.chat-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

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

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 消息样式 */
.ai-message, .user-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    max-width: 85%;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.ai-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Markdown内容样式 */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.2em; }
.message-content h4 { font-size: 1.1em; }

.message-content p {
    margin: 0.5em 0;
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.2em 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content blockquote {
    border-left: 3px solid #667eea;
    margin: 0.5em 0;
    padding: 0.2em 0 0.2em 1em;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 0 4px 4px 0;
}

.message-content strong {
    font-weight: 600;
    color: #2c3e50;
}

.message-content em {
    font-style: italic;
    color: #34495e;
}

.message-content a {
    color: #667eea;
    text-decoration: none;
}

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

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* 用户消息中的Markdown元素样式调整 */
.user-message .message-content strong {
    color: #ffffff;
    font-weight: 600;
}

.user-message .message-content em {
    color: #f8f9fa;
}

.user-message .message-content code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.user-message .message-content pre {
    background: rgba(255, 255, 255, 0.1);
}

.user-message .message-content blockquote {
    border-left-color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

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

.ai-message .message-content::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 8px 8px 0;
    border-color: transparent white transparent transparent;
}

.user-message .message-content::before {
    content: '';
    position: absolute;
    right: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 8px;
    border-color: transparent transparent transparent #667eea;
}

/* 快速问题按钮 */
.quick-questions {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-btn {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
    font-weight: 500;
}

.quick-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}



/* 输入区域 */
.chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 10px;
    align-items: center;
}

#ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#ai-chat-input:focus {
    border-color: #667eea;
}

#ai-chat-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 60px;
}

#ai-chat-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#ai-chat-send:active {
    transform: translateY(0);
}

/* 加载指示器 */
.loading-indicator {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #667eea;
    font-size: 14px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: loading-bounce 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 进入动画 */
.ai-chat-window {
    animation: slideIn 0.3s ease-out;
}

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

/* 暗色主题支持 */
@media (prefers-color-scheme: dark) {
    .ai-chat-window {
        background: #2c2c2c;
        border-color: #404040;
    }
    
    .chat-messages {
        background: #1e1e1e;
    }
    
    .message-content {
        background: #3c3c3c;
        color: #ffffff;
    }
    
    .ai-message .message-content::before {
        border-color: transparent #3c3c3c transparent transparent;
    }
    
    .chat-input {
        background: #2c2c2c;
        border-color: #404040;
    }
    
    #ai-chat-input {
        background: #3c3c3c;
        color: #ffffff;
        border-color: #404040;
    }
    
    .quick-questions {
        background: #2c2c2c;
        border-color: #404040;
    }
    
    .quick-btn {
        background: #3c3c3c;
        color: #ffffff;
        border-color: #404040;
    }
    
    .loading-indicator {
        background: #2c2c2c;
        border-color: #404040;
    }
    
    /* 暗色主题下的Markdown样式 */
    .message-content code {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .message-content pre {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .message-content blockquote {
        background: rgba(102, 126, 234, 0.1);
    }
    
    .message-content strong {
        color: #ffffff;
    }
    
    .message-content em {
        color: #e0e0e0;
    }
}