/* ИИ-помощник: плавающий чат-виджет. Контекстная раскатка (item detail и
   калькуляторы), §9 плана. Использует токены темы (var(--bg) и т.п.). */

#aiChatRoot { position: fixed; right: 18px; bottom: 18px; z-index: 1080; }

#aiChatBubble {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--accent, #e94560); color: #fff; border: none;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35); cursor: pointer;
    font-size: 24px; display: flex; align-items: center; justify-content: center;
    transition: transform .12s ease;
}
#aiChatBubble:hover { transform: scale(1.06); }

#aiChatPanel {
    position: absolute; right: 0; bottom: 70px;
    width: 360px; max-width: calc(100vw - 36px);
    height: 520px; max-height: calc(100vh - 120px);
    background: var(--bg-2, #16213e); color: var(--text, #eee);
    border: 1px solid var(--border, #2a2a40); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
    display: none; flex-direction: column; overflow: hidden;
}
#aiChatRoot.open #aiChatPanel { display: flex; }

.ai-chat-header {
    padding: 10px 14px; background: var(--bg-3, #1a1a2e);
    border-bottom: 1px solid var(--border, #2a2a40);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; font-size: 0.95em;
}
.ai-chat-header .ai-sub { font-weight: 400; font-size: 0.78em; color: var(--text-muted, #9aa); }
.ai-chat-close { background: none; border: none; color: var(--text-muted, #9aa); cursor: pointer; font-size: 18px; }

.ai-chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.ai-msg { max-width: 88%; padding: 8px 11px; border-radius: 10px; font-size: 0.88em; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--accent, #e94560); color: #fff; border-bottom-right-radius: 3px; }
.ai-msg.bot  { align-self: flex-start; background: var(--bg-3, #1a1a2e); border: 1px solid var(--border, #2a2a40); border-bottom-left-radius: 3px; }
.ai-msg.bot.degraded { border-color: #b8860b; }
.ai-msg.bot a.ai-inline-link { color: var(--accent, #e94560); text-decoration: underline; font-weight: 600; }
.ai-msg.bot a.ai-inline-link:hover { text-decoration: none; }

.ai-card { margin-top: 6px; border: 1px solid var(--border, #2a2a40); border-radius: 8px; padding: 8px 10px; background: var(--bg, #0f1626); font-size: 0.86em; }
.ai-card .ai-card-title { font-weight: 600; margin-bottom: 4px; }
.ai-card .ai-row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.ai-card .ai-row .v { font-variant-numeric: tabular-nums; }
.ai-card .pos { color: #46d369; } .ai-card .neg { color: #e94560; }
.ai-card .ai-stale { color: #b8860b; font-size: 0.92em; }

/* Бейдж вердикта ЧР — те же цвета, что на странице "Динамика цен ЧР". */
.ai-badge { display: inline-block; font-size: 0.78em; font-weight: 700; text-transform: uppercase;
    padding: 2px 8px; border-radius: 10px; margin-bottom: 5px; }
.ai-badge.v-SELL_NOW { background: rgba(230,126,34,.16); color: #f0932b; }
.ai-badge.v-SELL     { background: rgba(63,185,80,.16);  color: #3fb950; }
.ai-badge.v-HOLD     { background: rgba(93,173,226,.16); color: #5dade2; }
.ai-badge.v-NEUTRAL  { background: rgba(139,148,158,.16); color: #adbac7; }
.ai-badge.v-ILLIQUID { background: rgba(155,89,182,.14); color: #b07cc6; }
.ai-badge.v-NODATA   { background: rgba(139,148,158,.12); color: #8b949e; }

.ai-choices { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.ai-choice { text-align: left; background: var(--bg-3,#1a1a2e); border: 1px solid var(--border,#2a2a40); color: var(--text,#eee); border-radius: 6px; padding: 5px 8px; cursor: pointer; font-size: 0.85em; }
.ai-choice:hover { border-color: var(--accent, #e94560); }

.ai-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ai-link { font-size: 0.82em; background: var(--bg-3,#1a1a2e); border: 1px solid var(--border,#2a2a40); border-radius: 14px; padding: 3px 10px; color: var(--accent,#e94560); text-decoration: none; }
.ai-link:hover { background: var(--accent, #e94560); color: #fff; }

.ai-cta { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--accent,#e94560); border-radius: 8px; font-size: 0.85em; }
.ai-cta a { display: inline-block; margin-top: 5px; background: var(--accent,#e94560); color: #fff; padding: 4px 12px; border-radius: 6px; text-decoration: none; }

.ai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.ai-quick button { font-size: 0.8em; background: var(--bg-3,#1a1a2e); border: 1px solid var(--border,#2a2a40); color: var(--text,#eee); border-radius: 14px; padding: 4px 10px; cursor: pointer; }
.ai-quick button:hover { border-color: var(--accent,#e94560); }

.ai-chat-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border,#2a2a40); }
.ai-chat-input textarea { flex: 1; resize: none; height: 38px; max-height: 100px; background: var(--bg,#0f1626); color: var(--text,#eee); border: 1px solid var(--border,#2a2a40); border-radius: 8px; padding: 8px; font-size: 0.88em; }
.ai-chat-input button { background: var(--accent,#e94560); color: #fff; border: none; border-radius: 8px; padding: 0 14px; cursor: pointer; }
.ai-chat-input button:disabled { opacity: .5; cursor: default; }

.ai-foot { padding: 0 12px 8px; font-size: 0.72em; color: var(--text-muted,#9aa); text-align: center; }
.ai-typing { font-style: italic; color: var(--text-muted,#9aa); }

@media (max-width: 900px) {
    #aiChatPanel { width: calc(100vw - 24px); height: calc(100vh - 110px); right: -3px; }
}
