#ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: var(--font-ui, 'Inter', sans-serif);
}

#ai-chat-bubble {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-teal, #2A5D45) 0%, var(--brand-teal-mid, #1E4433) 100%);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.28);
    font-size: 24px;
    padding: 0;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}
#ai-chat-bubble:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.35); }
#ai-chat-bubble img { width: 100%; height: 100%; object-fit: cover; }

#ai-chat-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 340px;
    max-width: calc(100vw - 32px);
    height: 460px;
    max-height: calc(100vh - 120px);
    background: var(--bg-card, #fff);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
#ai-chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#ai-chat-header {
    background: linear-gradient(135deg, var(--brand-teal, #2A5D45) 0%, var(--brand-teal-mid, #1E4433) 100%);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}
#ai-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    opacity: 0.85;
}
#ai-chat-close:hover { opacity: 1; }

#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-parchment, #F7F4EF);
}

.ai-chat-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.87rem;
    line-height: 1.45;
    word-wrap: break-word;
}
.ai-chat-msg a { color: inherit; text-decoration: underline; }
.ai-chat-msg.user {
    align-self: flex-end;
    background: var(--brand-teal, #2A5D45);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.ai-chat-msg.assistant {
    align-self: flex-start;
    background: #fff;
    color: var(--text-body, #4B4335);
    border: 1px solid var(--border-card, #DDD8CE);
    border-bottom-left-radius: 3px;
}
.ai-chat-msg.typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--border-card, #DDD8CE);
    color: var(--text-muted, #9A8A82);
    font-style: italic;
}

#ai-chat-form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--border-card, #DDD8CE);
    background: #fff;
    flex-shrink: 0;
}
#ai-chat-input {
    flex: 1;
    border: 1px solid var(--border-input, #D0C8BC);
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 0.87rem;
    font-family: inherit;
    outline: none;
}
#ai-chat-input:focus { border-color: var(--brand-teal, #2A5D45); }
#ai-chat-form button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--brand-teal, #2A5D45);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
#ai-chat-form button:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 480px) {
    #ai-chat-bubble { width: 52px; height: 52px; font-size: 21px; }
    #ai-chat-widget { bottom: 16px; right: 16px; }
    #ai-chat-panel { bottom: 64px; width: calc(100vw - 24px); right: -4px; }
}
