/* ============================================================
   Vivaan — AI Concierge Widget (Mangalam Momento)
   Premium styling — reuses site's own CSS vars + Cinzel/Jakarta fonts
   ============================================================ */

/* Kill mobile's default tap-highlight rectangle + focus ring on all
   widget buttons — otherwise Chrome/Safari on mobile briefly show a
   translucent grey/white box over the button after a tap. */
#mm-ai-toggle, #mm-ai-close, #mm-ai-stop-speak, #mm-ai-send, #mm-ai-mic,
.mm-msg-action {
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
#mm-ai-toggle:focus, #mm-ai-close:focus, #mm-ai-stop-speak:focus,
#mm-ai-send:focus, #mm-ai-mic:focus {
    outline: none;
}

@keyframes mmFadeSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mmMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes mmBlink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes mmPulseRing {
    0%   { box-shadow: 0 0 0 0 rgba(220,49,49,0.45); }
    70%  { box-shadow: 0 0 0 10px rgba(220,49,49,0); }
    100% { box-shadow: 0 0 0 0 rgba(220,49,49,0); }
}
@keyframes mmDotGlow {
    0%, 100% { box-shadow: 0 0 0 3px rgba(46,187,121,0.25); }
    50%      { box-shadow: 0 0 0 6px rgba(46,187,121,0.12); }
}

/* ---------- Toggle button ---------- */
#mm-ai-toggle {
    position: fixed;
    right: 24px;
    bottom: 134px; /* clears the site's existing WhatsApp float button (bottom:70px + 45px tall) with a visible gap */
    z-index: 99998;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--base-color, #D9815C) 0%, #b9613f 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 11px 22px 11px 12px;
    box-shadow: 0 10px 30px -6px rgba(217, 129, 92, 0.55), 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    font-family: var(--primary-font, sans-serif);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: transform 0.3s cubic-bezier(.2,.8,.2,1), box-shadow 0.3s ease;
}
#mm-ai-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 36px -6px rgba(217, 129, 92, 0.65), 0 4px 10px rgba(0,0,0,0.18);
}
#mm-ai-toggle:active { transform: translateY(-1px) scale(0.98); }
#mm-ai-toggle .mm-ai-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: rgba(255,255,255,0.2); color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
#mm-ai-toggle .mm-ai-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #2ebb79;
    animation: mmDotGlow 2.4s infinite ease-in-out;
}

/* ---------- Panel ---------- */
#mm-ai-panel {
    position: fixed;
    right: 24px;
    bottom: 134px;
    z-index: 99999;
    width: 388px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 140px);
    background: #fdfbf9;
    border-radius: 22px;
    box-shadow: 0 30px 70px -12px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--primary-font, sans-serif);
    border: 1px solid rgba(255,255,255,0.4);
}
#mm-ai-panel.open {
    display: flex;
    animation: mmFadeSlideUp 0.32s cubic-bezier(.2,.9,.25,1) both;
}

/* ---------- Header ---------- */
#mm-ai-header {
    position: relative;
    background: linear-gradient(135deg, var(--dark-gray, #232323) 0%, #0d0d0d 100%);
    color: #fff;
    padding: 18px 18px 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}
#mm-ai-header::before {
    /* subtle copper glow accent, echoes the hero photography warmth */
    content: '';
    position: absolute;
    top: -40%; right: -20%;
    width: 160px; height: 160px;
    background: radial-gradient(circle, rgba(217,129,92,0.35) 0%, transparent 70%);
    pointer-events: none;
}
#mm-ai-header .mm-ai-avatar-lg {
    width: 44px; height: 44px; border-radius: 50%;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(217,129,92,0.5);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    overflow: hidden;
}
#mm-ai-header .mm-ai-avatar-lg img { width: 100%; height: 100%; object-fit: cover; display: block; }
#mm-ai-header .mm-ai-title {
    font-family: var(--alt-font, serif); font-size: 17px; letter-spacing: 0.6px;
    position: relative; z-index: 1;
}
#mm-ai-header .mm-ai-subtitle {
    font-size: 11px; opacity: 0.6; margin-top: 2px; letter-spacing: 0.2px;
    position: relative; z-index: 1;
}
#mm-ai-close {
    margin-left: auto; background: rgba(255,255,255,0.08); border: none; color: #fff;
    width: 28px; height: 28px; border-radius: 50%; padding: 0; box-sizing: border-box;
    opacity: 0.85; font-size: 20px; cursor: pointer; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s ease, opacity 0.2s ease;
    position: relative; z-index: 1; flex-shrink: 0;
    -webkit-appearance: none; appearance: none;
}
#mm-ai-close:hover { opacity: 1; background: rgba(255,255,255,0.16); }

#mm-ai-stop-speak {
    background: rgba(255,255,255,0.1); border: none; color: #fff;
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
    transition: background 0.2s ease;
    position: relative; z-index: 1; flex-shrink: 0;
}
#mm-ai-stop-speak:hover { background: rgba(255,255,255,0.2); }

/* ---------- Messages ---------- */
#mm-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px 18px;
    background:
        radial-gradient(circle at 100% 0%, rgba(217,129,92,0.06) 0%, transparent 45%),
        #faf7f4;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(217,129,92,0.35) transparent;
}
#mm-ai-messages::-webkit-scrollbar { width: 6px; }
#mm-ai-messages::-webkit-scrollbar-thumb { background: rgba(217,129,92,0.3); border-radius: 10px; }
#mm-ai-messages::-webkit-scrollbar-thumb:hover { background: rgba(217,129,92,0.5); }

.mm-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    animation: mmMsgIn 0.28s ease both;
}
.mm-msg-bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    color: var(--dark-gray, #232323);
    border-bottom-left-radius: 5px;
    white-space: pre-wrap;
}
.mm-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--base-color, #D9815C), #c06a44);
    color: #fff;
    box-shadow: 0 4px 14px rgba(217,129,92,0.3);
    border-bottom-right-radius: 5px;
    white-space: pre-wrap;
}

.mm-msg-action {
    align-self: flex-start;
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: -4px;
    background: #25D366; color: #fff; text-decoration: none;
    padding: 9px 18px; border-radius: 22px; font-size: 13px; font-weight: 600;
    box-shadow: 0 4px 12px rgba(37,211,102,0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: mmMsgIn 0.28s ease both;
}
.mm-msg-action:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(37,211,102,0.45); }
.mm-msg-action.mm-resource {
    background: linear-gradient(135deg, var(--base-color, #D9815C), #c06a44);
    box-shadow: 0 4px 12px rgba(217,129,92,0.35);
}
.mm-msg-action.mm-resource:hover { box-shadow: 0 6px 16px rgba(217,129,92,0.45); }

.mm-quick-actions {
    display: flex; flex-wrap: wrap; gap: 8px;
    align-self: flex-start; max-width: 100%;
    animation: mmMsgIn 0.3s ease both;
}
.mm-quick-btn {
    background: #fff; color: var(--dark-gray, #232323);
    border: 1.5px solid rgba(217,129,92,0.35);
    padding: 8px 14px; border-radius: 20px;
    font-size: 13px; font-weight: 600; font-family: var(--primary-font, sans-serif);
    cursor: pointer; white-space: nowrap;
    transition: all 0.2s ease;
}
.mm-quick-btn:hover {
    background: var(--base-color, #D9815C); color: #fff;
    border-color: var(--base-color, #D9815C);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(217,129,92,0.3);
}

.mm-typing {
    align-self: flex-start; display: flex; gap: 5px;
    padding: 13px 17px; background: #fff; border-radius: 18px;
    border-bottom-left-radius: 5px; border: 1px solid rgba(0,0,0,0.06);
}
.mm-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--base-color, #D9815C);
    animation: mmBlink 1.2s infinite ease-in-out;
}
.mm-typing span:nth-child(2) { animation-delay: 0.2s; }
.mm-typing span:nth-child(3) { animation-delay: 0.4s; }

/* ---------- Input bar ---------- */
#mm-ai-inputbar {
    display: flex; align-items: center; gap: 8px;
    padding: 14px; border-top: 1px solid rgba(0,0,0,0.06);
    background: #fff;
}
#mm-ai-input {
    flex: 1; border: 1.5px solid #e6e0da; border-radius: 24px;
    padding: 11px 18px; font-size: 14px; outline: none; font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #faf9f7;
}
#mm-ai-input:focus {
    border-color: var(--base-color, #D9815C);
    box-shadow: 0 0 0 3px rgba(217,129,92,0.12);
    background: #fff;
}
#mm-ai-send {
    background: linear-gradient(135deg, var(--base-color, #D9815C), #c06a44);
    border: none; color: #fff;
    width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(217,129,92,0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#mm-ai-send:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 6px 16px rgba(217,129,92,0.5); }
#mm-ai-send:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

#mm-ai-mic {
    background: #f4f1ee; border: none; color: #6b5f57;
    width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
    flex-shrink: 0; transition: all 0.2s ease;
}
#mm-ai-mic:hover { background: #ece6e0; }
#mm-ai-mic.mm-recording {
    background: var(--red, #dc3131); color: #fff;
    animation: mmPulseRing 1.4s infinite ease-in-out;
}

@media (max-width: 480px) {
    #mm-ai-panel { right: 8px; left: 8px; width: auto; bottom: 122px; border-radius: 18px; }
    #mm-ai-toggle { right: 12px; bottom: 118px; padding: 10px 18px 10px 10px; }
}
