/* NM AI Chatbot Widget */
:root {
    --nmai-color: #0d6efd;
}

/* ── Toggle button — fixed bottom-right, next to #nm-sbc-wrapper cart button ── */
/* Cart: right:24px, width:65px, bottom:24px → chat right: 24+65+5 = 94px */
.nmai-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 94px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.nmai-chat-left {
    right: auto;
    left: 94px;
}

/* Toggle button — same size/style as cart button */
.nmai-chat-toggle {
    width: 65px;
    height: 65px;
    border-radius: 12px;
    background: var(--nmai-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.28);
    transition: transform .2s, box-shadow .2s;
}
.nmai-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,.35);
}

/* ── Chat window — opens upward from the button ── */
.nmai-chat-window {
    position: fixed;
    bottom: 99px;  /* button 65px + gap 10px + bottom 24px */
    right: 94px;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: nmai-slide-up .2s ease;
    z-index: 99998;
}

.nmai-chat-left .nmai-chat-window {
    right: auto;
    left: 94px;
}

@keyframes nmai-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.nmai-chat-header {
    background: var(--nmai-color);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.nmai-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}
.nmai-chat-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

/* Messages */
.nmai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.nmai-chat-msg { display: flex; }
.nmai-chat-msg-bot  { justify-content: flex-start; }
.nmai-chat-msg-user { justify-content: flex-end; }

.nmai-chat-bubble {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}
.nmai-chat-msg-bot  .nmai-chat-bubble {
    background: #f0f2f5;
    color: #1a1d23;
    border-bottom-left-radius: 4px;
}
.nmai-chat-msg-user .nmai-chat-bubble {
    background: var(--nmai-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.nmai-chat-typing .nmai-chat-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}
.nmai-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #adb5bd;
    display: inline-block;
    animation: nmai-bounce .9s infinite;
}
.nmai-chat-typing span:nth-child(2) { animation-delay: .15s; }
.nmai-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes nmai-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* Input area */
.nmai-chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid #f0f2f5;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
.nmai-chat-input {
    flex: 1;
    border: 1.5px solid #dee2e6;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
}
.nmai-chat-input:focus { border-color: var(--nmai-color); }

.nmai-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--nmai-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s;
}
.nmai-chat-send:disabled { opacity: .4; cursor: not-allowed; }
.nmai-chat-send:not(:disabled):hover { opacity: .85; }

/* Links in bot messages */
.nmai-chat-msg-bot .nmai-chat-bubble a {
    color: var(--nmai-color);
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
    .nmai-chat-widget {
        right: 16px;
        bottom: 16px;
    }
    .nmai-chat-window {
        right: 16px;
        left: 16px;
        bottom: 84px;
        width: auto;
    }
}
