/* HTM Arabia chat bot widget. Brand colours only; asset-tag panel; motion respects reduced-motion. */
.htm-chat { position: fixed; left: 16px; bottom: 16px; z-index: 150; font-family: var(--ar); direction: rtl; }
.htm-chat svg { display: block; }

/* ---------- Robot button ---------- */
.chat-fab {
  position: relative; width: 64px; height: 64px; border-radius: 50%;
  background: var(--ink); color: var(--yellow); border: 2px solid var(--yellow);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  transition: transform .15s ease;
}
.chat-fab:hover { transform: translateY(-2px) rotate(-6deg); }
.chat-fab:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.bot-ico { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.bot-ico .bot-eyes circle, .bot-ico .bot-ball { fill: currentColor; stroke: none; }
.bot-eyes { transform-origin: 16px 16px; animation: bot-blink 4.5s infinite; }
.bot-ball { transform-origin: 16px 4px; animation: bot-ping 2.4s ease-in-out infinite; }
.chat-fab:hover .bot-antenna { animation: bot-wiggle .5s ease-in-out 2; transform-origin: 16px 9px; }
.is-open .chat-fab .bot-mouth { d: path("M13 21h6"); }
@keyframes bot-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes bot-ping { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes bot-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }

/* attention dot until the visitor has seen the teaser */
.chat-dot { position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--yellow); border: 2px solid var(--ink); }
.chat-fab.quiet .chat-dot, .is-open .chat-dot { display: none; }
.has-teaser .chat-fab { animation: bot-nudge 1.2s ease-in-out 2; }
@keyframes bot-nudge { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } 60% { transform: translateY(0); } }

/* ---------- Teaser bubble ---------- */
.chat-teaser {
  position: absolute; left: 0; bottom: 78px; width: max-content; max-width: min(280px, calc(100vw - 32px));
  background: var(--paper); color: var(--ink); border: 1px solid var(--ink); border-radius: 12px;
  padding: 12px 40px 12px 14px; cursor: pointer; font-size: 15px; font-weight: 600; line-height: 1.6;
}
.chat-teaser::after { content: ""; position: absolute; left: 24px; bottom: -7px; width: 12px; height: 12px; background: var(--paper); border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); transform: rotate(45deg); }
.chat-teaser.pop { animation: teaser-in .35s ease-out; }
@keyframes teaser-in { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
.chat-teaser-close { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.chat-teaser-close svg, .chat-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.chat-teaser-close:hover { color: var(--ink); background: var(--warm); }

/* ---------- Panel (asset tag) ---------- */
.chat-panel {
  position: absolute; left: 0; bottom: 78px; width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 110px));
  background: var(--paper); color: var(--ink); border: 1px solid var(--ink); border-radius: 8px;
  display: flex; flex-direction: column; overflow: hidden;
  clip-path: polygon(22px 0, 100% 0, 100% 100%, 0 100%, 0 22px);
  animation: panel-in .2s ease-out;
}
.chat-panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 14px; background: var(--ink); color: var(--paper); }
.chat-head h2 { font-size: 16px; line-height: 1.4; margin: 0; }
.chat-sub { font-size: 13px; color: var(--line); display: flex; align-items: center; gap: 6px; margin: 0; }
.chat-online { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--yellow); color: var(--yellow); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.chat-avatar .bot-ico { width: 26px; height: 26px; }
.chat-close { margin-inline-start: auto; width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--muted); background: transparent; color: var(--paper); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.chat-close:hover { border-color: var(--paper); }
.chat-head :focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--warm); overscroll-behavior: contain; }
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 88%; }
.msg-body { padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.75; word-wrap: break-word; }
.msg-bot { align-self: flex-start; }
.msg-bot .msg-body { background: var(--paper); border: 1px solid var(--line); border-bottom-right-radius: 4px; }
.msg-user { align-self: flex-end; }
.msg-user .msg-body { background: var(--ink); color: var(--paper); border-bottom-left-radius: 4px; }
.msg-avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--ink); color: var(--yellow); display: inline-flex; align-items: center; justify-content: center; }
.msg-avatar .bot-ico { width: 20px; height: 20px; }
.msg-avatar .bot-eyes, .msg-avatar .bot-ball, .chat-avatar .bot-eyes, .chat-avatar .bot-ball { animation: none; }
.msg-link { display: block; width: fit-content; margin-top: 6px; font-weight: 600; text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.chat-quick { display: flex; flex-direction: column; gap: 6px; padding: 10px 16px; background: var(--warm); border-top: 1px solid var(--line); }
.chat-quick[hidden] { display: none; }
.chat-chip { text-align: right; font: 500 14px/1.5 var(--ar); color: var(--ink); background: var(--paper); border: 1px solid var(--ink); border-radius: 999px; padding: 8px 14px; min-height: 40px; cursor: pointer; transition: background-color .15s; }
.chat-chip:hover { background: var(--yellow); }
.chat-chip:focus-visible, .chat-form textarea:focus-visible, .chat-send:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--paper); }
.chat-form textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; font: 400 15px/1.6 var(--ar); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--paper); }
.chat-form textarea:focus { border-color: var(--ink); }
.chat-send { width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1px solid var(--ink); background: var(--ink); color: var(--yellow); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.chat-send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.chat-send:hover { background: var(--yellow); color: var(--ink); }
.chat-send:disabled { opacity: .5; cursor: progress; }
.chat-privacy { margin: 0; padding: 0 14px 10px; font-size: 12px; color: var(--muted); background: var(--paper); }

@media (max-width: 479px) {
  .htm-chat { left: 12px; bottom: 12px; }
  .chat-fab { width: 56px; height: 56px; }
  .chat-panel { position: fixed; inset: 8px 8px 80px 8px; width: auto; height: auto; }
  .chat-teaser { bottom: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  .htm-chat *, .htm-chat *::before, .htm-chat *::after { animation: none !important; transition: none !important; }
}
