/* ==========================================================================
   Miro — public site AI assistant widget for mersal.it
   Floating green-robot mascot + dark chat panel. Vanilla, theme-agnostic.
   All state is class-driven so the widget.js only toggles classes.
   ========================================================================== */

#miro-root {
  --miro-accent: #22c55e;
  --miro-accent-2: #16a34a;
  --miro-bg1: #0b1220;
  --miro-bg2: #111a2e;
  --miro-panel: rgba(17, 24, 39, .96);
  --miro-line: rgba(148, 197, 168, .16);
  --miro-txt: #e6edf6;
  --miro-muted: #8fa0b6;
  --miro-user: var(--miro-accent);
  --miro-radius: 20px;
  --miro-font: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  position: fixed;
  z-index: 2147483000;
  inset-block-end: 22px;
  inset-inline-end: 22px;
  font-family: var(--miro-font);
  direction: rtl;
}
#miro-root.is-left { inset-inline-end: auto; inset-inline-start: 22px; }
#miro-root *, #miro-root *::before, #miro-root *::after { box-sizing: border-box; }

/* ---------- Launcher (the floating mascot) ---------- */
.miro-fab {
  position: relative;
  width: 92px; height: 92px;
  border: 0; padding: 0; cursor: pointer;
  background: transparent;
  filter: drop-shadow(0 10px 22px rgba(6, 78, 42, .35));
  animation: miroBob 3.4s ease-in-out infinite;
  transition: transform .25s ease;
}
.miro-fab:hover { transform: scale(1.05); }
.miro-fab:focus-visible { outline: 3px solid var(--miro-accent); outline-offset: 4px; border-radius: 50%; }
.miro-fab svg { width: 100%; height: 100%; display: block; overflow: visible; }
.miro-fab.is-hidden { display: none; }

/* pulsing halo behind the mascot */
.miro-fab::after {
  content: ""; position: absolute; inset: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 197, 94, .35), transparent 70%);
  z-index: -1;
  animation: miroHalo 2.6s ease-in-out infinite;
}

@keyframes miroBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes miroHalo { 0%,100% { transform: scale(.85); opacity: .5; } 50% { transform: scale(1.15); opacity: .9; } }

/* the waving arm inside the mascot (origin = shoulder) */
.miro-arm { transform-box: fill-box; transform-origin: 85% 90%; animation: miroWave 2.2s ease-in-out infinite; }
.miro-fab:hover .miro-arm { animation-duration: 1.1s; }
@keyframes miroWave { 0%,60%,100% { transform: rotate(0); } 70% { transform: rotate(16deg); } 80% { transform: rotate(-8deg); } 90% { transform: rotate(12deg); } }

/* the face screen glow */
.miro-face { animation: miroGlow 3s ease-in-out infinite; }
@keyframes miroGlow { 0%,100% { opacity: .92; } 50% { opacity: 1; } }

/* face: glowing display, pointer tracking, blinking, talking */
.miro-eyes, .miro-mouth { filter: drop-shadow(0 0 3px rgba(56, 245, 147, .75)); }
.miro-look { transition: transform .18s ease-out; }
.miro-eyes { transform-box: fill-box; transform-origin: 50% 50%; animation: miroBlink 5.2s ease-in-out infinite; }
@keyframes miroBlink { 0%, 91%, 100% { transform: scaleY(1); } 94%, 98% { transform: scaleY(.12); } 96% { transform: scaleY(.08); } }
.miro-mouth { transform-box: fill-box; transform-origin: 50% 35%; }
#miro-root.is-talking .miro-mouth { animation: miroTalk .34s ease-in-out infinite; }
@keyframes miroTalk { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.65) scaleX(.85); } }
#miro-root.is-talking .miro-head__ava { animation: miroAvaPulse 1s ease-in-out infinite; }
@keyframes miroAvaPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(34, 197, 94, .4); }
  50% { box-shadow: 0 0 0 5px rgba(34, 197, 94, .55); }
}

/* ---------- Teaser speech bubble ---------- */
.miro-teaser {
  position: absolute;
  inset-block-end: 30px;
  inset-inline-end: 96px;
  max-width: 220px;
  background: #fff;
  color: #0f2419;
  font-size: 14px; font-weight: 600; line-height: 1.5;
  padding: 12px 15px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 12px 30px rgba(6, 78, 42, .25);
  opacity: 0; transform: translateY(8px) scale(.9);
  transform-origin: bottom right;
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
#miro-root.is-left .miro-teaser { inset-inline-end: auto; inset-inline-start: 96px; border-radius: 16px 16px 16px 4px; transform-origin: bottom left; }
.miro-teaser.is-show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.miro-teaser__close {
  position: absolute; inset-block-start: -8px; inset-inline-start: -8px;
  width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer;
  background: #0f2419; color: #fff; font-size: 13px; line-height: 22px; padding: 0;
}

/* ---------- Chat panel ---------- */
.miro-panel {
  position: absolute;
  inset-block-end: 0; inset-inline-end: 0;
  width: 380px; max-width: calc(100vw - 32px);
  height: 620px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  border-radius: var(--miro-radius);
  overflow: hidden;
  color: var(--miro-txt);
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(34, 197, 94, .12), transparent 55%),
    linear-gradient(180deg, var(--miro-bg2), var(--miro-bg1));
  border: 1px solid var(--miro-line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(24px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .28s ease, transform .28s cubic-bezier(.2, .8, .3, 1.1);
  pointer-events: none;
}
#miro-root.is-left .miro-panel { transform-origin: bottom left; }
#miro-root.is-open .miro-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* header */
.miro-head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px;
  background: linear-gradient(120deg, rgba(22, 101, 52, .55), rgba(21, 128, 61, .25));
  border-bottom: 1px solid var(--miro-line);
  backdrop-filter: blur(6px);
}
.miro-head__ava {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #2f855a, #0e3a24);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, .4);
}
.miro-head__ava svg { width: 34px; height: 34px; }
.miro-head__meta { flex: 1; min-width: 0; }
.miro-head__name { font-size: 15px; font-weight: 700; }
.miro-head__status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--miro-muted); margin-top: 1px; }
.miro-head__status .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }
.miro-head__btns { display: flex; gap: 6px; }
.miro-iconbtn {
  width: 32px; height: 32px; border-radius: 10px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .08); color: #cfe9d9;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s ease;
}
.miro-iconbtn:hover { background: rgba(255, 255, 255, .16); }
.miro-iconbtn.is-off { opacity: .5; }
.miro-iconbtn svg { width: 17px; height: 17px; }
.miro-iconbtn--wa { background: #22c55e; color: #052e18; }
.miro-iconbtn--wa:hover { background: #16a34a; }

/* body */
.miro-body {
  flex: 1; overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.miro-body::-webkit-scrollbar { width: 6px; }
.miro-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }

.miro-msg {
  max-width: 84%;
  padding: 11px 14px;
  font-size: 14px; line-height: 1.7;
  border-radius: 16px;
  white-space: pre-wrap; word-wrap: break-word;
  animation: miroIn .25s ease;
}
@keyframes miroIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.miro-msg.is-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--miro-line);
  border-bottom-right-radius: 4px;
}
.miro-msg.is-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--miro-accent), var(--miro-accent-2));
  color: #05230f; font-weight: 600;
  border-bottom-left-radius: 4px;
}
.miro-error { align-self: center; color: #fca5a5; font-size: 13px; text-align: center; }

/* typing dots */
.miro-typing { align-self: flex-start; display: flex; gap: 5px; padding: 12px 15px; background: rgba(255,255,255,.06); border: 1px solid var(--miro-line); border-radius: 16px; }
.miro-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--miro-accent); animation: miroType 1.2s infinite ease-in-out; }
.miro-typing span:nth-child(2) { animation-delay: .18s; }
.miro-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes miroType { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* quick-reply chips */
.miro-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 6px; }
.miro-chip {
  border: 1px solid var(--miro-line);
  background: rgba(255, 255, 255, .05);
  color: var(--miro-txt);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 13px; border-radius: 999px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.miro-chip:hover { background: rgba(34, 197, 94, .16); border-color: rgba(34, 197, 94, .5); }
.miro-chip:active { transform: scale(.96); }

/* footer */
.miro-foot { display: flex; align-items: flex-end; gap: 9px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--miro-line); background: rgba(0,0,0,.18); }
.miro-input {
  flex: 1; resize: none; max-height: 96px;
  border: 1px solid var(--miro-line);
  background: rgba(255, 255, 255, .05);
  color: var(--miro-txt);
  font-family: inherit; font-size: 14px; line-height: 1.5;
  padding: 11px 14px; border-radius: 14px;
  outline: none;
}
.miro-input::placeholder { color: var(--miro-muted); }
.miro-input:focus { border-color: rgba(34, 197, 94, .55); background: rgba(255, 255, 255, .08); }
.miro-send {
  flex: 0 0 44px; width: 44px; height: 44px; border: 0; cursor: pointer;
  border-radius: 13px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff; display: flex; align-items: center; justify-content: center;
  transition: transform .1s ease, filter .18s ease;
}
.miro-send:hover { filter: brightness(1.1); }
.miro-send:active { transform: scale(.94); }
.miro-send:disabled { opacity: .5; cursor: default; }
.miro-send svg { width: 19px; height: 19px; }

.miro-powered { text-align: center; font-size: 10px; letter-spacing: .16em; color: var(--miro-muted); padding: 0 0 9px; font-weight: 700; }

/* mobile: fill the screen */
@media (max-width: 480px) {
  #miro-root { inset-block-end: 16px; inset-inline-end: 16px; }
  .miro-panel { width: calc(100vw - 24px); height: calc(100vh - 90px); }
  .miro-fab { width: 78px; height: 78px; }
  .miro-teaser { inset-inline-end: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .miro-fab, .miro-fab::after, .miro-arm, .miro-face,
  .miro-eyes, .miro-mouth, .miro-head__ava { animation: none !important; }
  .miro-look { transition: none; }
}
