/* ==========================================================================
   NML AI Chatbot Widget — styled theo NML Design System
   Token: --nml-* (fallback hex nếu site chưa load token), font Plus Jakarta Sans
   ========================================================================== */

#nml-chat-bubble,
#nml-chat-window,
#nml-chat-window * {
    box-sizing: border-box;
    font-family: var(--nml-font, 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

/* ---------- Bubble (trigger) ---------- */
#nml-chat-bubble {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--nml-blue, #2F6BFF) 0%, var(--nml-green, #22C55E) 100%) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(47,107,255,.32), 0 2px 8px rgba(34,197,94,.18);
    z-index: 999998;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

#nml-chat-bubble:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 20px rgba(47,107,255,.36), 0 3px 10px rgba(34,197,94,.24) !important;
}

#nml-chat-bubble svg {
    width: 26px;
    height: 26px;
}

/* ---------- Chat window (glass panel) ---------- */
#nml-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 480px;
    max-height: calc(100vh - 140px);
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.80);
    border-radius: var(--nml-r-lg, 20px);
    box-shadow: 0 8px 30px rgba(15,23,42,0.16), inset 0 1px 0 rgba(255,255,255,0.90);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    transform-origin: bottom right;
    opacity: 1;
    transform: scale(1) translateY(0);
    transition: opacity 250ms ease, transform 250ms ease;
}

#nml-chat-window.nml-hidden {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
    pointer-events: none;
}

/* ---------- Header ---------- */
#nml-chat-header {
    background: var(--nml-blue, #2F6BFF) !important;
    color: #fff !important;
    padding: 16px 18px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
}

#nml-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#nml-chat-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.6);
}

#nml-chat-header span:not(#nml-chat-avatar) {
    display: flex;
    align-items: center;
    gap: 6px;
}

#nml-chat-header span:not(#nml-chat-avatar)::after {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--nml-green, #22C55E);
    box-shadow: 0 0 0 3px rgba(34,197,94,.30);
    flex: 0 0 auto;
}

#nml-chat-close {
    background: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    opacity: .85;
    transition: opacity 150ms ease;
}

#nml-chat-close:hover {
    opacity: 1;
}

/* ---------- Messages area ---------- */
#nml-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: rgba(248,250,252,0.60);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#nml-chat-messages::-webkit-scrollbar {
    width: 6px;
}
#nml-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,.40);
    border-radius: 999px;
}

.nml-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: var(--nml-r-md, 14px);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.nml-msg.user {
    background: var(--nml-blue, #2F6BFF) !important;
    color: #fff !important;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.nml-msg.bot {
    background: #ffffff !important;
    color: var(--nml-tx, #0F172A) !important;
    align-self: flex-start;
    border: 1px solid var(--nml-border, #E2E8F0);
    border-bottom-left-radius: 4px;
}

.nml-msg.typing {
    color: var(--nml-tx3, #94A3B8) !important;
    font-style: normal;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nml-msg.typing::after {
    content: '●●●';
    letter-spacing: 2px;
    font-size: 10px;
    animation: nml-typing-pulse 1.2s infinite ease-in-out;
}

@keyframes nml-typing-pulse {
    0%, 100% { opacity: .35; }
    50% { opacity: 1; }
}

/* ---------- Input row ---------- */
#nml-chat-input-row {
    display: flex;
    border-top: 1px solid var(--nml-border, #E2E8F0);
    padding: 10px;
    gap: 8px;
    background: #fff;
    flex: 0 0 auto;
}

#nml-chat-input {
    flex: 1;
    border: 1.5px solid var(--nml-border, #E2E8F0) !important;
    border-radius: var(--nml-r-pill, 999px);
    background: #fff !important;
    padding: 10px 16px;
    font-size: 16px; /* iOS auto-zoom fix */
    color: var(--nml-tx, #0F172A) !important;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

#nml-chat-input::placeholder {
    color: var(--nml-tx3, #94A3B8) !important;
}

#nml-chat-input:focus {
    border-color: var(--nml-blue, #2F6BFF) !important;
    box-shadow: 0 0 0 4px rgba(47,107,255,.12) !important;
}

#nml-chat-send {
    background: var(--nml-blue, #2F6BFF) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--nml-r-pill, 999px);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease, transform 150ms ease;
    flex: 0 0 auto;
}

#nml-chat-send:hover:not(:disabled) {
    background: #1a55f0 !important;
}

#nml-chat-send:disabled {
    opacity: 0.55;
    cursor: default;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
    #nml-chat-window {
        right: 16px;
        bottom: 88px;
        width: calc(100vw - 32px);
        height: calc(100vh - 160px);
        border-radius: var(--nml-r-md, 14px);
    }
    #nml-chat-bubble {
        right: 16px;
        bottom: 16px;
    }
}
