/* Kilimo Chat Widget — kilimokwanza.org */

#kilimo-chat-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Bubble ─────────────────────────────── */
#kilimo-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--kilimo-primary, #2e7d32);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
#kilimo-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* ── Window ─────────────────────────────── */
#kilimo-chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: kilimo-slide-up 0.25s ease;
}

@keyframes kilimo-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ─────────────────────────────── */
#kilimo-chat-header {
    background: var(--kilimo-primary, #2e7d32);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}
#kilimo-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
#kilimo-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
#kilimo-chat-botname {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}
#kilimo-chat-status {
    font-size: 11px;
    opacity: 0.85;
}
#kilimo-chat-minimise {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.8;
    padding: 0 4px;
    transition: opacity 0.15s;
}
#kilimo-chat-minimise:hover { opacity: 1; }

/* ── Messages ───────────────────────────── */
#kilimo-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
}

.kilimo-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}
.kilimo-msg-bot {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.kilimo-msg-user {
    background: var(--kilimo-primary, #2e7d32);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* ── Typing indicator ───────────────────── */
#kilimo-chat-typing {
    padding: 12px 16px;
    background: #f9fafb;
    display: flex;
    gap: 5px;
    align-items: center;
}
#kilimo-chat-typing span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: kilimo-bounce 1.2s infinite;
}
#kilimo-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
#kilimo-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes kilimo-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-6px); }
}

/* ── Input ──────────────────────────────── */
#kilimo-chat-input-area {
    display: flex;
    padding: 12px 12px 8px;
    gap: 8px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}
#kilimo-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s;
    color: #1f2937;
}
#kilimo-chat-input:focus {
    border-color: var(--kilimo-primary, #2e7d32);
}
#kilimo-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--kilimo-primary, #2e7d32);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}
#kilimo-chat-send:hover { transform: scale(1.08); }
#kilimo-chat-send:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ── Footer ─────────────────────────────── */
#kilimo-chat-footer {
    text-align: center;
    font-size: 10.5px;
    color: #9ca3af;
    padding: 4px 0 8px;
    background: #fff;
}
#kilimo-chat-footer a {
    color: var(--kilimo-primary, #2e7d32);
    text-decoration: none;
}

/* ── Mobile ─────────────────────────────── */
@media (max-width: 400px) {
    #kilimo-chat-wrapper { bottom: 16px; right: 16px; }
    #kilimo-chat-window  { width: calc(100vw - 32px); right: 0; }
}
