/* AI-chat block — extracted from management-systems.css, scoped under .pb-ai-chat */
@keyframes aiTyping { 0%,100%{opacity:0.3;transform:translateY(0)} 50%{opacity:1;transform:translateY(-3px)} }
@keyframes aiBlink { 0%,100%{opacity:1} 50%{opacity:0} }
.pb-ai-chat .ai-chat-widget {
    background: #ffffff;
    border: 2px solid #764ba2;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(118,75,162,0.12);
}

.pb-ai-chat .ai-chat-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.pb-ai-chat .ai-chat-header-icon {
    font-size: 1.3rem;
    color: white;
}
.pb-ai-chat .ai-chat-header h3 {
    font-size: 0.95rem;
    color: white;
    font-weight: 600;
    margin: 0;
}
.pb-ai-chat .ai-chat-header p {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    margin: 2px 0 0;
}
/* Editable links in tabs and chat headers */
.pb-ai-chat .ms-tab a { color: inherit; text-decoration: none; display: block; }
.pb-ai-chat .ai-chat-header h3 a { color: inherit; text-decoration: none; display: block; }
.pb-ai-chat .ai-chat-header p a { color: inherit; text-decoration: none; display: block; }


.pb-ai-chat .ai-chat-body {
    height: 540px;
    overflow-y: auto;
    padding: 20px;
    background: #fafbff;
}
.pb-ai-chat .ai-chat-body::-webkit-scrollbar { width: 5px; }
.pb-ai-chat .ai-chat-body::-webkit-scrollbar-track { background: #f1f5f9; }
.pb-ai-chat .ai-chat-body::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 3px; }

.pb-ai-chat .ai-chat-body .msg { display: flex; gap: 10px; margin-bottom: 16px; }
.pb-ai-chat .ai-chat-body .msg.right { flex-direction: row-reverse; }
.pb-ai-chat .ai-chat-body .msg-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}
.pb-ai-chat .ai-chat-body .msg-avatar.human { background: linear-gradient(135deg, #667eea, #764ba2); }
.pb-ai-chat .ai-chat-body .msg-bubble {
    background: #ffffff;
    border: 1px solid #e0e7ff;
    border-radius: 14px; padding: 14px 18px;
    font-size: 0.92rem; line-height: 1.6; max-width: 88%;
    min-height: 24px; color: #1e293b;
    box-shadow: 0 1px 4px rgba(118,75,162,0.06);
}
.pb-ai-chat .ai-chat-body .msg.right .msg-bubble { background: #f5f3ff; border-color: #ddd6fe; color: #4c1d95; }

.pb-ai-chat .ai-chat-body .typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.pb-ai-chat .ai-chat-body .typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: #764ba2; animation: aiTyping 1s infinite; }
.pb-ai-chat .ai-chat-body .typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.pb-ai-chat .ai-chat-body .typing-dots span:nth-child(3) { animation-delay: 0.3s; }

.pb-ai-chat .ai-chat-body .cursor { display: inline-block; width: 2px; height: 1em; background: #764ba2; animation: aiBlink 0.7s infinite; vertical-align: text-bottom; margin-left: 1px; }

.pb-ai-chat .ai-chat-input {
    border-top: 2px solid #e0e7ff;
    padding: 12px 18px; display: flex; gap: 10px; align-items: center;
    background: white;
}
.pb-ai-chat .ai-chat-input-field { flex: 1; background: #f8fafc; border: 2px solid #e0e7ff; border-radius: 12px; padding: 10px 14px; color: #94a3b8; font-size: 0.88rem; }
.pb-ai-chat .ai-chat-input-btn { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #667eea, #764ba2); display: flex; align-items: center; justify-content: center; color: white; font-size: 1rem; box-shadow: 0 2px 8px rgba(118,75,162,0.3); }

/* AI-chat tabs (3 вкладки: Анализ / Поиск / Противоречия) — как на management-systems */
.pb-ai-chat .ac-chat-tabs { display: flex; gap: 0; margin-bottom: 0; border: 2px solid #764ba2; border-bottom: none; border-radius: 20px 20px 0 0; overflow: hidden; }
.pb-ai-chat .ac-chat-tab {
    flex: 1; padding: 10px 12px; text-align: center; font-size: 0.82rem; font-weight: 600;
    color: #6366f1; background: #f3f4f6; cursor: pointer; border: none; border-right: 1px solid #764ba2;
    transition: all 0.2s; word-break: break-word;
}
.pb-ai-chat .ac-chat-tab:last-child { border-right: none; }
.pb-ai-chat .ac-chat-tab.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.pb-ai-chat .ac-chat-tab:hover:not(.active) { background: #e0e7ff; }

/* One widget per tab — only the active one is shown */
.pb-ai-chat .ac-chat-widget { display: none; border-radius: 0 0 20px 20px; border-top: none; }
.pb-ai-chat .ac-chat-widget.active { display: block; }

/* Legacy panel alias (kept for backward compat) */
.pb-ai-chat .ac-chat-panel { display: none; }
.pb-ai-chat .ac-chat-panel.active { display: block; }
/* Body of a visible widget is always shown */
.pb-ai-chat .ac-chat-widget.active .ac-chat-panel { display: block; }

/* Responsive — mirrors management-systems.css mobile rules */
@media (max-width: 768px) {
    .pb-ai-chat .ai-chat-body { height: 380px !important; }
    .pb-ai-chat .ai-chat-body .msg-bubble { font-size: 0.82rem; max-width: 92%; }
    .pb-ai-chat .ai-chat-body .msg-avatar { width: 30px; height: 30px; font-size: 0.85rem; }
}
