/* BotMax AI WA ChatBot – Widget CSS */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

/* ---- Variables ---- */
#bm-widget {
    --bm-accent: #7C3AED;
    --bm-wa: #25D366;
    --bm-wa-dark: #128C7E;
    --bm-bg: #F5F3FF;
    --bm-white: #ffffff;
    --bm-border: #E5E7EB;
    --bm-text: #111827;
    --bm-muted: #6B7280;
    --bm-shadow: 0 8px 40px rgba(0,0,0,.18);
    --bm-radius: 18px;
}

/* ---- Container ---- */
#bm-widget {
    position: fixed;
    bottom: 24px;
    z-index: 2147483647;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1;
}
#bm-widget.bm-widget--right { right: 24px; }
#bm-widget.bm-widget--left  { left: 24px;  }

/* ---- Launcher ---- */
.bm-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    height: 58px;
    padding: 0 20px 0 0;
    background: var(--bm-accent);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 28px rgba(0,0,0,.22);
    transition: transform .28s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    overflow: visible;
    outline: none;
    color: white;
    font-family: inherit;
}
.bm-launcher:hover { transform: scale(1.06) translateY(-2px); box-shadow: 0 10px 36px rgba(0,0,0,.28); }
.bm-launcher:active { transform: scale(.97); }

.bm-launcher__icon {
    width: 58px; height: 58px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: opacity .2s, transform .3s cubic-bezier(.34,1.56,.64,1);
}
.bm-launcher__icon--bot   { opacity: 1;  transform: rotate(0) scale(1);   }
.bm-launcher__icon--close { opacity: 0;  transform: rotate(-90deg) scale(.5); position: absolute; left: 0; }

.bm-launcher.is-open .bm-launcher__icon--bot   { opacity: 0; transform: rotate(90deg) scale(.5); }
.bm-launcher.is-open .bm-launcher__icon--close { opacity: 1; transform: rotate(0) scale(1); }

.bm-launcher__label {
    font-size: 14px; font-weight: 700; letter-spacing: .2px;
    white-space: nowrap; max-width: 150px;
    overflow: hidden; text-overflow: ellipsis;
}

/* Pulse ring */
.bm-pulse {
    position: absolute;
    top: 50%; left: 0;
    transform: translate(-50%, -50%);
    width: 58px; height: 58px;
    background: var(--bm-accent);
    border-radius: 50%;
    opacity: .3;
    animation: bm-pulse 2.5s ease-out infinite;
    pointer-events: none;
}
@keyframes bm-pulse {
    0%   { transform: translate(-50%,-50%) scale(1); opacity: .3; }
    70%  { transform: translate(-50%,-50%) scale(1.65); opacity: 0; }
    100% { transform: translate(-50%,-50%) scale(1.65); opacity: 0; }
}
.bm-launcher.is-open .bm-pulse { animation: none; opacity: 0; }

/* ---- Chat Window ---- */
.bm-window {
    position: absolute;
    bottom: 72px;
    width: 360px;
    background: var(--bm-white);
    border-radius: var(--bm-radius);
    box-shadow: var(--bm-shadow);
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.07);
    transform-origin: bottom center;
    transform: scale(.9) translateY(16px);
    opacity: 0;
    transition: transform .32s cubic-bezier(.34,1.4,.64,1), opacity .25s ease;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    max-height: 540px;
}
.bm-widget--right .bm-window { right: 0; }
.bm-widget--left  .bm-window { left: 0; }

.bm-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header */
.bm-window__header {
    background: var(--bm-accent);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.bm-window__agent { display: flex; align-items: center; gap: 11px; }
.bm-window__avatar {
    width: 44px; height: 44px;
    background: rgba(255,255,255,.18);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    position: relative; flex-shrink: 0;
}
.bm-window__online-dot {
    position: absolute; bottom: 2px; right: 2px;
    width: 11px; height: 11px;
    background: #22C55E;
    border-radius: 50%;
    border: 2.5px solid var(--bm-accent);
}
.bm-window__agent-text strong {
    display: block; color: white; font-size: 15px; font-weight: 700; line-height: 1.2;
}
.bm-window__agent-text span {
    display: flex; align-items: center; gap: 5px;
    color: rgba(255,255,255,.82); font-size: 12px; margin-top: 2px; font-weight: 500;
}
.bm-green-dot {
    display: inline-block; width: 7px; height: 7px;
    background: #22C55E; border-radius: 50;
}
.bm-window__controls { display: flex; gap: 4px; }
.bm-ctrl-btn {
    width: 30px; height: 30px;
    background: rgba(255,255,255,.15); border: none; border-radius: 50%;
    color: white; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .15s; outline: none;
}
.bm-ctrl-btn:hover { background: rgba(255,255,255,.28); }

/* Messages area */
.bm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background: var(--bm-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Subtle dot grid bg */
    background-image: radial-gradient(circle, rgba(124,58,237,.08) 1px, transparent 1px);
    background-size: 22px 22px;
    scroll-behavior: smooth;
}
.bm-messages::-webkit-scrollbar { width: 4px; }
.bm-messages::-webkit-scrollbar-thumb { background: rgba(124,58,237,.2); border-radius: 4px; }

/* Message rows */
.bm-msg-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: bm-msg-in .3s cubic-bezier(.34,1.4,.64,1) both;
}
@keyframes bm-msg-in {
    from { opacity: 0; transform: translateY(8px) scale(.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bm-msg-row--bot { justify-content: flex-start; }
.bm-msg-row--user { justify-content: flex-end; }

.bm-msg-avatar {
    width: 28px; height: 28px;
    background: var(--bm-accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.bm-msg-col {
    display: flex; flex-direction: column; gap: 4px;
    max-width: 80%;
}

.bm-msg-sender {
    font-size: 11px; font-weight: 600; color: var(--bm-muted);
    padding-left: 2px;
}

.bm-bubble {
    padding: 10px 13px;
    border-radius: 4px 16px 16px 16px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--bm-text);
    background: var(--bm-white);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    word-break: break-word;
}

.bm-msg-row--user .bm-bubble {
    background: var(--bm-accent);
    color: white;
    border-radius: 16px 16px 4px 16px;
}

/* Quick replies */
.bm-qr-row {
    display: flex; flex-wrap: wrap; gap: 7px;
    padding-left: 36px;
    margin-top: 2px;
    animation: bm-msg-in .35s .08s cubic-bezier(.34,1.4,.64,1) both;
}
.bm-qr-chip {
    padding: 7px 14px;
    border: 2px solid var(--bm-accent);
    border-radius: 999px;
    font-size: 13px; font-weight: 600;
    color: var(--bm-accent);
    background: white;
    cursor: pointer;
    transition: all .18s;
    font-family: inherit;
}
.bm-qr-chip:hover {
    background: var(--bm-accent);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(124,58,237,.3);
}
.bm-qr-chip:active { transform: scale(.96); }
.bm-qr-chip.is-selected {
    background: var(--bm-accent); color: white;
    opacity: .7; pointer-events: none;
}

/* Typing indicator */
.bm-typing {
    display: flex; align-items: center; gap: 8px;
    animation: bm-msg-in .3s both;
}
.bm-typing-dots {
    background: white; border-radius: 4px 14px 14px 14px;
    padding: 10px 14px; display: flex; gap: 4px; align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.bm-typing-dots span {
    width: 7px; height: 7px; background: var(--bm-accent);
    border-radius: 50%; opacity: .4;
    animation: bm-dot .9s ease-in-out infinite;
}
.bm-typing-dots span:nth-child(2) { animation-delay: .15s; }
.bm-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bm-dot {
    0%,80%,100% { transform: scale(.8); opacity: .4; }
    40%          { transform: scale(1.2); opacity: 1; }
}

/* WhatsApp CTA */
.bm-wa-cta {
    padding: 14px 16px;
    background: #F0FDF4;
    border-top: 1px solid #BBF7D0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: bm-slide-up .35s cubic-bezier(.34,1.4,.64,1) both;
    flex-shrink: 0;
}
@keyframes bm-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.bm-wa-cta__msg {
    font-size: 13px; color: #166534; font-weight: 500;
    margin: 0; line-height: 1.5; text-align: center;
}
.bm-wa-cta__btn {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    padding: 13px 16px;
    background: var(--bm-wa);
    color: white; text-decoration: none;
    border-radius: 13px;
    font-size: 14px; font-weight: 700; font-family: inherit;
    transition: all .2s;
    box-shadow: 0 4px 14px rgba(37,211,102,.35);
    animation: bm-wa-pulse 2.5s ease-in-out infinite;
}
@keyframes bm-wa-pulse {
    0%,100% { box-shadow: 0 4px 14px rgba(37,211,102,.35); }
    50%      { box-shadow: 0 4px 24px rgba(37,211,102,.6); }
}
.bm-wa-cta__btn:hover {
    background: var(--bm-wa-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37,211,102,.5);
    color: white; text-decoration: none;
    animation: none;
}

/* Reply area */
.bm-reply {
    display: flex; align-items: center;
    padding: 10px 14px 10px;
    border-top: 1px solid var(--bm-border);
    background: var(--bm-white);
    gap: 8px;
    flex-shrink: 0;
    transition: opacity .3s;
}
.bm-reply.is-disabled {
    opacity: .45;
    pointer-events: none;
}
.bm-reply__input {
    flex: 1; border: none; outline: none;
    font-family: inherit; font-size: 14px; color: var(--bm-text);
    background: transparent;
    padding: 6px 0;
}
.bm-reply__input::placeholder { color: #9CA3AF; }
.bm-reply__send {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bm-accent); color: white; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .15s; flex-shrink: 0; outline: none;
}
.bm-reply__send:hover { background: #6D28D9; transform: scale(1.08); }

/* Footer */
.bm-footer {
    padding: 7px 14px 10px;
    font-size: 11px; color: var(--bm-muted);
    text-align: center;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    background: var(--bm-white);
    border-top: 1px solid #F3F4F6;
    flex-shrink: 0;
}
.bm-footer a { color: var(--bm-accent); text-decoration: none; font-weight: 700; }
.bm-footer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 480px) {
    #bm-widget.bm-widget--right { right: 14px; }
    #bm-widget.bm-widget--left  { left: 14px; }
    #bm-widget { bottom: 14px; }
    .bm-window { width: calc(100vw - 28px); max-width: 360px; }
    .bm-launcher { height: 52px; padding-right: 14px; }
    .bm-launcher__icon { width: 52px; height: 52px; }
}
