/* ── Floating AI chat widget ─────────────────────────────────────────────── */

.ai-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 4px 12px rgba(224,90,90,0.4), -4px -4px 12px var(--shadow-light);
    transition: transform .15s ease, background .15s ease;
}
.ai-fab:hover { background: var(--accent-hover); transform: translateY(-2px); }
.ai-fab.hidden { display: none; }

.ai-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 48px);
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--raised);
    z-index: 1201;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.ai-panel.open { display: flex; }

.ai-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}
.ai-head-title { font-weight: 600; color: var(--text); flex: 1; }
.ai-head-title small { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); }

.ai-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none; }
.ai-toggle input { accent-color: var(--accent); }

.ai-model { font-size: 12px; color: var(--text); background: var(--bg); border: none; border-radius: var(--radius-sm); box-shadow: var(--inset); padding: 4px 6px; cursor: pointer; outline: none; }

.ai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 4px; }
.ai-quick-btn { font-size: 12px; color: var(--text-muted); background: var(--bg); border: none; border-radius: var(--radius-sm); box-shadow: var(--raised-sm); padding: 6px 10px; cursor: pointer; transition: box-shadow .12s ease; }
.ai-quick-btn:hover { color: var(--text); }
.ai-quick-btn:active { box-shadow: var(--inset); }

.ai-icon-btn {
    width: 30px; height: 30px;
    border: none; border-radius: var(--radius-sm);
    background: var(--bg); color: var(--text-muted);
    box-shadow: var(--raised-sm); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.ai-icon-btn:active { box-shadow: var(--inset); }

.ai-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-msg { max-width: 88%; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.ai-msg.user  { align-self: flex-end;   background: var(--accent); color: #fff; box-shadow: var(--raised-sm); }
.ai-msg.bot   { align-self: flex-start; background: var(--bg); color: var(--text); box-shadow: var(--raised-sm); }
.ai-msg.note  { align-self: center; background: transparent; color: var(--text-muted); font-size: 12px; box-shadow: none; }
.ai-msg.error { align-self: flex-start; color: var(--accent); box-shadow: none; }

.ai-performed { align-self: flex-start; font-size: 12px; color: var(--text-muted); }
.ai-performed div::before { content: "✓ "; color: #3a9d5d; }

/* confirmation card */
.ai-confirm { align-self: stretch; background: var(--bg); border-radius: var(--radius-sm); box-shadow: var(--inset); padding: 12px; }
.ai-confirm h5 { margin: 0 0 8px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ai-confirm ul { margin: 0 0 10px; padding-left: 0; list-style: none; }
.ai-confirm li { font-size: 13px; color: var(--text); padding: 4px 0; }
.ai-confirm-actions { display: flex; gap: 8px; }
.ai-confirm-actions button { flex: 1; padding: 8px; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.ai-apply  { background: var(--accent); color: #fff; box-shadow: var(--raised-sm); }
.ai-reject { background: var(--bg); color: var(--text-muted); box-shadow: var(--raised-sm); }

.ai-foot { display: flex; gap: 8px; padding: 12px 16px; align-items: flex-end; }
.ai-foot textarea {
    flex: 1;
    resize: none;
    max-height: 120px;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    box-shadow: var(--inset);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
}
.ai-foot textarea:focus { outline: none; box-shadow: var(--inset), 0 0 0 2px var(--accent); }
.ai-send {
    width: 40px; height: 40px; flex: none;
    border: none; border-radius: 50%;
    background: var(--accent); color: #fff; cursor: pointer;
    box-shadow: var(--raised-sm);
    display: flex; align-items: center; justify-content: center;
}
.ai-send:disabled { opacity: .5; cursor: default; }

.ai-attach {
    width: 40px; height: 40px; flex: none;
    border: none; border-radius: 50%;
    background: var(--bg); color: var(--text-muted); cursor: pointer;
    box-shadow: var(--raised-sm);
    display: flex; align-items: center; justify-content: center;
}
.ai-attach:active { box-shadow: var(--inset); }
.ai-attach:disabled { opacity: .5; cursor: default; }

.ai-file-chip {
    align-self: flex-end;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-muted);
    background: var(--bg); box-shadow: var(--raised-sm);
    border-radius: var(--radius-sm); padding: 6px 10px;
}
.ai-file-chip::before { content: "📎"; }

.ai-typing { align-self: flex-start; color: var(--text-muted); font-size: 13px; }
.ai-typing span { animation: ai-blink 1.2s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 60%, 100% { opacity: .2; } 30% { opacity: 1; } }

@media (max-width: 480px) {
    .ai-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100vh - 16px); }
}
