/* ═══════════════════════════════════════════════════
   MR. CHATBOT — DEFAULT WIDGET STYLING  (business-agnostic)
   ---------------------------------------------------
   The original project shipped with NO stylesheet — the
   chat panel's look lived entirely in each client site's
   own CSS, targeting the old .guru-* class names. This
   file makes the engine self-contained: drop the whole
   MR-COOL folder into a site, link this stylesheet, and
   the widget already looks clean on both desktop and
   mobile with zero extra CSS required.

   INTEGRATING INTO A SITE THAT ALREADY HAS ITS OWN CHAT
   STYLES (targeting the old .guru-* classes): either link
   this file instead and delete the old rules, or update
   your existing selectors from .guru-* to .mrchat-* (a
   simple find/replace) — see README.md.

   Colours are CSS variables so a brand colour swap for a
   new business takes one edit, right here at the top.
═══════════════════════════════════════════════════ */

:root {
    --mrchat-primary: #88694C;
    --mrchat-primary-dark: #6D543E;
    --mrchat-bg: #FAF6F0;
    --mrchat-bot-bubble: #F1EBE0;
    --mrchat-user-bubble: var(--mrchat-primary);
    --mrchat-text: #0E0C0A;
    --mrchat-muted: #7A7268;
    --mrchat-border: #E7DECF;
    --mrchat-radius: 18px;
    --mrchat-shadow: 0 18px 48px rgba(14, 12, 10, 0.22);
    --mrchat-font: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#mrchat-panel {
    position: fixed;
    right: 20px;
    bottom: calc(20px + var(--vv-bottom, 0px));
    width: min(380px, calc(100vw - 24px));
    height: min(640px, calc(100vh - 100px));
    max-height: 640px;
    display: flex;
    flex-direction: column;
    background: var(--mrchat-bg);
    border-radius: var(--mrchat-radius);
    box-shadow: var(--mrchat-shadow);
    font-family: var(--mrchat-font);
    color: var(--mrchat-text);
    z-index: 2147483000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
    overflow: hidden;
}
#mrchat-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

@media (max-width: 768px) {
    #mrchat-panel {
        right: 0;
        left: 0;
        bottom: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        transform: translateY(8px);
    }
}

/* ── Header ── */
.mrchat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(135deg, var(--mrchat-primary), var(--mrchat-primary-dark));
    color: #fff;
    flex: 0 0 auto;
}
.mrchat-head-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 40px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
}
.mrchat-head-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mrchat-head-title { flex: 1 1 auto; min-width: 0; }
.mrchat-head-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.mrchat-head-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.92;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mrchat-online {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    flex: 0 0 7px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.mrchat-close {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    opacity: 0.9;
    flex: 0 0 auto;
}
.mrchat-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }

/* ── Body / messages ── */
.mrchat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--mrchat-bg);
}

.mrchat-msg {
    max-width: 84%;
    padding: 10px 13px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.mrchat-msg.bot {
    align-self: flex-start;
    background: var(--mrchat-bot-bubble);
    color: var(--mrchat-text);
    border-bottom-left-radius: 4px;
}
.mrchat-msg.user {
    align-self: flex-end;
    background: var(--mrchat-user-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.mrchat-link {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

/* Typing indicator */
.mrchat-msg.bot.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
}
.mrchat-msg.bot.typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--mrchat-muted);
    opacity: 0.5;
    animation: mrchat-blink 1.1s infinite ease-in-out;
}
.mrchat-msg.bot.typing span:nth-child(2) { animation-delay: .15s; }
.mrchat-msg.bot.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mrchat-blink {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

/* ── Quick-reply chips ── */
.mrchat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 0 4px;
}
.mrchat-chip {
    border: 1px solid var(--mrchat-border);
    background: #fff;
    color: var(--mrchat-primary-dark);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 13px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.mrchat-chip:hover { background: #fdf1f5; }
.mrchat-chip:active { transform: scale(0.97); }
.mrchat-chip-primary {
    background: var(--mrchat-primary);
    color: #fff;
    border-color: var(--mrchat-primary);
}
.mrchat-chip-primary:hover { background: var(--mrchat-primary-dark); }
.mrchat-actions { padding-top: 4px; }

/* ── Footer / input ── */
.mrchat-foot {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--mrchat-border);
    background: var(--mrchat-bg);
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.mrchat-input {
    flex: 1 1 auto;
    border: 1px solid var(--mrchat-border);
    border-radius: 999px;
    padding: 10px 15px;
    font-size: 16px; /* keeps iOS from auto-zooming on focus */
    outline: none;
    color: var(--mrchat-text);
    background: #fafafa;
}
.mrchat-input:focus { border-color: var(--mrchat-primary); background: #fff; }
.mrchat-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    background: var(--mrchat-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.mrchat-send svg { width: 18px; height: 18px; fill: currentColor; }
.mrchat-send:hover { background: var(--mrchat-primary-dark); }
.mrchat-send:disabled { opacity: 0.5; cursor: default; }
