/* ==========================================================================
   MI Brothers Tech — AI Chatbot & Voice Agent interfaces
   ========================================================================== */

/* ---------- Floating chatbot ---------- */
.chat-launcher {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 1500;
  width: 62px; height: 62px; border-radius: 50%; border: 0;
  background: var(--grad-brand); color: #fff; font-size: 1.6rem;
  display: grid; place-items: center; box-shadow: 0 14px 34px rgba(8, 125, 85, .42);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.chat-launcher:hover { transform: translateY(-3px) scale(1.04); }
.chat-launcher::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(37, 185, 165, .55); animation: ring 2.4s var(--ease) infinite; }
.chat-launcher .i-close { display: none; }
.chat-launcher[aria-expanded="true"] .i-open { display: none; }
.chat-launcher[aria-expanded="true"] .i-close { display: block; }
.chat-launcher[aria-expanded="true"]::before { display: none; }
.chat-launcher .badge { position: absolute; top: -2px; right: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--c-highlight); color: var(--c-ink); font-size: .7rem; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.chat-launcher[aria-expanded="true"] .badge { display: none; }

.chat-teaser { position: fixed; right: 5.6rem; bottom: 1.9rem; z-index: 1499; background: #fff; border: 1px solid var(--c-line); border-radius: 16px 16px 4px 16px; padding: .65rem .9rem; box-shadow: var(--sh-md); font-size: var(--fs-xs); font-weight: 500; max-width: 220px; opacity: 0; transform: translateY(8px); transition: all .4s var(--ease); pointer-events: none; }
.chat-teaser.is-visible { opacity: 1; transform: none; }

.chat-window {
  position: fixed; inset: 0; z-index: 1600;
  display: flex; flex-direction: column; background: #fff;
  opacity: 0; visibility: hidden; transform: translateY(24px) scale(.98); transform-origin: bottom right;
  transition: opacity .35s var(--ease), transform .35s var(--ease), visibility 0s linear .35s;
}
.chat-window.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

.chat-header { background: var(--grad-dark); color: #fff; padding: 1rem 1rem 1rem 1.15rem; display: flex; align-items: center; gap: .8rem; position: relative; overflow: hidden; flex: none; }
.chat-header::after { content: ""; position: absolute; width: 180px; height: 180px; right: -60px; top: -90px; border-radius: 50%; background: radial-gradient(circle, rgba(37, 185, 165, .5), transparent 70%); }
.chat-avatar { width: 42px; height: 42px; border-radius: 14px; background: rgba(255, 255, 255, .12); display: grid; place-items: center; font-size: 1.25rem; position: relative; flex: none; }
.chat-avatar::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: #3ee39b; border: 2px solid #06603F; }
.chat-title { flex: 1; min-width: 0; position: relative; z-index: 1; }
.chat-title strong { display: block; font-family: var(--ff-head); font-size: 1rem; }
.chat-title small { color: #B9D6C9; font-size: .75rem; }
.demo-pill { display: inline-block; background: var(--c-highlight); color: #4b4610; font-size: .62rem; font-weight: 700; padding: .1rem .45rem; border-radius: var(--r-pill); letter-spacing: .05em; text-transform: uppercase; margin-left: .35rem; vertical-align: 1px; }
.chat-hbtn { position: relative; z-index: 1; width: 36px; height: 36px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: #fff; display: grid; place-items: center; font-size: 1rem; transition: background .25s; }
.chat-hbtn:hover { background: rgba(255, 255, 255, .16); }

.chat-body { flex: 1; overflow-y: auto; padding: 1.1rem; background: var(--c-bg); display: flex; flex-direction: column; gap: .7rem; scroll-behavior: smooth; overscroll-behavior: contain; }
.msg { max-width: 86%; padding: .7rem .95rem; border-radius: 16px; font-size: .92rem; line-height: 1.5; animation: msg-in .35s var(--ease); word-wrap: break-word; }
.msg p { margin: 0 0 .45rem; } .msg p:last-child { margin: 0; }
.msg ul { padding-left: 1.1rem; margin: .3rem 0; }
.msg a { font-weight: 600; text-decoration: underline; }
.msg-bot { align-self: flex-start; background: #fff; border: 1px solid var(--c-line); border-bottom-left-radius: 4px; box-shadow: var(--sh-xs); }
.msg-user { align-self: flex-end; background: var(--grad-brand); color: #fff; border-bottom-right-radius: 4px; }
.msg-user a { color: #fff; }
.msg-time { display: block; font-size: .66rem; opacity: .6; margin-top: .3rem; }
.msg-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.msg-actions a, .msg-actions button { font-size: .78rem; font-weight: 600; padding: .4rem .75rem; border-radius: var(--r-pill); border: 1px solid var(--c-primary); color: var(--c-primary); background: #fff; text-decoration: none; display: inline-flex; gap: .3rem; align-items: center; }
.msg-actions a:hover, .msg-actions button:hover { background: var(--c-primary); color: #fff; }

.typing { align-self: flex-start; background: #fff; border: 1px solid var(--c-line); border-radius: 16px; border-bottom-left-radius: 4px; padding: .8rem 1rem; display: inline-flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--c-accent); animation: typing 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }

.chat-quick { display: flex; gap: .4rem; overflow-x: auto; padding: .65rem 1rem; background: #fff; border-top: 1px solid var(--c-line); flex: none; scrollbar-width: none; }
.chat-quick::-webkit-scrollbar { display: none; }
.chat-quick button { flex: none; border: 1px solid var(--c-line); background: var(--c-bg); padding: .45rem .8rem; border-radius: var(--r-pill); font-size: .78rem; font-weight: 500; transition: all .25s; }
.chat-quick button:hover { border-color: var(--c-primary); color: var(--c-primary); background: #fff; }

.chat-form { display: flex; gap: .5rem; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--c-line); flex: none; }
.chat-form input { flex: 1; border: 1.5px solid var(--c-line); border-radius: var(--r-pill); padding: .7rem 1rem; background: var(--c-bg); min-width: 0; font-size: 16px; /* prevents iOS zoom */ }
.chat-form input:focus { outline: none; border-color: var(--c-primary); background: #fff; }
.chat-send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--grad-brand); color: #fff; display: grid; place-items: center; font-size: 1.05rem; flex: none; transition: transform .25s var(--ease); }
.chat-send:hover { transform: scale(1.06); }
.chat-send:disabled { opacity: .5; transform: none; cursor: not-allowed; }
.chat-foot { text-align: center; font-size: .68rem; color: var(--c-muted); padding: 0 1rem .55rem; background: #fff; flex: none; }

/* ---------- Voice agent ---------- */
.voice-shell { background: var(--grad-dark); border-radius: var(--r-xl); padding: clamp(1.25rem, 1rem + 2vw, 2.5rem); color: #DDEDE5; position: relative; overflow: hidden; display: grid; gap: var(--sp-6); }
.voice-shell::before { content: ""; position: absolute; width: 500px; height: 500px; border-radius: 50%; left: 50%; top: -260px; transform: translateX(-50%); background: radial-gradient(circle, rgba(37, 185, 165, .35), transparent 65%); pointer-events: none; }
.voice-shell > * { position: relative; }
.voice-stage { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-4); }
.voice-status { display: inline-flex; align-items: center; gap: .5rem; padding: .4rem .9rem; border-radius: var(--r-pill); background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); font-size: .8rem; font-weight: 600; color: #fff; }
.voice-status .led { width: 9px; height: 9px; border-radius: 50%; background: #8FB8A6; }
.voice-shell[data-state="listening"] .voice-status .led { background: #3ee39b; animation: pulse-dot 1.2s infinite; }
.voice-shell[data-state="thinking"] .voice-status .led { background: var(--c-highlight); animation: pulse-dot .8s infinite; }
.voice-shell[data-state="speaking"] .voice-status .led { background: var(--c-accent); animation: pulse-dot 1s infinite; }
.voice-shell[data-state="error"] .voice-status .led { background: #ff8a73; }

.mic-wrap { position: relative; width: 168px; height: 168px; display: grid; place-items: center; }
.mic-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(37, 185, 165, .4); opacity: 0; }
.voice-shell[data-state="listening"] .mic-ring, .voice-shell[data-state="speaking"] .mic-ring { animation: ring 2s var(--ease) infinite; }
.voice-shell[data-state="listening"] .mic-ring:nth-child(2), .voice-shell[data-state="speaking"] .mic-ring:nth-child(2) { animation-delay: .65s; }
.voice-shell[data-state="listening"] .mic-ring:nth-child(3), .voice-shell[data-state="speaking"] .mic-ring:nth-child(3) { animation-delay: 1.3s; }
.mic-btn { width: 112px; height: 112px; border-radius: 50%; border: 0; background: #fff; color: var(--c-primary); font-size: 2.4rem; display: grid; place-items: center; box-shadow: 0 0 0 10px rgba(255, 255, 255, .06), 0 20px 50px rgba(0, 0, 0, .3); transition: transform .3s var(--ease), background .3s, color .3s; position: relative; z-index: 1; }
.mic-btn:hover { transform: scale(1.05); }
.voice-shell[data-state="listening"] .mic-btn { background: var(--grad-brand); color: #fff; }
.voice-canvas { width: 100%; max-width: 460px; height: 80px; }
.voice-hint { font-size: var(--fs-sm); color: #B9D6C9; max-width: 440px; margin: 0; }
.voice-controls { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.voice-controls .btn[disabled] { opacity: .45; pointer-events: none; }

.voice-transcript { background: rgba(255, 255, 255, .96); color: var(--c-ink); border-radius: var(--r-lg); display: flex; flex-direction: column; min-height: 360px; max-height: 480px; overflow: hidden; }
.vt-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem; border-bottom: 1px solid var(--c-line); }
.vt-head strong { font-family: var(--ff-head); font-size: .95rem; display: flex; gap: .45rem; align-items: center; }
.vt-head strong i { color: var(--c-primary); }
.vt-body { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .6rem; background: var(--c-bg); }
.vt-line { font-size: .9rem; padding: .6rem .85rem; border-radius: 14px; max-width: 90%; animation: msg-in .3s var(--ease); }
.vt-line.you { align-self: flex-end; background: var(--grad-brand); color: #fff; border-bottom-right-radius: 4px; }
.vt-line.agent { align-self: flex-start; background: #fff; border: 1px solid var(--c-line); border-bottom-left-radius: 4px; }
.vt-line.interim { opacity: .65; font-style: italic; }
.vt-line.system { align-self: center; background: transparent; color: var(--c-muted); font-size: .78rem; text-align: center; }
.vt-form { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--c-line); background: #fff; }
.vt-form input { flex: 1; min-width: 0; border: 1.5px solid var(--c-line); border-radius: var(--r-pill); padding: .6rem .95rem; background: var(--c-bg); font-size: 16px; }
.vt-form input:focus { outline: none; border-color: var(--c-primary); }
