/* ===== 基础样式 ===== */
#zibll-ai-assistant {
    position: fixed;
    z-index: 999999;
    transition: all 0.3s ease;
}

/* ===== 按钮样式 - 全面升级 ===== */
.ai-button {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 25px rgba(38, 117, 252, 0.4);
    animation: zibll-ai-pulse 2s infinite;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.ai-button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 30px rgba(38, 117, 252, 0.6);
}

.ai-button::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(30deg);
    animation: shine 3s infinite;
}

@keyframes zibll-ai-pulse {
    0% { transform: scale(1); box-shadow: 0 6px 25px rgba(38, 117, 252, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 8px 35px rgba(38, 117, 252, 0.6); }
    100% { transform: scale(1); box-shadow: 0 6px 25px rgba(38, 117, 252, 0.4); }
}

@keyframes shine {
    0% { transform: rotate(30deg) translateX(-100%); }
    100% { transform: rotate(30deg) translateX(100%); }
}

/* 新图标设计 */
.ai-button svg {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

.ai-button:hover svg {
    transform: scale(1.1);
}

/* ===== 位置类 ===== */
.zibll-ai-position-bottom-right { 
    bottom: 30px; 
    right: 30px; 
}

.zibll-ai-position-bottom-left { 
    bottom: 30px; 
    left: 30px; 
}

.zibll-ai-position-top-right { 
    top: 30px; 
    right: 30px; 
}

.zibll-ai-position-top-left { 
    top: 30px; 
    left: 30px; 
}

/* ===== 聊天窗口样式 - 浅色模式 ===== */
.ai-chatbox {
    position: absolute;
    width: 380px;
    height: 480px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    display: none;
    transform: translateY(10px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border: 1px solid #e5e7eb;
}

.ai-chatbox.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

/* ===== 位置适配 ===== */
.zibll-ai-position-bottom-right .ai-chatbox {
    bottom: 100%;
    right: 0;
    left: auto;
    margin-bottom: 15px;
}

.zibll-ai-position-bottom-left .ai-chatbox {
    bottom: 100%;
    left: 0;
    right: auto;
    margin-bottom: 15px;
}

.zibll-ai-position-top-right .ai-chatbox {
    top: 100%;
    right: 0;
    left: auto;
    margin-top: 15px;
}

.zibll-ai-position-top-left .ai-chatbox {
    top: 100%;
    left: 0;
    right: auto;
    margin-top: 15px;
}

/* ===== 聊天窗口组件样式 ===== */
.chat-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
}

.minimize-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.mode-selector {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    padding: 0 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px 0;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.mode-btn::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #4f46e5;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.mode-btn.active {
    color: #4f46e5;
    font-weight: 600;
}

.mode-btn.active::after {
    width: 100%;
}

.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-input {
    display: flex;
    padding: 15px;
    border-top: 1px solid #e5e7eb;
    background: white;
    position: relative;
    z-index: 10;
}

.chat-input input {
    flex: 1;
    padding: 14px 16px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    margin-right: 10px;
    font-size: 15px;
    transition: all 0.3s;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-input input:focus {
    border-color: #818cf8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.chat-input button {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 0 24px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(79, 70, 229, 0.2);
}

.chat-input button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

/* ===== 消息样式 ===== */
.ai-message, .user-message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    animation: messageAppear 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

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

.user-message {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.ai-message {
    background: white;
    color: #374151;
    margin-right: auto;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 5px;
}

/* 消息三角形指示器 */
.user-message::before {
    content: "";
    position: absolute;
    right: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #4f46e5;
}

.ai-message::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid white;
}

/* ===== 加载动画 ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: white;
    border-radius: 18px;
    max-width: 80px;
    margin-right: auto;
    border: 1px solid #e5e7eb;
}

.typing-dot {
    width: 10px;
    height: 10px;
    background: #818cf8;
    border-radius: 50%;
    margin: 0 3px;
    animation: typing-dot 1.4s infinite ease-in-out;
}

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

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

/* ===== 系统消息样式 ===== */
.system-message {
    background: #f0f7ff;
    border: 1px solid #d0e4ff;
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #3b82f6;
}

.system-message p {
    margin: 8px 0;
}

.system-message strong {
    color: #2563eb;
}

/* ===== 快捷问题样式 ===== */
.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
}

.quick-question {
    background: #e0e7ff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    color: #4f46e5;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.quick-question:hover {
    background: #c7d2fe;
    transform: translateY(-2px);
}

/* ===== 错误消息样式 ===== */
.error-message {
    background: #fff5f5 !important;
    color: #e53e3e !important;
    border: 1px solid #fc8181 !important;
}

.error-message::before {
    border-right-color: #fff5f5 !important;
}

/* =========================================== */
/* ===== 深色模式适配 ===== */
/* =========================================== */
@media (prefers-color-scheme: dark) {
    .ai-chatbox {
        background: #1f2937;
        border: 1px solid #374151;
    }
    
    .chat-header {
        background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    }
    
    .minimize-btn {
        background: rgba(255, 255, 255, 0.15);
    }
    
    .mode-selector {
        background: #111827;
        border-bottom: 1px solid #374151;
    }
    
    .mode-btn {
        color: #9ca3af;
    }
    
    .mode-btn.active {
        color: #a5b4fc;
    }
    
    .mode-btn.active::after {
        background: #818cf8;
    }
    
    .chat-history {
        background: #111827;
    }
    
    .chat-input {
        background: #1f2937;
        border-top: 1px solid #374151;
    }
    
    .chat-input input {
        background: #1f2937;
        border: 1px solid #374151;
        color: #e5e7eb;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
    
    .chat-input input:focus {
        border-color: #818cf8;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
    }
    
    .ai-message {
        background: #374151;
        color: #e5e7eb;
        border: 1px solid #4b5563;
    }
    
    .ai-message::before {
        border-right-color: #374151;
    }
    
    .typing-indicator {
        background: #374151;
        border: 1px solid #4b5563;
    }
    
    .typing-dot {
        background: #818cf8;
    }
    
    .system-message {
        background: #1e3a8a;
        border: 1px solid #3b82f6;
        color: #bfdbfe;
    }
    
    .system-message strong {
        color: #93c5fd;
    }
    
    .quick-question {
        background: #3730a3;
        color: #c7d2fe;
    }
    
    .quick-question:hover {
        background: #4f46e5;
    }
    
    .error-message {
        background: #7f1d1d !important;
        color: #fecaca !important;
        border: 1px solid #f87171 !important;
    }
    
    .error-message::before {
        border-right-color: #7f1d1d !important;
    }
}

/* 深色模式覆盖 - 如果网站有深色模式类 */
body.dark-mode .ai-chatbox,
body.dark-theme .ai-chatbox,
body.wp-dark-mode-active .ai-chatbox {
    background: #1f2937;
    border: 1px solid #374151;
}

body.dark-mode .chat-header,
body.dark-theme .chat-header,
body.wp-dark-mode-active .chat-header {
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
}

body.dark-mode .chat-history,
body.dark-theme .chat-history,
body.wp-dark-mode-active .chat-history {
    background: #111827;
}

body.dark-mode .chat-input input,
body.dark-theme .chat-input input,
body.wp-dark-mode-active .chat-input input {
    background: #1f2937;
    border: 1px solid #374151;
    color: #e5e7eb;
}

/* ===== 响应式调整 ===== */
@media (max-width: 480px) {
    #zibll-ai-assistant {
        bottom: 15px !important;
        right: 15px !important;
        left: auto !important;
        top: auto !important;
    }
    
    .ai-button {
        width: 60px;
        height: 60px;
    }
    
    .ai-chatbox {
        width: calc(100vw - 30px);
        height: 70vh;
        max-height: 500px;
        left: 15px !important;
        right: 15px !important;
        bottom: calc(100% + 15px) !important;
        top: auto !important;
    }
    
    .zibll-ai-position-bottom-right .ai-chatbox,
    .zibll-ai-position-bottom-left .ai-chatbox {
        bottom: calc(100% + 15px) !important;
    }
    
    .zibll-ai-position-top-right .ai-chatbox,
    .zibll-ai-position-top-left .ai-chatbox {
        top: calc(100% + 15px) !important;
    }
}

@media (max-width: 768px) {
    .ai-chatbox {
        max-width: calc(100vw - 40px);
    }
}

/* 滚动条美化 */
.chat-history::-webkit-scrollbar {
    width: 8px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

body.dark-mode .chat-history::-webkit-scrollbar-thumb,
body.dark-theme .chat-history::-webkit-scrollbar-thumb,
body.wp-dark-mode-active .chat-history::-webkit-scrollbar-thumb,
@media (prefers-color-scheme: dark) {
    .chat-history::-webkit-scrollbar-thumb {
        background: #4b5563;
    }
}