/* ─── AI Shopping Assistant Widget ─── */

/* Chat bubble (FAB) */
.ha-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cnvs-themecolor, #1B9CD9);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ha-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.ha-chat-bubble svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

/* Active conversation badge (UCP-014) */
.ha-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    transition: opacity 0.2s;
}

.ha-chat-bubble--pulse {
    animation: ha-pulse 3s ease-in-out infinite;
}

@keyframes ha-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }
    50% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 0 0 8px rgba(27, 156, 217, 0.15); }
}

/* Chat panel */
.ha-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.ha-chat-panel.ha-open {
    display: flex;
}

/* Header */
.ha-chat-header {
    background: var(--hector-navy, #005A8D);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ha-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}
.ha-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.8;
}
.ha-chat-close:hover {
    opacity: 1;
}

/* Messages area */
.ha-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message bubbles */
.ha-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}
.ha-msg a {
    color: inherit;
    text-decoration: underline;
}
.ha-msg-user {
    align-self: flex-end;
    background: var(--cnvs-themecolor, #1B9CD9);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ha-msg-assistant {
    align-self: flex-start;
    background: #f0f2f5;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

/* Markdown inside messages (UCP-016) */
.ha-msg h3, .ha-msg h4, .ha-msg h5, .ha-msg h6 {
    margin: 8px 0 4px;
    font-weight: 700;
    line-height: 1.3;
}
.ha-msg h3 { font-size: 15px; }
.ha-msg h4 { font-size: 14px; }
.ha-msg h5, .ha-msg h6 { font-size: 13px; }
.ha-msg h3:first-child,
.ha-msg h4:first-child,
.ha-msg h5:first-child { margin-top: 0; }

.ha-msg ul, .ha-msg ol {
    margin: 4px 0;
    padding-left: 18px;
}
.ha-msg li {
    margin: 2px 0;
}

.ha-msg del {
    color: #999;
}

.ha-msg code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
}

/* Markdown adjustments for user messages (cyan bg) */
.ha-msg-user del {
    color: rgba(255, 255, 255, 0.6);
}
.ha-msg-user code {
    background: rgba(255, 255, 255, 0.2);
}

/* Quick Replies (UCP-019) */
.ha-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 8px;
    align-self: flex-start;
}
.ha-quick-reply-btn {
    padding: 6px 14px;
    border: 1px solid var(--cnvs-themecolor, #1B9CD9);
    border-radius: 16px;
    background: #fff;
    color: var(--cnvs-themecolor, #1B9CD9);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.ha-quick-reply-btn:hover {
    background: var(--cnvs-themecolor, #1B9CD9);
    color: #fff;
}

/* Typing / tool indicator */
.ha-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    color: #666;
}
.ha-typing-dots {
    display: flex;
    gap: 3px;
}
.ha-typing-dots span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: ha-bounce 1.2s infinite;
}
.ha-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.ha-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ha-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Action link buttons (internal links rendered as buttons) */
.ha-action-link {
    display: inline-block;
    margin: 4px 4px 4px 0;
    padding: 7px 16px;
    background: var(--cnvs-themecolor, #1B9CD9);
    color: #fff !important;
    border-radius: 18px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none !important;
    transition: all 0.2s;
}
.ha-action-link:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* PayPal CTA button */
.ha-paypal-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 10px 20px;
    background: #0070ba;
    color: #fff !important;
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none !important;
    text-align: center;
    transition: background 0.2s;
}
.ha-paypal-btn:hover {
    background: #005ea6;
}

/* Feedback buttons (UCP-024) */
.ha-feedback {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}
.ha-msg-assistant:hover .ha-feedback,
.ha-feedback.ha-fb-done {
    opacity: 1;
}
.ha-fb-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
}
.ha-fb-btn:hover {
    opacity: 1;
    border-color: #ddd;
}
.ha-fb-done .ha-fb-btn {
    cursor: default;
    opacity: 0.3;
}
.ha-fb-done .ha-fb-btn.ha-fb-selected {
    opacity: 1;
    border-color: #ddd;
    background: #f0f2f5;
}

/* Close confirmation (UCP-023) */
.ha-confirm-close {
    align-self: center;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 16px 20px;
    text-align: center;
    margin: 8px 0;
}
.ha-confirm-close p {
    margin: 0 0 12px;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}
.ha-confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.ha-confirm-yes,
.ha-confirm-no {
    padding: 7px 18px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.ha-confirm-yes {
    background: #ef4444;
    color: #fff;
}
.ha-confirm-yes:hover {
    background: #dc2626;
}
.ha-confirm-no {
    background: #fff;
    color: #666;
    border: 1px solid #ddd;
}
.ha-confirm-no:hover {
    background: #f0f0f0;
}

/* Input area */
.ha-chat-input {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
    flex-shrink: 0;
}
.ha-chat-input input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.ha-chat-input input:focus {
    border-color: var(--cnvs-themecolor, #1B9CD9);
}
.ha-chat-input button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--cnvs-themecolor, #1B9CD9);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.ha-chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.ha-chat-input button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ─── Mobile ─── */
@media (max-width: 480px) {
    .ha-chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
    }
    .ha-chat-bubble {
        bottom: 16px;
        right: 16px;
    }
}
