/* 🤖 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, #1e3a8a 0%, #2563eb 100%);
    color: white;
    padding: 14px 22px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(30, 58, 138, 0.3),
                0 2px 8px rgba(30, 58, 138, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    min-width: 150px;
    justify-content: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 按钮内部光泽层 */
.ai-chat-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent);
    transition: left 0.7s ease;
    transform: skewX(-25deg);
}

.ai-chat-toggle:hover::before {
    left: 150%;
}

/* 按钮外层光晕 */
.ai-chat-toggle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle,
        rgba(147, 197, 253, 0.3) 0%,
        transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    border-radius: 50px;
    transition: transform 0.4s ease;
    z-index: -1;
    opacity: 0;
}

.ai-chat-toggle:hover::after {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 1;
}

.ai-chat-toggle:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 25px rgba(30, 58, 138, 0.4),
                0 4px 12px rgba(30, 58, 138, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    border-color: rgba(255, 255, 255, 0.2);
}

.ai-chat-toggle:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(45, 55, 72, 0.2),
                inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-chat-toggle .chat-icon {
    font-size: 26px;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

/* AI客服图标样式 */
.ai-logo-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2),
                0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    background: white;
    padding: 2px;
}

.ai-chat-toggle:hover .ai-logo-icon {
    transform: rotate(360deg) scale(1.1);
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.4),
                0 4px 12px rgba(59, 130, 246, 0.3);
}

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

.ai-chat-toggle .chat-text {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
    position: relative;
    z-index: 1;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* 聊天窗口 */
.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: 768px) {
    .ai-chat-window {
        position: fixed;
        width: calc(100vw - 16px);
        height: calc(100vh - 140px);
        bottom: 8px;
        right: 8px;
        left: 8px;
        top: auto;
        border-radius: 16px;
        max-width: none;
    }

    #ai-chat-container {
        right: 12px;
        bottom: 12px;
        left: auto;
    }

    .ai-chat-toggle {
        padding: 10px 16px;
        font-size: 13px;
        width: auto;
        min-width: 120px;
        box-shadow: 0 3px 12px rgba(30, 58, 138, 0.35);
    }

    .ai-chat-toggle .chat-text {
        font-size: 13px;
    }

    .ai-chat-toggle .chat-icon {
        font-size: 20px;
    }

    .ai-logo-icon {
        width: 24px;
        height: 24px;
    }

    .chat-header {
        padding: 14px 16px;
        border-radius: 16px 16px 0 0;
    }

    .chat-title .hotel-name {
        font-size: 14px;
    }

    .chat-title .ai-name {
        font-size: 12px;
    }

    .chat-messages {
        padding: 12px;
        gap: 12px;
    }

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

    #ai-chat-input {
        font-size: 15px;
        padding: 10px 14px;
    }

    #ai-chat-send {
        padding: 10px 18px;
        font-size: 14px;
        min-width: 55px;
    }

    .message-content {
        font-size: 14px;
        padding: 10px 13px;
        max-width: 100%;
        word-wrap: break-word;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .ai-message, .user-message {
        max-width: 90%;
        gap: 8px;
    }

    .loading-indicator {
        padding: 12px 14px;
        font-size: 13px;
    }

    .language-btn {
        padding: 6px 10px;
        font-size: 14px;
        min-width: 40px;
    }

    .language-dropdown {
        min-width: 130px;
    }

    .language-option {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* 更小屏幕优化 (≤480px) */
@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 12px);
        height: calc(100vh - 100px);
        bottom: 6px;
        right: 6px;
        left: 6px;
        border-radius: 14px;
    }

    #ai-chat-container {
        right: 10px;
        bottom: 10px;
    }

    .ai-chat-toggle {
        padding: 9px 14px;
        min-width: 110px;
    }

    .ai-chat-toggle .chat-text {
        font-size: 12px;
    }

    .ai-chat-toggle .chat-icon {
        font-size: 18px;
    }

    .chat-header {
        padding: 12px 14px;
    }

    .chat-title .hotel-name {
        font-size: 13px;
    }

    .chat-title .ai-name {
        font-size: 11px;
    }

    .ai-logo-icon {
        width: 22px;
        height: 22px;
    }

    .chat-messages {
        padding: 10px;
        gap: 10px;
    }

    .message-content {
        font-size: 13px;
        padding: 9px 12px;
        line-height: 1.5;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .ai-message, .user-message {
        max-width: 92%;
    }

    .chat-input {
        padding: 10px 12px;
        gap: 8px;
    }

    #ai-chat-input {
        font-size: 14px;
        padding: 9px 12px;
    }

    #ai-chat-send {
        padding: 9px 16px;
        font-size: 13px;
        min-width: 50px;
    }

    .loading-indicator {
        padding: 10px 12px;
        font-size: 12px;
    }

    .language-btn {
        padding: 5px 9px;
        font-size: 13px;
        min-width: 38px;
    }

    .language-dropdown {
        min-width: 120px;
        right: 0;
    }

    .language-option {
        padding: 9px 12px;
        font-size: 12px;
    }
}

/* 极小屏幕优化 (≤360px) */
@media (max-width: 360px) {
    .ai-chat-window {
        width: calc(100vw - 8px);
        height: calc(100vh - 90px);
        bottom: 4px;
        right: 4px;
        left: 4px;
        border-radius: 12px;
    }

    #ai-chat-container {
        right: 8px;
        bottom: 8px;
    }

    .ai-chat-toggle {
        padding: 8px 12px;
        min-width: 100px;
        font-size: 11px;
    }

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

    .chat-title .hotel-name {
        font-size: 12px;
    }

    .chat-title .ai-name {
        font-size: 10px;
    }

    .message-content {
        font-size: 12px;
        padding: 8px 10px;
    }

    #ai-chat-input {
        font-size: 13px;
        padding: 8px 10px;
    }

    #ai-chat-send {
        padding: 8px 14px;
        font-size: 12px;
    }

    .message-avatar {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }
}

/* 聊天头部 */
.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;
}

/* 头部控制按钮区域 */
.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 语言选择器 */
.language-selector {
    position: relative;
}

.language-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 45px;
    justify-content: center;
}

.language-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 140px;
    overflow: hidden;
    display: none;
    margin-top: 5px;
    border: 1px solid #e1e5e9;
}

.language-option {
    padding: 12px 16px;
    cursor: pointer;
    color: #2c3e50;
    font-size: 14px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-option:hover {
    background-color: #f8f9fa;
}

.language-option.selected {
    background-color: #667eea;
    color: white;
}

.language-option.selected:hover {
    background-color: #5a67d8;
}

.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 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
    line-height: 1.3;
}

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

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

.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 strong {
    font-weight: 600;
    color: #2c3e50;
}

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

.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;
}

/* 输入区域 */
.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);
    }
}
