@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ── Launcher ─────────────────────────────────────────────────── */
#mp-chat-launcher {
    position: fixed; bottom: 80px; right: 16px; z-index: 1100;
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--accent, #d4546a); color: #fff;
    border: none; cursor: pointer; overflow: hidden;
    box-shadow: 0 6px 24px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.12);
    display: flex; align-items: center; justify-content: center; font-size: 22px;
    -webkit-tap-highlight-color: transparent;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), background .2s, box-shadow .2s;
}
#mp-chat-launcher:hover { transform: scale(1.08); box-shadow: 0 10px 32px rgba(0,0,0,.28); }
#mp-chat-launcher.is-open { background: var(--ink, #1a0a06); }
.lch-icon-chat, .lch-icon-close { position: absolute; transition: opacity .2s, transform .2s; }
.lch-icon-close { opacity: 0; transform: scale(.6) rotate(-45deg); }
#mp-chat-launcher.is-open .lch-icon-chat  { opacity: 0; transform: scale(.6) rotate(45deg); }
#mp-chat-launcher.is-open .lch-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }
.lch-badge {
    position: absolute; top: -2px; right: -2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #f59e0b; color: #fff; font-size: 9.5px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; animation: lch-pop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes lch-pop { from { transform: scale(0); } to { transform: scale(1); } }
.lch-tooltip {
    position: fixed; bottom: 96px; right: 80px;
    background: #1a0a06; color: #fff;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px; font-weight: 600; padding: 7px 13px;
    border-radius: 99px; white-space: nowrap; z-index: 1100;
    box-shadow: 0 4px 14px rgba(0,0,0,.2); pointer-events: none;
    animation: lch-tip .5s cubic-bezier(.34,1.56,.64,1) .8s both;
}
.lch-tooltip::after {
    content: ''; position: absolute; right: -6px; top: 50%;
    transform: translateY(-50%); border: 6px solid transparent;
    border-left-color: #1a0a06; border-right: 0;
}
@keyframes lch-tip { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

/* ── Chat window ──────────────────────────────────────────────── */
#mp-chat-window {
    position: fixed; bottom: 148px; right: 16px; z-index: 1099;
    width: min(360px, calc(100vw - 28px));
    height: min(520px, calc(100dvh - 200px));
    display: flex; flex-direction: column;
    background: #fdf8f4; border-radius: 20px; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.2), 0 4px 16px rgba(0,0,0,.1);
    border: 1px solid #e8ddd6;
    transform-origin: bottom right;
    transform: scale(.85) translateY(20px); opacity: 0; pointer-events: none;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
}
#mp-chat-window.is-open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* Header */
.cw-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent, #d4546a), var(--accent-dk, #b8394f));
    padding: 14px 16px 12px; display: flex; align-items: center; gap: 11px;
}
.cw-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,.25); font-size: 18px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(255,255,255,.4);
}
.cw-header-text { flex: 1; }
.cw-name { font-family: 'Cormorant Garamond', serif; font-size: 16px; font-weight: 700; color: #fff; line-height: 1.1; }
.cw-status { font-size: 10.5px; color: rgba(255,255,255,.82); font-weight: 500; display: flex; align-items: center; gap: 4px; }
.cw-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; animation: lch-pop .4s; }

/* ── Messages — this is the ONLY scrollable zone ─────────────── */
.cw-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* KEY: padding-bottom gives space so last bubble never hides behind input */
    padding: 14px 14px 12px;
    display: flex; flex-direction: column; gap: 10px;
    scrollbar-width: thin; scrollbar-color: #e8ddd6 transparent;
    /* smooth momentum scrolling on iOS */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.cw-messages::-webkit-scrollbar { width: 4px; }
.cw-messages::-webkit-scrollbar-thumb { background: #e8ddd6; border-radius: 4px; }

/* Bubbles */
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.msg-bot  { justify-content: flex-start; }
.msg-user { justify-content: flex-end; }
.msg-bot-icon {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; align-self: flex-end;
    background: linear-gradient(135deg, var(--accent, #d4546a), var(--accent-dk, #b8394f));
    color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.bubble {
    padding: 10px 13px; border-radius: 16px;
    font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13px; line-height: 1.58;
    max-width: calc(100% - 44px);
    animation: msg-in .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(.95); } to { opacity: 1; transform: none; } }
.bubble-bot  { background: #fff; color: #1a0a06; border: 1px solid #e8ddd6; border-bottom-left-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.bubble-user { background: var(--accent, #d4546a); color: #fff; border-bottom-right-radius: 4px; }
.bubble-bot a { color: var(--accent, #d4546a); font-weight: 700; text-decoration: underline; }

/* Typing dots */
.typing-dots { display: flex; gap: 4px; padding: 4px 2px; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: #9b7c73; opacity: .6; animation: ty-dot .9s ease infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes ty-dot { 0%,80%,100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* ── Quick-reply chips — NOW INLINE inside .cw-messages ─────── */
/* They appear as a message row, scroll naturally with the thread  */
.cw-chips-row {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 2px 0 4px;
    /* left indent to align with bot bubbles */
    padding-left: 36px;
    animation: msg-in .3s cubic-bezier(.34,1.56,.64,1);
}
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: #fff; border: 1.5px solid #e8ddd6;
    color: #1a0a06; font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11.5px; font-weight: 600; padding: 6px 12px;
    border-radius: 99px; cursor: pointer; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { background: var(--accent-lt, #fce8ed); border-color: var(--accent, #d4546a); color: var(--accent, #d4546a); }
/* Chips that have been used get dimmed */
.chip.used { opacity: .45; pointer-events: none; }

/* ── Input bar — fixed at bottom, never overlaps messages ─────── */
.cw-input-wrap {
    flex-shrink: 0;
    padding: 10px 12px; background: #fff;
    border-top: 1px solid #e8ddd6;
    display: flex; align-items: center; gap: 8px;
}
.cw-input {
    flex: 1; border: 1.5px solid #e8ddd6; border-radius: 12px;
    padding: 9px 13px; font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px; color: #1a0a06; background: #fdf8f4;
    outline: none; resize: none;
    transition: border-color .15s, box-shadow .15s;
}
.cw-input:focus { border-color: var(--accent, #d4546a); box-shadow: 0 0 0 3px var(--accent-lt, #fce8ed); }
.cw-input::placeholder { color: #9b7c73; }
.cw-send {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    background: var(--accent, #d4546a); color: #fff; border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 15px; -webkit-tap-highlight-color: transparent;
    transition: background .15s, transform .15s;
}
.cw-send:hover  { background: var(--accent-dk, #b8394f); transform: scale(1.05); }
.cw-send:disabled { background: #e8ddd6; cursor: not-allowed; transform: none; }
.cw-powered { flex-shrink: 0; text-align: center; font-size: 9.5px; color: #c8b8b2; padding: 0 0 7px; }
