/* Afodabo v16 — AI Msaidizi. Prefix .ai- ; inafanya kazi kwenye app na landing (rangi zina fallback). */
.ai-w { --ai-p: var(--primary, #2f7a38); --ai-bg: var(--surface-strong, var(--surface, #fff)); --ai-fg: var(--text, #0f172a); --ai-mut: var(--muted, #64748b); --ai-line: var(--border, var(--line, #e2e8f0)); --ai-field: var(--field, #f1f5f9);
    position: fixed; right: 18px; bottom: 22px; z-index: 60; font-family: inherit; }
@media (max-width: 900px) { body.app .ai-w { bottom: 80px; right: 12px; } }
.ai-fab { position: relative; width: 60px; height: 60px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; padding: 0;
    background: #fff; border: 2px solid #7cc242; box-shadow: 0 10px 28px rgba(15, 23, 42, .25), 0 0 0 4px rgba(124, 194, 66, .18); transition: transform .15s; }
.ai-fab img { width: 34px; height: 34px; object-fit: contain; }
.ai-fab-badge { position: absolute; right: -4px; top: -4px; min-width: 22px; height: 18px; padding: 0 5px; border-radius: 99px; background: #2f7a38; color: #fff;
    font-size: .62rem; font-weight: 800; line-height: 18px; letter-spacing: .02em; border: 2px solid #fff; }
.ai-fab:hover { transform: translateY(-2px) scale(1.03); }
.ai-w.open .ai-fab { display: none; }
.ai-panel { position: absolute; right: 0; bottom: 0; width: min(390px, calc(100vw - 24px)); height: min(600px, calc(100vh - 110px)); display: flex; flex-direction: column;
    background: var(--ai-bg); color: var(--ai-fg); border: 1px solid var(--ai-line); border-radius: 20px; box-shadow: 0 24px 60px rgba(15, 23, 42, .28); overflow: hidden; }
.ai-panel[hidden] { display: none; }
.ai-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--ai-line); background: linear-gradient(135deg, color-mix(in srgb, var(--ai-p) 12%, transparent), transparent); }
.ai-logo { position: relative; width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 1.5px solid #7cc242; display: grid; place-items: center; flex: none; }
.ai-logo img { width: 22px; height: 22px; object-fit: contain; }
.ai-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; border: 2px solid var(--ai-bg); }
.ai-ht { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ai-ht b { font-size: .95rem; }
.ai-ht small { font-size: .72rem; color: var(--ai-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-ib { width: 34px; height: 34px; border-radius: 10px; border: 0; background: none; color: var(--ai-mut); display: grid; place-items: center; cursor: pointer; flex: none; }
.ai-ib:hover { background: var(--ai-field); color: var(--ai-fg); }
.ai-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: .88rem; line-height: 1.45; overflow-wrap: anywhere; }
.ai-msg p { margin: 0 0 6px; } .ai-msg p:last-child { margin: 0; }
.ai-msg ul { margin: 4px 0 6px; padding-left: 18px; } .ai-msg li { margin: 2px 0; }
.ai-msg a { color: var(--ai-p); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ai-msg.bot { align-self: flex-start; background: var(--ai-field); border-bottom-left-radius: 6px; }
.ai-msg.me { align-self: flex-end; background: var(--ai-p); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.ai-msg.err { background: color-mix(in srgb, #dc2626 12%, transparent); color: #b91c1c; }
.ai-msg.typing { color: var(--ai-mut); font-style: italic; }
.ai-msg.typing::after { content: ""; display: inline-block; width: 1em; animation: ai-dots 1.2s steps(4) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes ai-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.ai-fb { display: flex; gap: 4px; margin-top: 6px; }
.ai-fb button { border: 1px solid var(--ai-line); background: var(--ai-bg); border-radius: 99px; font-size: .72rem; padding: 2px 8px; cursor: pointer; color: var(--ai-mut); }
.ai-fb button.on { border-color: var(--ai-p); color: var(--ai-p); }
.ai-sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-sugg button { border: 1px solid var(--ai-line); background: var(--ai-bg); color: var(--ai-fg); border-radius: 99px; padding: 6px 11px; font-size: .78rem; cursor: pointer; text-align: left; }
.ai-sugg button:hover { border-color: var(--ai-p); color: var(--ai-p); }
.ai-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--ai-line); align-items: flex-end; }
.ai-form textarea { flex: 1; resize: none; border: 1px solid var(--ai-line); background: var(--ai-field); color: var(--ai-fg); border-radius: 14px; padding: 10px 12px; font: inherit; font-size: .9rem; max-height: 120px; min-height: 42px; outline: none; }
.ai-form textarea:focus { border-color: var(--ai-p); }
.ai-send { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--ai-p); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.ai-send:disabled { opacity: .5; cursor: default; }
.ai-foot { font-size: .68rem; color: var(--ai-mut); padding: 0 12px 10px; text-align: center; }
@media (max-width: 560px) {
    .ai-w.open { right: 0; left: 0; bottom: 0; }
    .ai-panel { position: fixed; inset: auto 0 0 0; width: 100%; height: min(86vh, 640px); border-radius: 20px 20px 0 0; }
}

/* Ukurasa mzima */
.ai-page { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 14px; }
.ai-page .ai-w { position: static; }
.ai-page .ai-panel { position: static; width: 100%; height: calc(100vh - 150px); min-height: 480px; box-shadow: none; }
.ai-hist { display: flex; flex-direction: column; gap: 4px; }
.ai-hist a { display: block; padding: 8px 10px; border-radius: 10px; font-size: .82rem; color: var(--text) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-hist a.on, .ai-hist a:hover { background: var(--field); }
@media (max-width: 900px) { .ai-page { grid-template-columns: minmax(0, 1fr); } .ai-page .ai-side { display: none; } .ai-page .ai-panel { height: calc(100vh - 190px); } }
