/* ==========================================================================
   MindDo — "Mindy" demo-booking chatbot
   Uses the colour variables from style.css, so it follows light and dark mode.
   ========================================================================== */

.mbot { position: fixed; right: clamp(12px, 2.5vw, 26px); bottom: clamp(12px, 2.5vw, 26px); z-index: 150; font-family: var(--font-body); }
.mbot [hidden] { display: none !important; }

/* ---------- robot ---------- */
.mbot-robot { display: block; overflow: visible; }
.mbot-robot .r-all { animation: mbot-bob 3.2s ease-in-out infinite; }
.mbot-robot .r-arm { transform-box: view-box; transform-origin: 86px 84px; animation: mbot-wave 4.5s ease-in-out infinite; }
.mbot-robot .r-eye { transform-box: fill-box; transform-origin: center; animation: mbot-blink 4.5s infinite; }
.mbot-robot .r-light { animation: mbot-pulse 1.6s ease-in-out infinite; }

@keyframes mbot-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes mbot-wave {
  0%, 44%, 100% { transform: rotate(0deg); }
  6%, 18%, 30% { transform: rotate(-22deg); }
  12%, 24%, 36% { transform: rotate(12deg); }
}
@keyframes mbot-blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }
@keyframes mbot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- launcher ---------- */
.mbot-launch {
  position: relative; display: grid; place-items: center; width: 76px; height: 76px; margin-left: auto;
  border: 2px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer;
  box-shadow: var(--shadow-lg); transition: transform .2s ease, border-color .2s ease;
}
.mbot-launch:hover { transform: translateY(-2px) scale(1.04); border-color: var(--aqua); }
.mbot-launch:focus-visible, .mbot-x:focus-visible, .mbot-chip:focus-visible, .mbot-send:focus-visible { outline: 3px solid var(--aqua); outline-offset: 2px; }
.mbot-launch .mbot-robot { width: 62px; height: 62px; }
.mbot-launch::after {
  content: ""; position: absolute; right: 4px; top: 4px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--sun); border: 2px solid var(--surface);
}

.mbot-hello {
  position: absolute; right: 6px; bottom: 90px; width: max-content; max-width: min(250px, calc(100vw - 40px));
  display: flex; align-items: flex-start; gap: 8px; padding: 12px 12px 12px 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 18px 18px 4px 18px;
  box-shadow: var(--shadow-md); font-size: 15px; line-height: 1.4; cursor: pointer;
  animation: mbot-pop .35s cubic-bezier(.2, 1.3, .4, 1) both;
}
.mbot-hello b { display: block; font-family: var(--font-display); font-size: 15px; }
.mbot-hello span { color: var(--text-2); }
.mbot-x {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 20px; cursor: pointer;
}
.mbot-x:hover { background: var(--bg-alt); color: var(--text); }
@keyframes mbot-pop { from { opacity: 0; transform: translateY(8px) scale(.92); } to { opacity: 1; transform: none; } }

/* ---------- panel ---------- */
.mbot-panel {
  position: absolute; right: 0; bottom: 0; display: flex; flex-direction: column;
  width: min(380px, calc(100vw - 24px)); height: min(600px, calc(100vh - 100px)); height: min(600px, calc(100dvh - 100px));
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: mbot-pop .28s ease both;
}
.mbot-head {
  flex: none; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; color: #fff;
  background: linear-gradient(120deg, #0c3b52, #0e9c9c 65%, #22c3c0);
}
.mbot-ava { flex: none; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, .95); }
.mbot-ava .mbot-robot { width: 42px; height: 42px; }
.mbot-head h2 { margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 700; color: #fff; line-height: 1.2; }
.mbot-head p { margin: 2px 0 0; font-size: 13px; color: #dcf5f4; display: flex; align-items: center; gap: 6px; }
.mbot-head p::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fba918; }
.mbot-head .mbot-x { margin-left: auto; width: 36px; height: 36px; color: #fff; font-size: 24px; }
.mbot-head .mbot-x:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.mbot-bar { flex: none; height: 4px; background: var(--bg-alt); }
.mbot-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--aqua)); transition: width .35s ease; }

.mbot-log { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); overscroll-behavior: contain; }
.mbot-msg { max-width: 86%; padding: 10px 14px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; animation: mbot-pop .22s ease both; }
.mbot-msg--bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; }
.mbot-msg--me { align-self: flex-end; background: var(--blue); color: #fff; border-radius: 16px 16px 4px 16px; }
.mbot-msg--ok { border-color: var(--teal); }
.mbot-msg--err { border-color: var(--orange); }
.mbot-msg a { color: var(--blue); font-weight: 600; text-decoration: underline; }

.mbot-sum { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.mbot-sum dt { color: var(--muted); }
.mbot-sum dd { margin: 0; font-weight: 600; }

.mbot-typing { display: flex; gap: 5px; padding: 14px; }
.mbot-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: mbot-dot 1s infinite; }
.mbot-typing i:nth-child(2) { animation-delay: .15s; }
.mbot-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes mbot-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.mbot-chips { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 14px 4px; background: var(--bg); }
.mbot-chips:empty { display: none; }
.mbot-chip {
  padding: 8px 14px; min-height: 38px; border: 1.5px solid var(--blue); border-radius: 999px; background: var(--surface);
  color: var(--blue); font: 600 14px var(--font-body); cursor: pointer; transition: background .15s, color .15s;
}
.mbot-chip:hover { background: var(--blue); color: #fff; }
.mbot-chip--main { background: var(--orange); border-color: var(--orange); color: #fff; }
.mbot-chip--main:hover { background: var(--orange-deep); border-color: var(--orange-deep); }

.mbot-form { flex: none; display: flex; gap: 8px; padding: 10px 12px 12px; background: var(--bg); border-top: 1px solid var(--line); }
.mbot-form input[type="text"], .mbot-form input[type="email"], .mbot-form input[type="tel"] {
  flex: 1; min-width: 0; height: 46px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); font: 16px var(--font-body);
}
.mbot-form input:focus { outline: none; border-color: var(--aqua); }
.mbot-form input::placeholder { color: var(--muted); }
.mbot-send {
  flex: none; display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 50%;
  background: var(--orange); color: #fff; font-size: 22px; cursor: pointer;
}
.mbot-send:hover { background: var(--orange-deep); }
.mbot-send:disabled, .mbot-form input:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 520px) {
  .mbot.is-open { right: 0; bottom: 0; left: 0; }
  .mbot-panel { position: fixed; inset: auto 0 0 0; width: 100%; height: min(88vh, 640px); height: min(88dvh, 640px); border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; }
  .mbot-launch { width: 68px; height: 68px; }
  .mbot-launch .mbot-robot { width: 54px; height: 54px; }
  .mbot-hello { bottom: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  .mbot-robot .r-all, .mbot-robot .r-arm, .mbot-robot .r-eye, .mbot-robot .r-light,
  .mbot-hello, .mbot-panel, .mbot-msg, .mbot-typing i { animation: none; }
}
