/* =========================================================
   MandiKhata — live chat launcher + popup (assets/js/chat.js)
   ========================================================= */
.float-chat-row { gap: .75rem; }
.chat-float {
    position: relative; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(140deg, #0ea5e9 0%, #2563eb 55%, #4f46e5 100%);
    box-shadow: 0 10px 30px rgba(37,99,235,.45); transition: transform .3s ease;
}
.chat-float[hidden] { display: none; }
.chat-float svg { width: 30px; height: 30px; }
.chat-float:hover { transform: scale(1.08) rotate(6deg); }
.chat-float::after {
    content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid rgba(59,130,246,.55);
    animation: mkc-ring 2.4s ease-out infinite; pointer-events: none;
}
.chat-float[aria-expanded="true"]::after { display: none; }
@keyframes mkc-ring { 0% { transform: scale(.9); opacity: .9; } 80%, 100% { transform: scale(1.35); opacity: 0; } }
.chat-float-badge {
    position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
    background: #ef4444; color: #fff; font: 700 .72rem/20px 'Quicksand', system-ui, sans-serif; border: 2px solid #fff;
}
.chat-float-badge[hidden] { display: none; }

/* ---------- popup ---------- */
.mkc-panel {
    --mkc-bg: #ffffff; --mkc-soft: #f1f5f9; --mkc-line: rgba(15,23,42,.08); --mkc-text: #0f172a; --mkc-muted: #526072;
    --mkc-me: linear-gradient(135deg, #047857, #065f46); --mkc-accent: #2563eb;
    position: fixed; right: 24px; bottom: 166px; z-index: 1002; width: 384px; height: 600px; max-height: calc(100vh - 186px);
    display: flex; flex-direction: column; overflow: hidden; border-radius: 22px;
    background: var(--mkc-bg); color: var(--mkc-text); border: 1px solid var(--mkc-line);
    box-shadow: 0 30px 80px -20px rgba(15,23,42,.45), 0 2px 6px rgba(15,23,42,.06);
    font-family: 'Quicksand', 'Noto Sans Devanagari', system-ui, sans-serif;
    opacity: 0; transform: translateY(14px) scale(.98); transform-origin: bottom right; transition: opacity .2s ease, transform .2s ease;
}
.mkc-panel[hidden] { display: none; }
.mkc-panel.is-open { opacity: 1; transform: none; }
html[data-theme="dark"] .mkc-panel {
    --mkc-bg: #0f172a; --mkc-soft: #1e293b; --mkc-line: rgba(255,255,255,.08); --mkc-text: #f8fafc; --mkc-muted: #a3b1c6;
    box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
}

.mkc-head { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid var(--mkc-line); }
.mkc-ava {
    position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff;
    background: linear-gradient(140deg, #0ea5e9 0%, #2563eb 55%, #4f46e5 100%);
}
.mkc-ava svg { width: 25px; height: 25px; }
.mkc-dot { position: absolute; right: 0; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: #22c55e; border: 2px solid var(--mkc-bg); }
.mkc-panel.is-off .mkc-dot { background: #f59e0b; }
.mkc-who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mkc-who b { font-size: 1rem; font-weight: 700; }
.mkc-who small { font-size: .76rem; color: var(--mkc-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mkc-ic {
    flex: none; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--mkc-muted);
    display: grid; place-items: center; cursor: pointer; transition: background .2s ease, color .2s ease;
}
.mkc-ic svg { width: 20px; height: 20px; }
.mkc-ic:hover { background: var(--mkc-soft); color: var(--mkc-text); }

.mkc-body { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .55rem; overscroll-behavior: contain; scroll-behavior: smooth; }
.mkc-row { display: flex; flex-direction: column; align-items: flex-start; max-width: 86%; }
.mkc-row.mkc-me { align-self: flex-end; align-items: flex-end; }
.mkc-bubble {
    padding: .65rem .9rem; border-radius: 16px 16px 16px 4px; background: var(--mkc-soft); color: var(--mkc-text);
    font-size: .93rem; line-height: 1.5; font-weight: 500; white-space: pre-line; overflow-wrap: anywhere;
}
.mkc-bubble a { color: var(--mkc-accent); font-weight: 600; }
.mkc-me .mkc-bubble { background: var(--mkc-me); color: #fff; border-radius: 16px 16px 4px 16px; }
.mkc-me .mkc-bubble a { color: #fff; }
.mkc-me.is-pending { opacity: .65; }
.mkc-agent .mkc-bubble { background: rgba(37,99,235,.1); border: 1px solid rgba(37,99,235,.25); }
.mkc-tag { font-size: .7rem; font-weight: 700; color: var(--mkc-accent); margin: 0 0 .2rem .3rem; }
html[data-theme="dark"] .mkc-panel { --mkc-accent: #7cb3ff; }

/* menu (first screen) */
.mkc-menu { display: flex; flex-direction: column; margin: .2rem 0 .3rem; }
.mkc-menu-item {
    display: flex; align-items: center; gap: .8rem; width: 100%; padding: .7rem .4rem; border: 0; border-bottom: 1px solid var(--mkc-line);
    background: none; color: var(--mkc-text); font: 600 .93rem/1.3 inherit; font-family: inherit; text-align: left; cursor: pointer; border-radius: 10px;
    transition: background .2s ease;
}
.mkc-menu-item:last-child { border-bottom: 0; }
.mkc-menu-item:hover { background: var(--mkc-soft); }
.mkc-menu-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--mkc-soft); font-size: 1.05rem; }
.mkc-menu-item:nth-child(6n+1) .mkc-menu-ico { background: #e0f2fe; }
.mkc-menu-item:nth-child(6n+2) .mkc-menu-ico { background: #fef3c7; }
.mkc-menu-item:nth-child(6n+3) .mkc-menu-ico { background: #dcfce7; }
.mkc-menu-item:nth-child(6n+4) .mkc-menu-ico { background: #fce7f3; }
.mkc-menu-item:nth-child(6n+5) .mkc-menu-ico { background: #ede9fe; }
.mkc-menu-item:nth-child(6n+6) .mkc-menu-ico { background: #ffedd5; }
html[data-theme="dark"] .mkc-menu-ico { background: #1e293b !important; }
.mkc-menu-label { flex: 1; min-width: 0; }
.mkc-menu-arrow { flex: none; color: var(--mkc-muted); display: grid; }
.mkc-menu-arrow svg { width: 18px; height: 18px; transition: transform .2s ease; }
.mkc-menu-item:hover .mkc-menu-arrow svg { transform: translateX(3px); }

/* quick replies under a bot answer */
.mkc-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .1rem 0 .3rem; }
.mkc-chip {
    padding: .45rem .8rem; border-radius: 999px; border: 1px solid rgba(37,99,235,.35); background: transparent; color: var(--mkc-accent);
    font: 600 .82rem/1.2 inherit; font-family: inherit; cursor: pointer; transition: background .2s ease;
}
.mkc-chip:hover { background: rgba(37,99,235,.08); }
.mkc-chips.is-old { display: none; }

.mkc-typing .mkc-bubble { display: flex; gap: 4px; padding: .8rem .95rem; }
.mkc-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--mkc-muted); animation: mkc-dots 1s infinite ease-in-out; }
.mkc-typing i:nth-child(2) { animation-delay: .15s; }
.mkc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes mkc-dots { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.mkc-foot { display: flex; align-items: center; gap: .5rem; margin: 0 .85rem; padding: .35rem .4rem .35rem .95rem; border-radius: 16px; border: 1.5px solid rgba(37,99,235,.45); background: var(--mkc-bg); }
.mkc-foot:focus-within { border-color: var(--mkc-accent); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.mkc-foot input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--mkc-text); font: 500 .95rem/1.4 inherit; font-family: inherit; padding: .55rem 0; }
.mkc-foot input::placeholder { color: var(--mkc-muted); }
.mkc-foot button {
    flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
    background: var(--mkc-accent); color: #fff; transition: transform .2s ease;
}
.mkc-foot button svg { width: 19px; height: 19px; }
.mkc-foot button:hover { transform: scale(1.06); }
html[data-theme="dark"] .mkc-foot button { background: #2563eb; }
.mkc-note { margin: .45rem 0 .65rem; text-align: center; font-size: .7rem; font-weight: 600; color: var(--mkc-muted); }

@media (max-width: 600px) {
    .mkc-panel { left: 0; right: 0; bottom: 0; width: auto; height: min(88vh, 680px); max-height: none; border-radius: 22px 22px 0 0; transform-origin: bottom center; }
    html.mkc-open .float-actions { visibility: hidden; }
    .mkc-foot input { font-size: 16px; } /* no zoom-on-focus on iPhone */
}
@media (prefers-reduced-motion: reduce) {
    .chat-float::after, .mkc-typing i { animation: none; }
    .mkc-panel { transition: none; }
}
