/* Malaika AI – Chat Widget Styles */

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
    --mal-primary:     #7c3aed;
    --mal-primary-dk:  #5b21b6;
    --mal-bot-bg:      #f3f0ff;
    --mal-user-bg:     #7c3aed;
    --mal-user-color:  #ffffff;
    --mal-bot-color:   #1e1b4b;
    --mal-radius:      18px;
    --mal-shadow:      0 8px 32px rgba(124, 58, 237, .25);
    --mal-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mal-z:           999999;
}

/* ── Launcher bubble ─────────────────────────────────────────────────────── */
#malaika-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--mal-primary);
    color: #fff;
    cursor: pointer;
    border: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--mal-shadow);
    z-index: var(--mal-z);
    transition: transform .2s, background .2s;
}

#malaika-launcher:hover {
    background: var(--mal-primary-dk);
    transform: scale(1.08);
}

#malaika-launcher svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: transform .2s;
}

#malaika-launcher.open svg.icon-chat { display: none; }
#malaika-launcher:not(.open) svg.icon-close { display: none; }

/* ── Widget window ───────────────────────────────────────────────────────── */
#malaika-widget {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 360px;
    max-height: 560px;
    border-radius: 16px;
    box-shadow: var(--mal-shadow);
    background: #fff;
    display: flex;
    flex-direction: column;
    z-index: var(--mal-z);
    font-family: var(--mal-font);
    overflow: hidden;
    transition: opacity .25s, transform .25s;
    transform-origin: bottom right;
}

#malaika-widget.hidden {
    opacity: 0;
    transform: scale(.92) translateY(12px);
    pointer-events: none;
}

@media (max-width: 420px) {
    #malaika-widget {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
    }
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#malaika-header {
    background: linear-gradient(135deg, var(--mal-primary) 0%, var(--mal-primary-dk) 100%);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#malaika-header .mal-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

#malaika-header .mal-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

#malaika-header .mal-subtitle {
    font-size: 11px;
    opacity: .8;
    margin-top: 2px;
}

#malaika-header .mal-online {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255,255,255,.5);
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Messages area ───────────────────────────────────────────────────────── */
#malaika-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 220px;
    max-height: 340px;
    background: #fafafa;
}

/* Scrollbar */
#malaika-messages::-webkit-scrollbar { width: 5px; }
#malaika-messages::-webkit-scrollbar-track { background: transparent; }
#malaika-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

/* ── Bubble ──────────────────────────────────────────────────────────────── */
.mal-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: var(--mal-radius);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    animation: malPop .15s ease;
}

@keyframes malPop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mal-bubble.bot {
    background: var(--mal-bot-bg);
    color: var(--mal-bot-color);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.mal-bubble.user {
    background: var(--mal-user-bg);
    color: var(--mal-user-color);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */
.mal-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 14px;
    background: var(--mal-bot-bg);
    border-radius: var(--mal-radius);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 60px;
}

.mal-typing span {
    width: 7px;
    height: 7px;
    background: #7c3aed;
    border-radius: 50%;
    animation: malBounce 1.2s infinite ease;
}

.mal-typing span:nth-child(2) { animation-delay: .2s; }
.mal-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes malBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ──────────────────────────────────────────────────────────── */
#malaika-input-area {
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#malaika-input {
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 22px;
    padding: 9px 14px;
    font-family: var(--mal-font);
    font-size: 14px;
    line-height: 1.4;
    max-height: 100px;
    outline: none;
    transition: border-color .2s;
}

#malaika-input:focus {
    border-color: var(--mal-primary);
    box-shadow: 0 0 0 2px rgba(124,58,237,.15);
}

#malaika-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--mal-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .1s;
}

#malaika-send:hover  { background: var(--mal-primary-dk); }
#malaika-send:active { transform: scale(.94); }

#malaika-send svg { width: 18px; height: 18px; fill: #fff; }
#malaika-send:disabled { background: #d1d5db; cursor: not-allowed; }

/* ── Lead capture form ───────────────────────────────────────────────────── */
#malaika-lead-form {
    background: #f3f0ff;
    border-top: 1px solid #ddd6fe;
    padding: 14px 16px;
}

#malaika-lead-form p {
    margin: 0 0 10px;
    font-size: 13px;
    color: #4c1d95;
    font-weight: 500;
}

#malaika-lead-form input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #c4b5fd;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 8px;
    box-sizing: border-box;
    outline: none;
}

#malaika-lead-form input:focus {
    border-color: var(--mal-primary);
}

#malaika-lead-form button {
    width: 100%;
    padding: 9px;
    background: var(--mal-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#malaika-lead-form button:hover {
    background: var(--mal-primary-dk);
}

/* ── WhatsApp CTA ────────────────────────────────────────────────────────── */
.mal-whatsapp-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #25d366;
    color: #fff !important;
    text-decoration: none !important;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
}

/* ── Inline embed ────────────────────────────────────────────────────────── */
.malaika-chat-embed {
    /* Inline embed uses full widget but without the floating button */
}

.malaika-chat-embed #malaika-launcher { display: none !important; }
.malaika-chat-embed #malaika-widget   { position: relative; bottom: auto; right: auto; border-radius: 12px; }
