/* =========================================================================
   myWebhero — on-site assistant (chat widget)
   Keys off the brand variables in style.css so it always matches the site.
   ========================================================================= */

.mwh-chat {
    --c-brand:    var(--brand, #1b3bff);
    --c-brand-d:  var(--brand-dark, #0f2091);
    --c-ink:      var(--ink, #0e1524);
    --c-ink-soft: var(--ink-soft, #4a5568);
    --c-line:     var(--line, #e4e8f0);
    --c-mist:     var(--mist, #f5f7fb);
    --c-font:     var(--font, 'Inter', system-ui, sans-serif);
    --c-display:  var(--display, 'Manrope', var(--c-font));
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 900;
    font-family: var(--c-font);
}

/* --- Launcher bubble ----------------------------------------------------- */
.mwh-chat-launch {
    display: inline-flex;
    align-items: center;
    gap: .55em;
    border: 0;
    cursor: pointer;
    background: var(--c-brand);
    color: #fff;
    font-family: var(--c-display);
    font-weight: 700;
    font-size: .95rem;
    padding: .8em 1.2em;
    border-radius: 999px;
    box-shadow: 0 12px 30px rgba(27, 59, 255, .32);
    transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
}
.mwh-chat-launch:hover { background: var(--c-brand-d); transform: translateY(-2px); }
.mwh-chat-launch svg { width: 20px; height: 20px; flex: none; }
.mwh-chat-launch .mwh-launch-label { white-space: nowrap; }

/* --- Panel --------------------------------------------------------------- */
.mwh-chat-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(380px, calc(100vw - 40px));
    height: min(600px, calc(100vh - 40px));
    max-height: 600px;
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: 18px;
    box-shadow: 0 30px 70px rgba(15, 32, 145, .22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
}

/* Hidden state — [hidden] is forced to none by style.css, so we just toggle it. */

/* Header */
.mwh-chat-head {
    display: flex;
    align-items: center;
    gap: .7em;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--c-brand), var(--c-brand-d));
    color: #fff;
}
.mwh-chat-head .mwh-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    flex: none;
}
.mwh-chat-head .mwh-avatar svg { width: 18px; height: 18px; }
.mwh-chat-head .mwh-title { font-family: var(--c-display); font-weight: 700; font-size: 1rem; line-height: 1.1; }
.mwh-chat-head .mwh-sub { font-size: .74rem; opacity: .85; margin-top: 2px; }
.mwh-chat-head .mwh-head-text { flex: 1 1 auto; min-width: 0; }
.mwh-chat-close {
    border: 0; background: transparent; color: #fff; cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px; font-size: 20px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s ease;
}
.mwh-chat-close:hover { background: rgba(255,255,255,.16); }

/* Message list */
.mwh-chat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    background: var(--c-mist);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mwh-msg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: .92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.mwh-msg a { color: inherit; text-decoration: underline; }
.mwh-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: var(--c-ink);
    border: 1px solid var(--c-line);
    border-bottom-left-radius: 4px;
}
.mwh-msg-user {
    align-self: flex-end;
    background: var(--c-brand);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.mwh-msg-bot a { color: var(--c-brand); }

/* Typing indicator */
.mwh-typing { display: inline-flex; gap: 4px; align-items: center; }
.mwh-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--c-ink-soft); opacity: .4;
    animation: mwh-bounce 1.2s infinite ease-in-out;
}
.mwh-typing span:nth-child(2) { animation-delay: .15s; }
.mwh-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mwh-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .3; } 40% { transform: translateY(-4px); opacity: .8; } }

/* Composer */
.mwh-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--c-line);
    background: #fff;
}
.mwh-chat-input {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid var(--c-line);
    border-radius: 12px;
    padding: 10px 12px;
    font-family: var(--c-font);
    font-size: .92rem;
    line-height: 1.4;
    max-height: 120px;
    color: var(--c-ink);
}
.mwh-chat-input:focus { outline: 2px solid var(--c-brand); outline-offset: 0; border-color: transparent; }
.mwh-chat-send {
    flex: none;
    border: 0;
    cursor: pointer;
    background: var(--c-brand);
    color: #fff;
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s ease;
}
.mwh-chat-send:hover { background: var(--c-brand-d); }
.mwh-chat-send:disabled { opacity: .5; cursor: default; }
.mwh-chat-send svg { width: 20px; height: 20px; }

.mwh-chat-foot {
    text-align: center;
    font-size: .68rem;
    color: var(--c-ink-soft);
    padding: 0 12px 10px;
    background: #fff;
}
.mwh-chat-foot a { color: var(--c-ink-soft); text-decoration: underline; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mwh-chat-launch, .mwh-chat-send, .mwh-chat-close { transition: none; }
    .mwh-typing span { animation: none; }
}
