/* AH AI Assistant - Chat Widget */
.ai-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary, #4680FF);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(70, 128, 255, 0.35);
    z-index: 10000;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ai-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(70, 128, 255, 0.45);
}
.ai-chat-btn.active {
    display: none;
}

.ai-chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, sans-serif;
}
.ai-chat-panel.open {
    display: flex;
}

.ai-chat-header {
    padding: 14px 16px;
    background: var(--primary, #4680FF);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.ai-chat-title {
    font-size: 14px;
    font-weight: 600;
}
.ai-chat-subtitle {
    font-size: 11px;
    opacity: 0.7;
}
.ai-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    padding: 4px;
    line-height: 1;
}
.ai-chat-close:hover {
    opacity: 1;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-body, #f8fafc);
}

.ai-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}
.ai-msg-user {
    align-self: flex-end;
    background: var(--primary, #4680FF);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg-assistant {
    align-self: flex-start;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #0f172a);
    border: 1px solid var(--border, #e2e8f0);
    border-bottom-left-radius: 4px;
}
.ai-msg-assistant code {
    background: var(--bg-input, #f1f5f9);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12px;
}
.ai-msg-assistant pre {
    background: var(--bg-input, #f1f5f9);
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
    margin: 6px 0;
}
.ai-msg-error {
    align-self: center;
    background: rgba(239,68,68,0.1);
    color: #ef4444;
    font-size: 12px;
    text-align: center;
    padding: 6px 12px;
}

.ai-msg-typing {
    align-self: flex-start;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e2e8f0);
    padding: 10px 18px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}
.ai-msg-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted, #94a3b8);
    margin: 0 2px;
    animation: aiTyping 1.2s infinite;
}
.ai-msg-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-msg-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiTyping {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-3px); }
}

.ai-confirm-btns {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.ai-confirm-btns button {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}
.ai-confirm-yes {
    background: var(--success, #10b981);
    color: #fff;
}
.ai-confirm-no {
    background: var(--bg-input, #f1f5f9);
    color: var(--text-primary, #0f172a);
}

.ai-chat-input-area {
    padding: 12px;
    border-top: 1px solid var(--border, #e2e8f0);
    display: flex;
    gap: 8px;
    background: var(--bg-card, #fff);
    flex-shrink: 0;
}
.ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    font-size: 13px;
    background: var(--bg-input, #f1f5f9);
    color: var(--text-primary, #0f172a);
    outline: none;
    resize: none;
    font-family: inherit;
    max-height: 80px;
}
.ai-chat-input:focus {
    border-color: var(--primary, #4680FF);
    box-shadow: 0 0 0 3px rgba(70,128,255,0.1);
}
.ai-chat-input::placeholder {
    color: var(--text-muted, #94a3b8);
}
.ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--primary, #4680FF);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: filter 0.15s;
}
.ai-chat-send:hover {
    filter: brightness(0.9);
}
.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .ai-chat-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        bottom: 8px;
        right: 8px;
        border-radius: 12px;
    }
    .ai-chat-btn {
        bottom: 16px;
        right: 16px;
    }
}
