/* ============================================================
   NovaPeople AI Assistant — floating launcher + chat panel
   ============================================================ */

.ai-fab {
    position: fixed;
    bottom: 24px;
    inset-inline-end: 24px;
    z-index: 1080;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    box-shadow: 0 8px 24px rgba(99, 102, 241, .45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    transition: transform .2s ease, box-shadow .2s ease;
    animation: ai-fab-pulse 2.8s ease-in-out infinite;
}

.ai-fab:hover { transform: scale(1.08); box-shadow: 0 10px 30px rgba(139, 92, 246, .6); }
.ai-fab:active { transform: scale(.96); }

.ai-fab .ai-fab-badge {
    position: absolute;
    top: -2px;
    inset-inline-end: -2px;
    background: #22c55e;
    color: #fff;
    font-size: .55rem;
    font-weight: 700;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 8px;
    box-shadow: 0 0 0 2px #fff;
    letter-spacing: .3px;
}

@keyframes ai-fab-pulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(99, 102, 241, .45); }
    50%      { box-shadow: 0 8px 24px rgba(99, 102, 241, .45), 0 0 0 10px rgba(99, 102, 241, .08); }
}

/* ── Chat panel ─────────────────────────────────────────── */
.ai-panel {
    position: fixed;
    bottom: 92px;
    inset-inline-end: 24px;
    z-index: 1081;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
    background: var(--bs-body-bg, #fff);
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
    overflow: hidden;
    transform-origin: bottom right;
    animation: ai-panel-in .18s ease-out;
}

@keyframes ai-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.ai-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
}

.ai-panel-header .ai-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
}
.ai-panel-header .ai-title { font-weight: 700; line-height: 1.1; }
.ai-panel-header .ai-subtitle { font-size: .72rem; opacity: .85; }
.ai-panel-header .ai-close {
    margin-inline-start: auto;
    background: transparent; border: none; color: #fff;
    font-size: 1.1rem; cursor: pointer; opacity: .85;
    width: 30px; height: 30px; border-radius: 8px;
}
.ai-panel-header .ai-close:hover { opacity: 1; background: rgba(255, 255, 255, .15); }

/* ── Messages ───────────────────────────────────────────── */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bs-tertiary-bg, #f6f7fb);
}

.ai-msg { display: flex; flex-direction: column; max-width: 88%; }
.ai-msg.user { align-self: flex-end; align-items: flex-end; }
.ai-msg.assistant { align-self: flex-start; align-items: flex-start; }

.ai-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: .88rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-msg.user .ai-bubble {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg.assistant .ai-bubble {
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #1f2937);
    border: 1px solid rgba(0, 0, 0, .07);
    border-bottom-left-radius: 4px;
}
.ai-bubble p { margin: 0 0 .5rem; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble table { width: 100%; border-collapse: collapse; margin: 4px 0; font-size: .82rem; }
.ai-bubble th, .ai-bubble td { border: 1px solid rgba(0,0,0,.1); padding: 3px 6px; text-align: start; }
.ai-bubble code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; }

/* actions taken by the AI */
.ai-actions { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.ai-action-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .72rem; color: #16a34a;
    background: rgba(34, 197, 94, .1);
    border: 1px solid rgba(34, 197, 94, .25);
    border-radius: 20px; padding: 2px 9px; width: fit-content;
}

.ai-error .ai-bubble { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* typing indicator */
.ai-typing { display: inline-flex; gap: 4px; padding: 11px 14px; }
.ai-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #9ca3af; animation: ai-bounce 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

/* quick suggestion chips */
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; background: var(--bs-tertiary-bg, #f6f7fb); }
.ai-suggestion {
    font-size: .76rem; cursor: pointer;
    background: var(--bs-body-bg, #fff);
    border: 1px solid rgba(99, 102, 241, .3);
    color: #6366f1; border-radius: 20px; padding: 5px 11px;
    transition: background .15s ease, color .15s ease;
}
.ai-suggestion:hover { background: #6366f1; color: #fff; }

/* ── Composer ───────────────────────────────────────────── */
.ai-composer {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(0, 0, 0, .07);
    background: var(--bs-body-bg, #fff);
}
.ai-composer textarea {
    flex: 1; resize: none; border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 12px; padding: 9px 12px; font-size: .88rem;
    max-height: 110px; line-height: 1.4; outline: none;
    background: var(--bs-body-bg, #fff); color: var(--bs-body-color, #1f2937);
}
.ai-composer textarea:focus { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, .15); }
.ai-send {
    width: 40px; height: 40px; flex: 0 0 40px;
    border: none; border-radius: 12px; color: #fff; cursor: pointer;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    transition: opacity .15s ease;
}
.ai-send:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 480px) {
    .ai-panel { inset-inline-end: 8px; bottom: 80px; width: calc(100vw - 16px); height: calc(100vh - 110px); }
    .ai-fab { bottom: 16px; inset-inline-end: 16px; }
}
