/* ---------- AI CHAT WIDGET ("Ask about Awan") ---------- */
/* Shared row for .back-to-top + .ai-chat-fab, appended by js/main.js.
 DOM order (back-to-top first, chat button second) is what puts
 back-to-top on the left and the chat button on the right, closest to
 the corner — swap the append order in main.js to swap which is which.
 Flexbox sizes to content, so this never needs hand-tuned pixel gaps
 even though the chat button's width varies with its label text. */
.fab-stack{
 position:fixed;right:26px;bottom:26px;z-index:60;
 display:flex;align-items:center;gap:12px;
}
@media (max-width:640px){
 .fab-stack{right:16px;bottom:16px;gap:10px;}
}
.ai-chat-fab{
 position:static;
 display:flex;align-items:center;gap:9px;
 padding:12px 14px 12px 18px;border-radius:999px;
 background:var(--ink);border:1px solid var(--ink);color:var(--paper);
 cursor:pointer;box-shadow:4px 4px 0 var(--rule);
 font-family:'IBM Plex Mono',monospace;font-size:12.5px;font-weight:700;
 letter-spacing:.01em;text-transform:uppercase;
 transition:opacity .2s ease,transform .2s ease,visibility .2s,background .2s;
}
.ai-chat-fab:hover{background:var(--up);border-color:var(--up);}
.ai-chat-fab.is-hidden{opacity:0;visibility:hidden;transform:translateY(12px);pointer-events:none;}
.ai-chat-fab svg{flex:none;order:2;}
.ai-chat-fab-label{order:1;}
@media (max-width:640px){
 .ai-chat-fab{padding:12px;}
 .ai-chat-fab-label{display:none;}
}

.ai-chat-panel{
 position:fixed;right:26px;bottom:86px;z-index:70;
 width:min(360px,calc(100vw - 32px));
 max-height:min(520px,calc(100vh - 112px));
 display:flex;flex-direction:column;
 background:var(--paper-card);border:1.5px solid var(--ink);border-radius:var(--radius-lg);
 box-shadow:6px 6px 0 var(--rule);
 opacity:0;visibility:hidden;transform:translateY(16px) scale(.98);
 transition:opacity .22s ease,transform .22s ease,visibility .22s;
}
.ai-chat-panel.is-open{opacity:1;visibility:visible;transform:translateY(0) scale(1);}
@media (max-width:640px){
 .ai-chat-panel{left:16px;right:16px;bottom:70px;width:auto;max-height:min(480px,calc(100vh - 96px));}
}

.ai-chat-head{
 display:flex;align-items:center;justify-content:space-between;
 padding:14px 16px;border-bottom:1px solid var(--rule);
 font-family:'IBM Plex Mono',monospace;font-size:12.5px;font-weight:700;
 letter-spacing:.02em;text-transform:uppercase;color:var(--ink);
}
.ai-chat-close{
 background:none;border:none;color:var(--ink-50);cursor:pointer;
 font-size:14px;line-height:1;padding:4px;
}
.ai-chat-close:hover{color:var(--brick);}

.ai-chat-messages{
 flex:1;min-height:180px;overflow-y:auto;
 padding:14px 16px;display:flex;flex-direction:column;gap:10px;
}
.ai-chat-msg{
 max-width:86%;padding:9px 12px;border-radius:10px;
 font-size:13.5px;line-height:1.5;white-space:pre-wrap;word-break:break-word;
}
.ai-chat-msg--assistant{
 align-self:flex-start;background:var(--paper-deep);color:var(--ink);
 border-bottom-left-radius:3px;
}
.ai-chat-msg--user{
 align-self:flex-end;background:var(--up);color:var(--paper);
 border-bottom-right-radius:3px;
}
.ai-chat-msg--typing{display:inline-flex;gap:4px;align-items:center;padding:14px 16px;}
.ai-chat-dot{width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.4;animation:ai-dot-bounce 1.2s ease-in-out infinite;}
.ai-chat-dot:nth-child(2){animation-delay:.2s;}
.ai-chat-dot:nth-child(3){animation-delay:.4s;}
@keyframes ai-dot-bounce{0%,80%,100%{opacity:.4;transform:translateY(0);}40%{opacity:1;transform:translateY(-3px);}}
.ai-chat-msg--egg-typing{font-size:20px;line-height:1;padding:12px 16px;animation:ai-egg-bounce .35s ease-in-out infinite;}
@keyframes ai-egg-bounce{0%,100%{transform:translateY(0);}50%{transform:translateY(-3px);}}
.ai-chat-msg p{margin:0 0 8px 0;}
.ai-chat-msg p:last-child{margin-bottom:0;}
.ai-chat-msg strong{font-weight:700;}
.ai-chat-msg em{font-style:italic;}
.ai-chat-msg ul,.ai-chat-msg ol{margin:2px 0 8px 0;padding-left:20px;}
.ai-chat-msg ul:last-child,.ai-chat-msg ol:last-child{margin-bottom:0;}
.ai-chat-msg li{margin-bottom:3px;}
.ai-chat-msg li:last-child{margin-bottom:0;}
.ai-chat-msg h1,.ai-chat-msg h2,.ai-chat-msg h3,.ai-chat-msg h4,.ai-chat-msg h5,.ai-chat-msg h6{
 font-size:1em;font-weight:700;margin:0 0 6px 0;line-height:1.4;
}
.ai-chat-msg code{
 background:rgba(0,0,0,.08);padding:1px 5px;border-radius:4px;
 font-family:'IBM Plex Mono',ui-monospace,monospace;font-size:.9em;
}
.ai-chat-msg pre{
 background:rgba(0,0,0,.08);padding:9px 10px;border-radius:8px;
 overflow-x:auto;margin:0 0 8px 0;white-space:pre;
}
.ai-chat-msg pre code{background:none;padding:0;}
.ai-chat-msg blockquote{
 border-left:2px solid currentColor;opacity:.85;margin:0 0 8px 0;padding-left:10px;
}
.ai-chat-msg a{color:inherit;text-decoration:underline;text-underline-offset:2px;}
.ai-chat-table-wrap{overflow-x:auto;margin:0 0 8px 0;-webkit-overflow-scrolling:touch;}
.ai-chat-table-wrap:last-child{margin-bottom:0;}
.ai-chat-msg table{border-collapse:collapse;width:100%;font-size:.92em;}
.ai-chat-msg th,.ai-chat-msg td{border:1px solid var(--rule);padding:6px 10px;text-align:left;vertical-align:top;}
.ai-chat-msg th{background:rgba(0,0,0,.06);font-weight:700;white-space:nowrap;}
.ai-chat-msg--user table{border-color:rgba(255,255,255,.35);}
.ai-chat-msg--user th,.ai-chat-msg--user td{border-color:rgba(255,255,255,.35);}
.ai-chat-msg--user th{background:rgba(255,255,255,.15);}
html[data-theme="dark"] .ai-chat-msg th{background:rgba(255,255,255,.08);}
html[data-theme="dark"] .ai-chat-msg code,
html[data-theme="dark"] .ai-chat-msg pre{background:rgba(255,255,255,.1);}

.ai-chat-form{
 display:flex;gap:8px;padding:12px;border-top:1px solid var(--rule);
}
.ai-chat-input{
 flex:1;padding:10px 12px;border:1.5px solid var(--rule);border-radius:6px;
 background:var(--paper);color:var(--ink);font-family:'Inter',sans-serif;font-size:13.5px;
}
.ai-chat-input:focus{outline:none;border-color:var(--up);}
.ai-chat-send{
 padding:10px 16px;border-radius:6px;border:1.5px solid var(--ink);
 background:var(--ink);color:var(--paper);cursor:pointer;
 font-family:'IBM Plex Mono',monospace;font-size:12px;font-weight:700;text-transform:uppercase;
}
.ai-chat-send:hover{background:var(--up);border-color:var(--up);}

html[data-theme="dark"] .ai-chat-fab{background:var(--night-card);border-color:var(--rule);color:var(--on-night);}
html[data-theme="dark"] .ai-chat-fab:hover{background:var(--up);border-color:var(--up);color:var(--on-night);}
html[data-theme="dark"] .ai-chat-panel{background:var(--night-card);border-color:var(--rule);}
html[data-theme="dark"] .ai-chat-head{color:var(--on-night);border-color:var(--rule);}
html[data-theme="dark"] .ai-chat-close{color:var(--on-night-50);}
html[data-theme="dark"] .ai-chat-msg--assistant{background:var(--night);color:var(--on-night);}
html[data-theme="dark"] .ai-chat-input{background:var(--night);color:var(--on-night);border-color:var(--rule);}

.ai-chat-tools{display:flex;align-items:center;gap:6px;}
.ai-chat-expand{background:none;border:none;color:var(--ink-50);cursor:pointer;padding:4px;line-height:0;}
.ai-chat-expand:hover{color:var(--up);}
.ai-chat-resize{position:absolute;top:0;left:0;width:24px;height:24px;cursor:nwse-resize;touch-action:none;z-index:2;}
.ai-chat-resize::before{content:'';position:absolute;top:7px;left:7px;width:9px;height:9px;border-top:2px solid var(--ink-50);border-left:2px solid var(--ink-50);border-top-left-radius:3px;opacity:.65;}
.ai-chat-resize:hover::before{opacity:1;border-color:var(--up);}
.ai-chat-panel.is-sizing{user-select:none;-webkit-user-select:none;}
.ai-chat-head{padding-left:28px;}
@media (max-width:640px){.ai-chat-resize{cursor:ns-resize;}}

/* ---- embed overrides (Ucapan Digital landing pages) ---- */
body.ai-embed .ai-chat-fab,body.ai-embed .ai-chat-panel{
 --paper:#FBFAFF;--paper-deep:#EFEBFA;--paper-card:#fff;--ink:#1E1B2E;--ink-50:rgba(30,27,46,.62);
 --rule:#E4E0F2;--up:var(--ac-d,#B83A73);--radius-lg:18px;
 font-family:'Figtree',system-ui,sans-serif;
}
body.ai-embed .ai-chat-fab,body.ai-embed .ai-chat-head,body.ai-embed .ai-chat-send,body.ai-embed .ai-chat-input{font-family:'Figtree',system-ui,sans-serif;text-transform:none;letter-spacing:0;}
body.ai-embed .ai-chat-head{font-size:15px;}
body.ai-embed .ai-chat-fab{font-size:15px;}
body.ai-embed .ai-chat-msg{font-size:15px;}
body.ai-embed .ai-chat-input{font-size:15px;}
body.ai-embed .ai-chat-fab{border-radius:999px;box-shadow:0 8px 20px rgba(30,27,46,.22);}
/* sits to the LEFT of the 54px WhatsApp button (right:16px;bottom:16px), vertically centred on it */
body.ai-embed .ai-embed-stack{right:80px;bottom:16px;height:54px;z-index:46;}
body.ai-embed .ai-chat-panel{right:16px;bottom:84px;z-index:60;box-shadow:0 18px 40px rgba(30,27,46,.28);}
@media (max-width:640px){
 body.ai-embed .ai-embed-stack{right:78px;bottom:16px;}
 body.ai-embed .ai-chat-panel{left:12px;right:12px;bottom:82px;}
}
