/* ── Almamate AI Chatbot v2.0 ─────────────────────────────────────────────── */
:root {
    --alm-primary:     #2563eb;
    --alm-primary-dk:  #1d4ed8;
    --alm-bg:          #ffffff;
    --alm-surface:     #f8fafc;
    --alm-border:      #e2e8f0;
    --alm-text:        #1e293b;
    --alm-muted:       #64748b;
    --alm-user-bg:     var(--alm-primary);
    --alm-bot-bg:      #f1f5f9;
    --alm-radius:      16px;
    --alm-shadow:      0 20px 60px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.1);
    --alm-launcher-sz: 58px;
    --alm-win-width:   360px;
    --alm-win-height:  520px;
    --alm-z:           99999;
    --alm-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --alm-anim:        .25s cubic-bezier(.4,0,.2,1);
}

/* ── Launcher ─────────────────────────────────────────────────────────────── */
#almamate-chatbot { position: fixed; bottom: 24px; right: 24px; z-index: var(--alm-z); font-family: var(--alm-font); }

#almamate-launcher {
    width:  var(--alm-launcher-sz);
    height: var(--alm-launcher-sz);
    border-radius: 50%;
    background: var(--alm-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37,99,235,.45);
    transition: transform var(--alm-anim), box-shadow var(--alm-anim), background var(--alm-anim);
    position: relative;
    z-index: 2;
}
#almamate-launcher:hover  { transform: scale(1.08); box-shadow: 0 6px 28px rgba(37,99,235,.55); background: var(--alm-primary-dk); }
#almamate-launcher:focus-visible { outline: 3px solid rgba(37,99,235,.5); outline-offset: 3px; }

/* Pulse ring on launcher when closed */
#almamate-launcher::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(37,99,235,.4);
    animation: alm-pulse 2.4s ease-in-out infinite;
}
#almamate-chatbot.open #almamate-launcher::before { display: none; }

@keyframes alm-pulse {
    0%   { transform: scale(1);   opacity: 1; }
    70%  { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* ── Chat Window ──────────────────────────────────────────────────────────── */
#almamate-window {
    position: absolute;
    bottom: calc(var(--alm-launcher-sz) + 14px);
    right: 0;
    width: var(--alm-win-width);
    max-width: calc(100vw - 32px);
    height: var(--alm-win-height);
    max-height: calc(100vh - 120px);
    background: var(--alm-bg);
    border-radius: var(--alm-radius);
    box-shadow: var(--alm-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(.85) translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--alm-anim), opacity var(--alm-anim);
}
#almamate-chatbot.open #almamate-window {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
#almamate-header {
    background: var(--alm-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#almamate-header-info { display: flex; align-items: center; gap: 10px; }
#almamate-avatar {
    width: 38px; height: 38px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
#almamate-bot-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
#almamate-status   { font-size: 11px; opacity: .85; display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.almamate-dot {
    width: 7px; height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: alm-blink 2s ease-in-out infinite;
}
@keyframes alm-blink { 0%,100%{opacity:1} 50%{opacity:.4} }

#almamate-close-btn {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 30px; height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--alm-anim);
    flex-shrink: 0;
}
#almamate-close-btn:hover { background: rgba(255,255,255,.28); }

/* ── Messages ─────────────────────────────────────────────────────────────── */
#almamate-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#almamate-messages::-webkit-scrollbar { width: 4px; }
#almamate-messages::-webkit-scrollbar-thumb { background: var(--alm-border); border-radius: 2px; }

.alm-bubble-wrap { display: flex; align-items: flex-end; gap: 8px; }
.alm-bubble-wrap.user  { flex-direction: row-reverse; }

.alm-mini-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--alm-surface);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    border: 1px solid var(--alm-border);
}
.alm-bubble-wrap.user .alm-mini-avatar { background: var(--alm-primary); color: #fff; font-size: 11px; font-weight: 700; }

.alm-bubble {
/*     max-width: 78%; */
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--alm-text);
    word-break: break-word;
    animation: alm-pop .2s ease-out;
}
@keyframes alm-pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.alm-bubble.bot  { background: var(--alm-bot-bg); border-bottom-left-radius: 4px; }
.alm-bubble.user { background: var(--alm-user-bg); color: #fff; border-bottom-right-radius: 4px; }

/* Typing indicator */
.alm-typing { display: flex; gap: 4px; padding: 12px 14px; }
.alm-typing span {
    width: 7px; height: 7px;
    background: var(--alm-muted);
    border-radius: 50%;
    animation: alm-bounce 1.2s infinite ease-in-out;
}
.alm-typing span:nth-child(2) { animation-delay: .2s; }
.alm-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes alm-bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-7px)} }

/* Timestamp */
.alm-time { font-size: 10px; color: var(--alm-muted); text-align: right; margin-top: 2px; padding: 0 4px; }
.alm-bubble-wrap.bot .alm-time { text-align: left; }

/* ── Lead Form ────────────────────────────────────────────────────────────── */
#almamate-lead-form {
    background: var(--alm-surface);
    border-top: 1px solid var(--alm-border);
    padding: 14px 16px;
    flex-shrink: 0;
    animation: alm-slide-up .3s ease-out;
}
@keyframes alm-slide-up { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

.almamate-lead-title { font-size: 13px; font-weight: 600; color: var(--alm-text); margin: 0 0 10px; }

#almamate-lead-form input {
    width: 100%;
    padding: 8px 11px;
    margin-bottom: 7px;
    border: 1px solid var(--alm-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--alm-font);
    color: var(--alm-text);
    background: #fff;
    box-sizing: border-box;
    transition: border-color var(--alm-anim), box-shadow var(--alm-anim);
}
#almamate-lead-form input:focus { outline: none; border-color: var(--alm-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

#almamate-lead-error { color: #dc2626; font-size: 12px; margin-bottom: 8px; padding: 6px 10px; background: #fef2f2; border-radius: 6px; border: 1px solid #fecaca; }

#almamate-lead-submit {
    width: 100%;
    padding: 10px;
    background: var(--alm-primary);
    color: #fff;
    border: none;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--alm-anim);
    font-family: var(--alm-font);
    margin-bottom: 6px;
}
#almamate-lead-submit:hover { background: var(--alm-primary-dk); }
#almamate-lead-submit:disabled { opacity: .6; cursor: not-allowed; }

.almamate-text-btn { background: none; border: none; color: var(--alm-muted); font-size: 12px; cursor: pointer; width: 100%; text-align: center; padding: 4px; font-family: var(--alm-font); }
.almamate-text-btn:hover { color: var(--alm-text); }

/* ── Input Area ───────────────────────────────────────────────────────────── */
#almamate-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--alm-border);
    background: #fff;
    flex-shrink: 0;
}

#almamate-input {
    flex: 1;
    border: 1px solid var(--alm-border);
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: var(--alm-font);
    color: var(--alm-text);
    resize: none;
    line-height: 1.45;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color var(--alm-anim), box-shadow var(--alm-anim);
    background: var(--alm-surface);
}
#almamate-input:focus { outline: none; border-color: var(--alm-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); background: #fff; }
#almamate-input::placeholder { color: var(--alm-muted); }

#almamate-send-btn {
    width: 38px; height: 38px;
    background: var(--alm-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--alm-anim), transform var(--alm-anim), opacity var(--alm-anim);
}
#almamate-send-btn:hover:not(:disabled) { background: var(--alm-primary-dk); transform: scale(1.08); }
#almamate-send-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Footer note ──────────────────────────────────────────────────────────── */
#almamate-footer-note { text-align: center; font-size: 10px; color: #cbd5e1; margin: 0; padding: 4px 0 6px; background: #fff; flex-shrink: 0; }

/* ── Unread badge ─────────────────────────────────────────────────────────── */
#almamate-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--alm-font);
    min-width: 18px; height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center; justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #almamate-chatbot { bottom: 16px; right: 16px; }
    #almamate-window { width: calc(100vw - 32px); height: calc(100vh - 100px); bottom: calc(var(--alm-launcher-sz) + 10px); }
}

/* ── Save-details trigger button inside chat ─────────────────────────────── */
.alm-save-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 7px 16px;
    background: var(--alm-primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--alm-font);
    transition: background var(--alm-anim);
}
.alm-save-btn:hover { background: var(--alm-primary-dk); }

/* ── Quick reply buttons (distinct from save-details button) ─────────────── */
.alm-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.alm-quick-btn {
    padding: 6px 14px;
    background: #fff;
    color: var(--alm-primary);
    border: 1.5px solid var(--alm-primary);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--alm-font);
    transition: background var(--alm-anim), color var(--alm-anim);
    white-space: nowrap;
}
.alm-quick-btn:hover { background: var(--alm-primary); color: #fff; }


/* Force chatbot SVG icons to display even if theme overrides svg styles */
#almamate-launcher svg,
#almamate-send-btn svg {
    display: block !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    flex-shrink: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    fill: #ffffff !important;
    stroke: none !important;
    overflow: visible !important;
    pointer-events: none !important;
}

#almamate-icon-chat,
#almamate-icon-close {
    width: 28px !important;
    height: 28px !important;
    fill: #ffffff !important;
}

#almamate-launcher {
    color: #ffffff !important;
}

#almamate-send-btn {
    color: #ffffff !important;
}
