/* Middletown HVAC Help Desk (Havoc) — replaces the Web.com customerAiAgent widget.
 * Footprint, colours and copy match the live widget (orange launcher, cream panel, "Middletown HVAC Help Desk").
 * Scoped to #mtown-chat. No external dependencies. */
#mtown-chat,#mtown-chat *{box-sizing:border-box}
#mtown-chat{position:fixed;right:18px;bottom:18px;z-index:940;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#1f2937}
#mtown-chat[hidden]{display:none}

/* launcher */
#mtown-chat .mtchat-launch{display:flex;align-items:center;justify-content:center;width:56px;height:56px;border:0;border-radius:50%;background:#ee7400;color:#000;cursor:pointer;box-shadow:0 10px 28px #0006;transition:transform .18s}
#mtown-chat .mtchat-launch svg{width:32px;height:32px;fill:currentColor}
#mtown-chat .mtchat-launch:hover{transform:scale(1.06)}
#mtown-chat .mtchat-launch:focus-visible{outline:3px solid #65d9ff;outline-offset:3px}
#mtown-chat[data-open="true"] .mtchat-launch{display:none}

/* panel */
#mtown-chat .mtchat-panel{display:none;position:relative;width:min(380px,calc(100vw - 24px));height:min(560px,calc(100vh - 110px));flex-direction:column;background:#fffcf5;border:1px solid #d5b86c;border-radius:16px;box-shadow:0 18px 50px #0007;overflow:visible}
#mtown-chat[data-open="true"] .mtchat-panel{display:flex;animation:mtchat-in .28s ease-out}
@keyframes mtchat-in{from{opacity:0;transform:translateY(16px) scale(.97)}to{opacity:1;transform:none}}

/* Havoc: sits at the desk to the left of the panel (desktop), like the live site */
#mtown-chat .mtchat-havoc{position:absolute;left:-300px;bottom:40px;width:290px;height:290px;pointer-events:none;background:url(/assets/img/brand/havoc-desk-512.webp) center bottom/contain no-repeat;filter:drop-shadow(0 14px 22px #0008);transform-origin:50% 100%;animation:mtchat-havoc-in .55s cubic-bezier(.2,.9,.3,1.2) both,mtchat-havoc-idle 6s ease-in-out 1.2s infinite}
@keyframes mtchat-havoc-in{from{opacity:0;transform:translateY(40px) scale(.85) rotate(-4deg)}to{opacity:1;transform:none}}
@keyframes mtchat-havoc-idle{0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)}}
@media(max-width:1100px){#mtown-chat .mtchat-havoc{left:-215px;width:200px;height:200px}}
@media(max-width:760px){#mtown-chat .mtchat-havoc{display:none}}

/* header */
#mtown-chat .mtchat-head{display:flex;align-items:center;gap:10px;padding:12px 14px;background:#0b1d2b;color:#fff;border-radius:15px 15px 0 0;border-bottom:3px solid #d5b86c}
#mtown-chat .mtchat-head img{width:34px;height:34px;border-radius:50%;background:#fffcf5;object-fit:cover;object-position:35% 15%}
#mtown-chat .mtchat-title{font-weight:800;font-size:15px;line-height:1.2}
#mtown-chat .mtchat-sub{font-size:11px;color:#b7e7e9;margin-top:2px}
#mtown-chat .mtchat-close{margin-left:auto;width:36px;height:36px;border:0;border-radius:8px;background:transparent;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center}
#mtown-chat .mtchat-close svg{width:16px;height:16px;fill:currentColor}
#mtown-chat .mtchat-close:focus-visible,#mtown-chat .mtchat-chip:focus-visible,#mtown-chat .mtchat-send:focus-visible,#mtown-chat input:focus-visible,#mtown-chat textarea:focus-visible,#mtown-chat .mtchat-lead button:focus-visible{outline:3px solid #65d9ff;outline-offset:2px}

/* log */
#mtown-chat .mtchat-log{flex:1;overflow:auto;padding:14px;display:flex;flex-direction:column;gap:10px;scroll-behavior:smooth}
#mtown-chat .mtchat-msg{max-width:88%;padding:10px 13px;border-radius:14px;font-size:14px;line-height:1.5;white-space:pre-wrap;word-wrap:break-word}
#mtown-chat .mtchat-msg a{color:#0b5fc3;font-weight:600}
#mtown-chat .mtchat-msg.bot{align-self:flex-start;background:#fff;border:1px solid #e8dcc2;border-bottom-left-radius:4px}
#mtown-chat .mtchat-msg.user{align-self:flex-end;background:#0b1d2b;color:#fff;border-bottom-right-radius:4px}
#mtown-chat .mtchat-msg.sys{align-self:center;background:#fff4d2;border:1px solid #ffd37a;font-size:13px;text-align:center}
#mtown-chat .mtchat-typing{align-self:flex-start;color:#6b7280;font-size:13px;padding:4px 13px}
#mtown-chat .mtchat-typing::after{content:"…";animation:mtchat-dots 1s steps(3,end) infinite}
@keyframes mtchat-dots{0%{content:"."}50%{content:".."}100%{content:"..."}}

/* fallback card (function unreachable) */
#mtown-chat .mtchat-fallback{align-self:stretch;display:grid;gap:8px;padding:12px;background:#fff;border:1px solid #e8dcc2;border-radius:12px;font-size:14px}
#mtown-chat .mtchat-fallback a{display:flex;align-items:center;justify-content:center;min-height:44px;border-radius:10px;font-weight:800;text-decoration:none}
#mtown-chat .mtchat-fallback .call{background:#ee7400;color:#000}
#mtown-chat .mtchat-fallback .text{background:#0b1d2b;color:#fff}

/* chips */
#mtown-chat .mtchat-chips[hidden]{display:none}
#mtown-chat .mtchat-chips{display:flex;flex-wrap:wrap;gap:6px;padding:0 12px 8px}
#mtown-chat .mtchat-chip{border:1px solid #d5b86c;background:#fff;color:#1f2937;border-radius:999px;padding:7px 11px;font:600 12px/1.3 inherit;cursor:pointer}
#mtown-chat .mtchat-chip::before{content:"✦ ";color:#ee7400}
#mtown-chat .mtchat-chip:hover{background:#fff4d2}

/* composer */
#mtown-chat .mtchat-form{display:flex;gap:8px;padding:10px 12px 12px;border-top:1px solid #e8dcc2;background:#fffcf5;border-radius:0 0 15px 15px}
#mtown-chat .mtchat-input{flex:1;min-height:44px;padding:10px 12px;border:1px solid #cfc3a6;border-radius:10px;font:400 15px/1.3 inherit;background:#fff}
#mtown-chat .mtchat-send{min-width:44px;height:44px;border:0;border-radius:10px;background:#ee7400;color:#000;font-weight:800;cursor:pointer}
#mtown-chat .mtchat-send[disabled]{opacity:.5;cursor:default}

/* lead form (inline in the log) */
#mtown-chat .mtchat-lead{align-self:stretch;display:grid;gap:8px;padding:12px;background:#fff;border:1px solid #d5b86c;border-radius:12px}
#mtown-chat .mtchat-lead label{display:grid;gap:4px;font-size:12px;font-weight:700;color:#374151}
#mtown-chat .mtchat-lead input,#mtown-chat .mtchat-lead textarea{min-height:42px;padding:9px 11px;border:1px solid #cfc3a6;border-radius:8px;font:400 15px/1.3 inherit}
#mtown-chat .mtchat-lead textarea{min-height:64px;resize:vertical}
#mtown-chat .mtchat-lead .hp{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}
#mtown-chat .mtchat-lead button{min-height:44px;border:0;border-radius:10px;background:#0b1d2b;color:#fff;font:800 14px/1 inherit;cursor:pointer}
#mtown-chat .mtchat-lead .note{font-size:11px;color:#6b7280;margin:0}

/* footer actions always visible */
#mtown-chat .mtchat-quick{display:flex;gap:6px;padding:0 12px 8px}
#mtown-chat .mtchat-quick a{flex:1;display:flex;align-items:center;justify-content:center;min-height:36px;border-radius:8px;font-size:12px;font-weight:800;text-decoration:none;border:1px solid #d5b86c;color:#0b1d2b;background:#fff}

/* mobile: full-width sheet above the quick-action bar */
@media(max-width:600px){
  #mtown-chat{right:8px;bottom:calc(84px + env(safe-area-inset-bottom,0px))}
  #mtown-chat .mtchat-panel{width:calc(100vw - 16px);height:min(70vh,560px)}
}
@media(prefers-reduced-motion:reduce){
  #mtown-chat .mtchat-panel,#mtown-chat .mtchat-havoc,#mtown-chat .mtchat-launch{animation:none!important;transition:none!important}
}
