PluginProbe
AI Builder – Generate pages, blocks, images & translate with AI / 2.7.3
AI Builder – Generate pages, blocks, images & translate with AI v2.7.3
2.7.9 2.7.8 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.10 2.3.11 All 121 releases
ai-builder / admin / pages / agent-chat.php

agent-chat.php in AI Builder – Generate pages, blocks, images & translate with AI 2.7.3, at admin/pages/agent-chat.php

1,366 lines 31.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Agent Chat Admin Page
4 *
5 * Provides a chat interface for interacting with WordPress via AI
6 * and settings for managing API route access.
7 *
8 * @package AI_Builder
9 */
10
11 if (!defined('ABSPATH')) {
12 exit;
13 }
14
15 // Check authentication
16 $jwt_token = get_option('aibui_jwt_token', '');
17 if (empty($jwt_token)) {
18 echo '<div class="wrap"><div class="notice notice-error"><p>' . esc_html__('Please sign in to use the Site Copilot.', 'ai-builder') . '</p></div></div>';
19 return;
20 }
21 ?>
22
23 <div class="wrap aibui-agent-wrap">
24 <h1><?php esc_html_e('Site Copilot', 'ai-builder'); ?></h1>
25 <p class="aibui-agent-description">
26 <?php esc_html_e('Chat with an AI assistant that can interact with your WordPress site.', 'ai-builder'); ?>
27 </p>
28
29 <div class="aibui-info-notice" style="background: #f0f6fc; border-left: 4px solid #2271b1; padding: 12px 16px; margin: 20px 0; border-radius: 4px;">
30 <p style="margin: 0; font-size: 14px; line-height: 1.6;">
31 <?php
32 printf(
33 /* translators: %s: Link to documentation article */
34 esc_html__('Want to learn more about Site Copilot? %s', 'ai-builder'),
35 sprintf(
36 '<a href="%s" target="_blank" rel="noopener noreferrer" style="color: #2271b1; text-decoration: underline;">%s</a>',
37 esc_url('https://website-ai-builder.com/action-chat-manage-wordpress-with-simple-commands/'),
38 esc_html__('Follow this guide for more information about this feature.', 'ai-builder')
39 )
40 );
41 ?>
42 </p>
43 </div>
44
45 <!-- Subscription Warning Container (shown for free users) -->
46 <div id="aibui-subscription-warning" style="display: none;"></div>
47
48 <!-- Site Copilot Content (can be locked) -->
49 <div id="aibui-copilot-content">
50
51 <!-- Tabs Navigation -->
52 <nav class="nav-tab-wrapper aibui-agent-tabs">
53 <a href="#chat" class="nav-tab nav-tab-active" data-tab="chat">
54 <span class="dashicons dashicons-format-chat"></span>
55 <?php esc_html_e('Chat', 'ai-builder'); ?>
56 </a>
57 <a href="#security" class="nav-tab" data-tab="security">
58 <span class="dashicons dashicons-shield"></span>
59 <?php esc_html_e('API Security', 'ai-builder'); ?>
60 </a>
61 </nav>
62
63 <!-- Tab Content: Chat -->
64 <div id="tab-chat" class="aibui-tab-content aibui-tab-active">
65 <div class="aibui-chat-container">
66 <!-- Chat Messages Area -->
67 <div class="aibui-chat-messages" id="aibui-chat-messages">
68 <div class="aibui-chat-welcome">
69 <div class="aibui-welcome-icon">
70 <span class="dashicons dashicons-admin-site-alt3"></span>
71 </div>
72 <h2><?php esc_html_e('Welcome to AI Agent Chat', 'ai-builder'); ?></h2>
73 <p><?php esc_html_e('I can help you manage your WordPress site. Try asking me to:', 'ai-builder'); ?></p>
74 <ul class="aibui-suggestions">
75 <li><button type="button" class="aibui-suggestion-btn"><?php esc_html_e('List recent posts', 'ai-builder'); ?></button></li>
76 <li><button type="button" class="aibui-suggestion-btn"><?php esc_html_e('Show all pages', 'ai-builder'); ?></button></li>
77 <li><button type="button" class="aibui-suggestion-btn"><?php esc_html_e('List categories', 'ai-builder'); ?></button></li>
78 <li><button type="button" class="aibui-suggestion-btn"><?php esc_html_e('Show pending comments', 'ai-builder'); ?></button></li>
79 </ul>
80 </div>
81 </div>
82
83 <!-- Chat Input Area -->
84 <div class="aibui-chat-input-container">
85 <form id="aibui-chat-form" class="aibui-chat-form">
86 <div class="aibui-input-wrapper">
87 <textarea
88 id="aibui-chat-input"
89 class="aibui-chat-input"
90 placeholder="<?php esc_attr_e('Type your message...', 'ai-builder'); ?>"
91 rows="1"
92 maxlength="4000"
93 ></textarea>
94 <button type="submit" class="aibui-send-btn" id="aibui-send-btn" disabled>
95 <span class="dashicons dashicons-arrow-up-alt"></span>
96 </button>
97 </div>
98 <div class="aibui-chat-meta">
99 <div class="aibui-chat-meta-left">
100 <span class="aibui-char-count"><span id="aibui-char-count">0</span>/4000</span>
101 <span class="aibui-credits-indicator" id="aibui-credits-indicator" aria-live="polite"></span>
102 </div>
103 <div class="aibui-chat-meta-right">
104 <button type="button" class="aibui-stop-btn" id="aibui-stop-chat" title="<?php esc_attr_e('Stop current request', 'ai-builder'); ?>" disabled>
105 <?php esc_html_e('Stop', 'ai-builder'); ?>
106 </button>
107 <button type="button" class="aibui-clear-btn" id="aibui-clear-chat" title="<?php esc_attr_e('Clear conversation', 'ai-builder'); ?>">
108 <span class="dashicons dashicons-trash"></span>
109 <?php esc_html_e('Clear', 'ai-builder'); ?>
110 </button>
111 </div>
112 </div>
113 </form>
114 </div>
115 </div>
116 </div>
117
118 <!-- Tab Content: Security -->
119 <div id="tab-security" class="aibui-tab-content">
120 <div class="aibui-security-container">
121 <div class="aibui-security-header">
122 <div class="aibui-security-info">
123 <h2><?php esc_html_e('API Route Access Control', 'ai-builder'); ?></h2>
124 <p><?php esc_html_e('Control which WordPress REST API routes the AI agent can access. Only whitelisted routes will be available as tools.', 'ai-builder'); ?></p>
125 </div>
126 <div class="aibui-security-actions">
127 <button type="button" class="button" id="aibui-reset-routes">
128 <span class="dashicons dashicons-image-rotate"></span>
129 <?php esc_html_e('Reset to Defaults', 'ai-builder'); ?>
130 </button>
131 <button type="button" class="button button-primary" id="aibui-save-routes">
132 <span class="dashicons dashicons-saved"></span>
133 <?php esc_html_e('Save Changes', 'ai-builder'); ?>
134 </button>
135 </div>
136 </div>
137
138 <!-- Stats -->
139 <div class="aibui-security-stats" id="aibui-security-stats">
140 <div class="aibui-stat">
141 <span class="aibui-stat-value" id="stat-total">-</span>
142 <span class="aibui-stat-label"><?php esc_html_e('Total Routes', 'ai-builder'); ?></span>
143 </div>
144 <div class="aibui-stat aibui-stat-enabled">
145 <span class="aibui-stat-value" id="stat-enabled">-</span>
146 <span class="aibui-stat-label"><?php esc_html_e('Enabled', 'ai-builder'); ?></span>
147 </div>
148 <div class="aibui-stat aibui-stat-disabled">
149 <span class="aibui-stat-value" id="stat-disabled">-</span>
150 <span class="aibui-stat-label"><?php esc_html_e('Disabled', 'ai-builder'); ?></span>
151 </div>
152 <div class="aibui-stat">
153 <span class="aibui-stat-value" id="stat-namespaces">-</span>
154 <span class="aibui-stat-label"><?php esc_html_e('Namespaces', 'ai-builder'); ?></span>
155 </div>
156 </div>
157
158 <!-- Search -->
159 <div class="aibui-search-box">
160 <span class="dashicons dashicons-search"></span>
161 <input type="text" id="aibui-route-search" placeholder="<?php esc_attr_e('Search routes...', 'ai-builder'); ?>" />
162 </div>
163
164 <!-- Routes List -->
165 <div class="aibui-routes-list" id="aibui-routes-list">
166 <div class="aibui-loading">
167 <span class="spinner is-active"></span>
168 <?php esc_html_e('Loading routes...', 'ai-builder'); ?>
169 </div>
170 </div>
171 </div>
172 </div>
173
174 </div><!-- End #aibui-copilot-content -->
175 </div>
176
177 <!-- Tool Confirmation Modal -->
178 <div id="aibui-tool-confirm-modal" class="aibui-modal" style="display: none;">
179 <div class="aibui-modal-backdrop"></div>
180 <div class="aibui-modal-content">
181 <div class="aibui-modal-header">
182 <h3>
183 <span class="dashicons dashicons-warning"></span>
184 <?php esc_html_e('Confirm Action', 'ai-builder'); ?>
185 </h3>
186 </div>
187 <div class="aibui-modal-body">
188 <p class="aibui-modal-description">
189 <?php esc_html_e('The AI wants to perform the following action:', 'ai-builder'); ?>
190 </p>
191 <div class="aibui-tool-details">
192 <div class="aibui-tool-method">
193 <span class="aibui-method-badge" id="aibui-confirm-method">PUT</span>
194 <span class="aibui-tool-name" id="aibui-confirm-tool-name">update_wp_v2_posts</span>
195 </div>
196 <div class="aibui-tool-params-section">
197 <h4><?php esc_html_e('Parameters:', 'ai-builder'); ?></h4>
198 <pre class="aibui-tool-params" id="aibui-confirm-params">{}</pre>
199 </div>
200 </div>
201 <p class="aibui-modal-warning">
202 <span class="dashicons dashicons-info"></span>
203 <?php esc_html_e('This action may modify data on your WordPress site. Please review the details before proceeding.', 'ai-builder'); ?>
204 </p>
205 </div>
206 <div class="aibui-modal-footer">
207 <button type="button" class="button aibui-modal-cancel" id="aibui-confirm-cancel">
208 <?php esc_html_e('Cancel', 'ai-builder'); ?>
209 </button>
210 <button type="button" class="button button-primary aibui-modal-confirm" id="aibui-confirm-execute">
211 <?php esc_html_e('Execute', 'ai-builder'); ?>
212 </button>
213 </div>
214 </div>
215 </div>
216
217 <style>
218 /* Agent Chat Styles */
219 .aibui-agent-wrap {
220 max-width: 1400px;
221 margin-right: 20px;
222 }
223
224 /* Subscription Warning */
225 .aibui-subscription-warning {
226 background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
227 border: 1px solid #f59e0b;
228 border-radius: 12px;
229 padding: 24px 32px;
230 margin-bottom: 24px;
231 display: flex;
232 align-items: center;
233 justify-content: space-between;
234 gap: 20px;
235 box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
236 }
237
238 .aibui-subscription-warning-content {
239 display: flex;
240 align-items: center;
241 gap: 16px;
242 }
243
244 .aibui-subscription-warning-icon {
245 width: 48px;
246 height: 48px;
247 background: #f59e0b;
248 border-radius: 50%;
249 display: flex;
250 align-items: center;
251 justify-content: center;
252 flex-shrink: 0;
253 }
254
255 .aibui-subscription-warning-icon .dashicons {
256 font-size: 24px;
257 width: 24px;
258 height: 24px;
259 color: #fff;
260 }
261
262 .aibui-subscription-warning-text h3 {
263 margin: 0 0 4px;
264 font-size: 16px;
265 font-weight: 600;
266 color: #92400e;
267 }
268
269 .aibui-subscription-warning-text p {
270 margin: 0;
271 font-size: 14px;
272 color: #a16207;
273 }
274
275 .aibui-subscription-warning .aibui-upgrade-btn {
276 background: #2563eb;
277 color: #fff;
278 border: none;
279 padding: 12px 24px;
280 border-radius: 8px;
281 font-size: 14px;
282 font-weight: 600;
283 cursor: pointer;
284 text-decoration: none;
285 white-space: nowrap;
286 transition: all 0.2s;
287 }
288
289 .aibui-subscription-warning .aibui-upgrade-btn:hover {
290 background: #1d4ed8;
291 color: #fff;
292 }
293
294 /* Locked State */
295 #aibui-copilot-content.aibui-locked {
296 pointer-events: none;
297 opacity: 0.5;
298 filter: grayscale(50%);
299 user-select: none;
300 }
301
302 .aibui-agent-description {
303 color: #50575e;
304 font-size: 14px;
305 margin-bottom: 20px;
306 }
307
308 /* Tabs */
309 .aibui-agent-tabs {
310 margin-bottom: 0;
311 border-bottom: 1px solid #c3c4c7;
312 }
313
314 .aibui-agent-tabs .nav-tab {
315 display: inline-flex;
316 align-items: center;
317 gap: 6px;
318 }
319
320 .aibui-agent-tabs .nav-tab .dashicons {
321 font-size: 18px;
322 width: 18px;
323 height: 18px;
324 }
325
326 /* Tab Content */
327 .aibui-tab-content {
328 display: none;
329 background: #fff;
330 border: 1px solid #c3c4c7;
331 border-top: none;
332 padding: 0;
333 }
334
335 .aibui-tab-content.aibui-tab-active {
336 display: block;
337 }
338
339 /* Chat Container */
340 .aibui-chat-container {
341 display: flex;
342 flex-direction: column;
343 height: calc(100vh - 280px);
344 min-height: 500px;
345 }
346
347 .aibui-chat-messages {
348 flex: 1;
349 overflow-y: auto;
350 padding: 24px;
351 background: #f6f7f7;
352 }
353
354 /* Welcome Screen */
355 .aibui-chat-welcome {
356 text-align: center;
357 padding: 60px 20px;
358 }
359
360 .aibui-welcome-icon {
361 width: 80px;
362 height: 80px;
363 background: linear-gradient(135deg, #2271b1, #135e96);
364 border-radius: 50%;
365 display: flex;
366 align-items: center;
367 justify-content: center;
368 margin: 0 auto 20px;
369 }
370
371 .aibui-welcome-icon .dashicons {
372 font-size: 40px;
373 width: 40px;
374 height: 40px;
375 color: #fff;
376 }
377
378 .aibui-chat-welcome h2 {
379 font-size: 24px;
380 font-weight: 600;
381 color: #1d2327;
382 margin-bottom: 10px;
383 }
384
385 .aibui-chat-welcome p {
386 color: #50575e;
387 font-size: 15px;
388 margin-bottom: 20px;
389 }
390
391 .aibui-suggestions {
392 display: flex;
393 flex-wrap: wrap;
394 justify-content: center;
395 gap: 10px;
396 list-style: none;
397 margin: 0;
398 padding: 0;
399 }
400
401 .aibui-suggestion-btn {
402 background: #fff;
403 border: 1px solid #c3c4c7;
404 border-radius: 20px;
405 padding: 8px 16px;
406 font-size: 13px;
407 color: #2271b1;
408 cursor: pointer;
409 transition: all 0.2s;
410 }
411
412 .aibui-suggestion-btn:hover {
413 background: #2271b1;
414 color: #fff;
415 border-color: #2271b1;
416 }
417
418 /* Chat Messages */
419 .aibui-message {
420 max-width: 80%;
421 margin-bottom: 16px;
422 animation: fadeIn 0.3s ease;
423 }
424
425 @keyframes fadeIn {
426 from { opacity: 0; transform: translateY(10px); }
427 to { opacity: 1; transform: translateY(0); }
428 }
429
430 .aibui-message-user {
431 margin-left: auto;
432 }
433
434 .aibui-message-assistant {
435 margin-right: auto;
436 }
437
438 .aibui-message-content {
439 padding: 12px 16px;
440 border-radius: 16px;
441 font-size: 14px;
442 line-height: 1.5;
443 }
444
445 .aibui-message-user .aibui-message-content {
446 background: #2271b1;
447 color: #fff;
448 border-bottom-right-radius: 4px;
449 }
450
451 .aibui-message-assistant .aibui-message-content {
452 background: #fff;
453 color: #1d2327;
454 border: 1px solid #e0e0e0;
455 border-bottom-left-radius: 4px;
456 }
457
458 .aibui-message-content pre {
459 background: #f0f0f1;
460 padding: 12px;
461 border-radius: 8px;
462 overflow-x: auto;
463 font-size: 13px;
464 margin: 10px 0;
465 }
466
467 .aibui-message-content code {
468 background: rgba(0,0,0,0.1);
469 padding: 2px 6px;
470 border-radius: 4px;
471 font-size: 13px;
472 }
473
474 /* Markdown Styles */
475 .aibui-message-content .aibui-md-p {
476 margin: 0 0 12px;
477 }
478
479 .aibui-message-content .aibui-md-p:last-child {
480 margin-bottom: 0;
481 }
482
483 .aibui-message-content .aibui-md-h1 {
484 font-size: 1.5em;
485 font-weight: 700;
486 margin: 16px 0 12px;
487 color: #1d2327;
488 border-bottom: 1px solid #e5e7eb;
489 padding-bottom: 8px;
490 }
491
492 .aibui-message-content .aibui-md-h2 {
493 font-size: 1.3em;
494 font-weight: 600;
495 margin: 14px 0 10px;
496 color: #1d2327;
497 }
498
499 .aibui-message-content .aibui-md-h3 {
500 font-size: 1.15em;
501 font-weight: 600;
502 margin: 12px 0 8px;
503 color: #374151;
504 }
505
506 .aibui-message-content .aibui-md-h4,
507 .aibui-message-content .aibui-md-h5,
508 .aibui-message-content .aibui-md-h6 {
509 font-size: 1em;
510 font-weight: 600;
511 margin: 10px 0 6px;
512 color: #374151;
513 }
514
515 .aibui-message-content .aibui-md-h1:first-child,
516 .aibui-message-content .aibui-md-h2:first-child,
517 .aibui-message-content .aibui-md-h3:first-child {
518 margin-top: 0;
519 }
520
521 .aibui-message-content .aibui-md-list {
522 margin: 8px 0;
523 padding-left: 24px;
524 }
525
526 .aibui-message-content .aibui-md-list li {
527 margin-bottom: 4px;
528 line-height: 1.5;
529 }
530
531 .aibui-message-content ul.aibui-md-list {
532 list-style-type: disc;
533 }
534
535 .aibui-message-content ol.aibui-md-list {
536 list-style-type: decimal;
537 }
538
539 .aibui-message-content .aibui-md-blockquote {
540 border-left: 4px solid #2271b1;
541 padding-left: 16px;
542 margin: 12px 0;
543 color: #6b7280;
544 font-style: italic;
545 }
546
547 .aibui-message-content .aibui-md-hr {
548 border: none;
549 border-top: 1px solid #e5e7eb;
550 margin: 16px 0;
551 }
552
553 .aibui-message-content .aibui-md-inline-code {
554 background: #f3f4f6;
555 color: #dc2626;
556 padding: 2px 6px;
557 border-radius: 4px;
558 font-size: 0.9em;
559 font-family: 'SF Mono', Monaco, Consolas, monospace;
560 }
561
562 .aibui-message-content .aibui-md-code-block {
563 position: relative;
564 margin: 12px 0;
565 border-radius: 8px;
566 overflow: hidden;
567 background: #1f2937;
568 }
569
570 .aibui-message-content .aibui-md-code-block .aibui-code-lang {
571 position: absolute;
572 top: 8px;
573 right: 12px;
574 font-size: 10px;
575 text-transform: uppercase;
576 color: #9ca3af;
577 letter-spacing: 0.5px;
578 }
579
580 .aibui-message-content .aibui-md-code-block pre {
581 margin: 0;
582 background: transparent;
583 padding: 16px;
584 overflow-x: auto;
585 }
586
587 .aibui-message-content .aibui-md-code-block code {
588 background: transparent;
589 color: #e5e7eb;
590 padding: 0;
591 font-size: 13px;
592 font-family: 'SF Mono', Monaco, Consolas, monospace;
593 line-height: 1.6;
594 }
595
596 .aibui-message-content a {
597 color: #2271b1;
598 text-decoration: underline;
599 }
600
601 .aibui-message-content a:hover {
602 color: #135e96;
603 }
604
605 .aibui-message-content strong {
606 font-weight: 600;
607 }
608
609 .aibui-message-content em {
610 font-style: italic;
611 }
612
613 .aibui-message-content del {
614 text-decoration: line-through;
615 color: #6b7280;
616 }
617
618 /* Tool Execution Indicator */
619 .aibui-tool-execution {
620 display: flex;
621 align-items: center;
622 gap: 8px;
623 padding: 8px 12px;
624 background: #f0f6fc;
625 border: 1px solid #c5d9ed;
626 border-radius: 8px;
627 font-size: 12px;
628 color: #2271b1;
629 margin-bottom: 8px;
630 }
631
632 .aibui-tool-execution .dashicons {
633 animation: spin 1s linear infinite;
634 }
635
636 .aibui-tool-execution--completed .dashicons {
637 animation: none;
638 color: #00a32a;
639 }
640
641 .aibui-tool-execution--error {
642 background: #fcf0f1;
643 border-color: #d63638;
644 color: #d63638;
645 }
646
647 .aibui-tool-execution--error .dashicons {
648 animation: none;
649 color: #d63638;
650 }
651
652 .aibui-tool-execution--waiting {
653 background: #fef3c7;
654 border-color: #fbbf24;
655 color: #92400e;
656 }
657
658 .aibui-tool-execution--waiting .dashicons {
659 animation: pulse 1.5s ease-in-out infinite;
660 color: #f59e0b;
661 }
662
663 @keyframes pulse {
664 0%, 100% { opacity: 1; }
665 50% { opacity: 0.5; }
666 }
667
668 .aibui-tool-execution--cancelled {
669 background: #f3f4f6;
670 border-color: #9ca3af;
671 color: #6b7280;
672 }
673
674 .aibui-tool-execution--cancelled .dashicons {
675 animation: none;
676 color: #6b7280;
677 }
678
679 /* Inline Method Badge */
680 .aibui-method-badge-inline {
681 display: inline-block;
682 padding: 2px 6px;
683 border-radius: 3px;
684 font-size: 9px;
685 font-weight: 700;
686 text-transform: uppercase;
687 letter-spacing: 0.3px;
688 margin-right: 4px;
689 vertical-align: middle;
690 }
691
692 .aibui-method-badge-inline.method-get {
693 background: #dbeafe;
694 color: #1d4ed8;
695 }
696
697 .aibui-method-badge-inline.method-post {
698 background: #dcfce7;
699 color: #16a34a;
700 }
701
702 .aibui-method-badge-inline.method-put {
703 background: #fef3c7;
704 color: #d97706;
705 }
706
707 .aibui-method-badge-inline.method-patch {
708 background: #fef3c7;
709 color: #d97706;
710 }
711
712 .aibui-method-badge-inline.method-delete {
713 background: #fee2e2;
714 color: #dc2626;
715 }
716
717 @keyframes spin {
718 from { transform: rotate(0deg); }
719 to { transform: rotate(360deg); }
720 }
721
722 /* Loading Message */
723 .aibui-message-loading {
724 display: flex;
725 gap: 6px;
726 padding: 16px;
727 }
728
729 .aibui-loading-dot {
730 width: 8px;
731 height: 8px;
732 background: #c3c4c7;
733 border-radius: 50%;
734 animation: bounce 1.4s infinite ease-in-out both;
735 }
736
737 .aibui-loading-dot:nth-child(1) { animation-delay: -0.32s; }
738 .aibui-loading-dot:nth-child(2) { animation-delay: -0.16s; }
739
740 @keyframes bounce {
741 0%, 80%, 100% { transform: scale(0); }
742 40% { transform: scale(1); }
743 }
744
745 /* Chat Input */
746 .aibui-chat-input-container {
747 padding: 16px 24px;
748 background: #fff;
749 border-top: 1px solid #e0e0e0;
750 }
751
752 .aibui-chat-form {
753 max-width: 900px;
754 margin: 0 auto;
755 }
756
757 .aibui-input-wrapper {
758 display: flex;
759 align-items: flex-end;
760 gap: 12px;
761 background: #f6f7f7;
762 border: 1px solid #c3c4c7;
763 border-radius: 24px;
764 padding: 8px 8px 8px 16px;
765 transition: border-color 0.2s;
766 }
767
768 .aibui-input-wrapper:focus-within {
769 border-color: #2271b1;
770 box-shadow: 0 0 0 1px #2271b1;
771 }
772
773 .aibui-chat-input {
774 flex: 1;
775 border: none;
776 background: transparent;
777 font-size: 14px;
778 line-height: 1.5;
779 resize: none;
780 max-height: 150px;
781 outline: none;
782 }
783
784 .aibui-send-btn {
785 width: 36px;
786 height: 36px;
787 border-radius: 50%;
788 background: #2271b1;
789 border: none;
790 color: #fff;
791 cursor: pointer;
792 display: flex;
793 align-items: center;
794 justify-content: center;
795 transition: all 0.2s;
796 flex-shrink: 0;
797 }
798
799 .aibui-send-btn:disabled {
800 background: #c3c4c7;
801 cursor: not-allowed;
802 }
803
804 .aibui-send-btn:not(:disabled):hover {
805 background: #135e96;
806 transform: scale(1.05);
807 }
808
809 .aibui-chat-meta {
810 display: flex;
811 justify-content: space-between;
812 align-items: center;
813 margin-top: 8px;
814 padding: 0 8px;
815 }
816
817 .aibui-chat-meta-left {
818 display: flex;
819 align-items: center;
820 gap: 12px;
821 }
822
823 .aibui-chat-meta-right {
824 display: flex;
825 align-items: center;
826 gap: 8px;
827 }
828
829 .aibui-char-count {
830 font-size: 12px;
831 color: #787c82;
832 }
833
834 .aibui-credits-indicator {
835 font-size: 12px;
836 color: #047857;
837 }
838
839 .aibui-stop-btn {
840 display: inline-flex;
841 align-items: center;
842 gap: 4px;
843 background: transparent;
844 border: 1px solid #dcdcde;
845 border-radius: 999px;
846 padding: 4px 10px;
847 font-size: 11px;
848 color: #d63638;
849 cursor: pointer;
850 }
851
852 .aibui-stop-btn .dashicons {
853 font-size: 14px;
854 }
855
856 .aibui-stop-btn:disabled {
857 opacity: 0.5;
858 cursor: default;
859 }
860
861 .aibui-clear-btn {
862 display: inline-flex;
863 align-items: center;
864 gap: 4px;
865 background: transparent;
866 border: none;
867 color: #787c82;
868 font-size: 12px;
869 cursor: pointer;
870 padding: 4px 8px;
871 border-radius: 4px;
872 transition: all 0.2s;
873 }
874
875 .aibui-clear-btn:hover {
876 background: #f0f0f1;
877 color: #d63638;
878 }
879
880 /* Security Tab */
881 .aibui-security-container {
882 padding: 24px;
883 }
884
885 .aibui-security-header {
886 display: flex;
887 justify-content: space-between;
888 align-items: flex-start;
889 margin-bottom: 24px;
890 flex-wrap: wrap;
891 gap: 16px;
892 }
893
894 .aibui-security-info h2 {
895 font-size: 18px;
896 font-weight: 600;
897 margin: 0 0 8px;
898 }
899
900 .aibui-security-info p {
901 color: #50575e;
902 margin: 0;
903 }
904
905 .aibui-security-actions {
906 display: flex;
907 gap: 8px;
908 }
909
910 .aibui-security-actions .button {
911 display: inline-flex;
912 align-items: center;
913 gap: 4px;
914 }
915
916 /* Stats */
917 .aibui-security-stats {
918 display: flex;
919 gap: 16px;
920 margin-bottom: 24px;
921 flex-wrap: wrap;
922 }
923
924 .aibui-stat {
925 background: #f6f7f7;
926 border-radius: 8px;
927 padding: 16px 24px;
928 text-align: center;
929 min-width: 120px;
930 }
931
932 .aibui-stat-value {
933 display: block;
934 font-size: 28px;
935 font-weight: 600;
936 color: #1d2327;
937 }
938
939 .aibui-stat-label {
940 font-size: 12px;
941 color: #50575e;
942 text-transform: uppercase;
943 letter-spacing: 0.5px;
944 }
945
946 .aibui-stat-enabled .aibui-stat-value {
947 color: #00a32a;
948 }
949
950 .aibui-stat-disabled .aibui-stat-value {
951 color: #d63638;
952 }
953
954 /* Search */
955 .aibui-search-box {
956 position: relative;
957 margin-bottom: 20px;
958 }
959
960 .aibui-search-box .dashicons {
961 position: absolute;
962 left: 12px;
963 top: 50%;
964 transform: translateY(-50%);
965 color: #787c82;
966 }
967
968 .aibui-search-box input {
969 width: 100%;
970 max-width: 400px;
971 padding: 10px 12px 10px 38px;
972 border: 1px solid #c3c4c7;
973 border-radius: 8px;
974 font-size: 14px;
975 }
976
977 /* Routes List */
978 .aibui-routes-list {
979 border: 1px solid #c3c4c7;
980 border-radius: 8px;
981 background: #fff;
982 max-height: 500px;
983 overflow-y: auto;
984 }
985
986 .aibui-loading {
987 display: flex;
988 align-items: center;
989 justify-content: center;
990 gap: 8px;
991 padding: 40px;
992 color: #50575e;
993 }
994
995 /* Namespace Group */
996 .aibui-namespace-group {
997 border-bottom: 1px solid #e0e0e0;
998 }
999
1000 .aibui-namespace-group:last-child {
1001 border-bottom: none;
1002 }
1003
1004 .aibui-namespace-header {
1005 display: flex;
1006 align-items: center;
1007 justify-content: space-between;
1008 padding: 12px 16px;
1009 background: #f6f7f7;
1010 cursor: pointer;
1011 user-select: none;
1012 }
1013
1014 .aibui-namespace-header:hover {
1015 background: #f0f0f1;
1016 }
1017
1018 .aibui-namespace-name {
1019 display: flex;
1020 align-items: baseline;
1021 gap: 8px;
1022 }
1023
1024 .aibui-namespace-name .dashicons {
1025 transition: transform 0.2s;
1026 }
1027
1028 .aibui-namespace-title {
1029 font-weight: 600;
1030 font-size: 14px;
1031 }
1032
1033 .aibui-namespace-description {
1034 font-size: 12px;
1035 color: #6b7280;
1036 }
1037
1038 .aibui-namespace-group.collapsed .aibui-namespace-name .dashicons {
1039 transform: rotate(-90deg);
1040 }
1041
1042 .aibui-namespace-count {
1043 font-size: 12px;
1044 color: #50575e;
1045 background: #e0e0e0;
1046 padding: 2px 8px;
1047 border-radius: 10px;
1048 }
1049
1050 .aibui-namespace-routes {
1051 display: block;
1052 }
1053
1054 .aibui-namespace-group.collapsed .aibui-namespace-routes {
1055 display: none;
1056 }
1057
1058 /* Route Item */
1059 .aibui-route-item {
1060 display: flex;
1061 align-items: center;
1062 gap: 12px;
1063 padding: 10px 16px 10px 32px;
1064 border-top: 1px solid #f0f0f1;
1065 transition: background 0.2s;
1066 }
1067
1068 .aibui-route-item:hover {
1069 background: #f6f7f7;
1070 }
1071
1072 .aibui-route-item.aibui-route-disabled {
1073 opacity: 0.6;
1074 }
1075
1076 .aibui-route-checkbox {
1077 margin-right: 12px;
1078 }
1079
1080 .aibui-route-method {
1081 font-size: 11px;
1082 font-weight: 600;
1083 padding: 2px 6px;
1084 border-radius: 4px;
1085 margin-right: 10px;
1086 min-width: 50px;
1087 text-align: center;
1088 }
1089
1090 .aibui-route-method-get { background: #d1fae5; color: #065f46; }
1091 .aibui-route-method-post { background: #dbeafe; color: #1e40af; }
1092 .aibui-route-method-put { background: #fef3c7; color: #92400e; }
1093 .aibui-route-method-patch { background: #e9d5ff; color: #6b21a8; }
1094 .aibui-route-method-delete { background: #fee2e2; color: #991b1b; }
1095
1096 .aibui-route-path {
1097 flex: 1;
1098 font-family: monospace;
1099 font-size: 13px;
1100 color: #1d2327;
1101 word-break: break-all;
1102 }
1103
1104 .aibui-route-main {
1105 flex: 1;
1106 display: flex;
1107 flex-direction: column;
1108 gap: 2px;
1109 }
1110
1111 .aibui-route-description {
1112 font-size: 11px;
1113 color: #6b7280;
1114 }
1115
1116 .aibui-route-doc-link {
1117 font-size: 11px;
1118 padding: 4px 8px;
1119 border-radius: 4px;
1120 border: 1px solid #d0d4d9;
1121 background: #ffffff;
1122 color: #1d4ed8;
1123 text-decoration: none;
1124 white-space: nowrap;
1125 transition: all 0.15s ease;
1126 }
1127
1128 .aibui-route-doc-link:hover {
1129 background: #eff6ff;
1130 border-color: #93c5fd;
1131 color: #1d4ed8;
1132 }
1133
1134 .aibui-route-locked {
1135 color: #787c82;
1136 margin-left: 8px;
1137 }
1138
1139 /* Toast Notification */
1140 .aibui-toast {
1141 position: fixed;
1142 bottom: 40px;
1143 right: 40px;
1144 background: #1d2327;
1145 color: #fff;
1146 padding: 12px 20px;
1147 border-radius: 8px;
1148 font-size: 14px;
1149 z-index: 100000;
1150 animation: slideIn 0.3s ease;
1151 display: flex;
1152 align-items: center;
1153 gap: 8px;
1154 }
1155
1156 .aibui-toast.aibui-toast-success {
1157 background: #00a32a;
1158 }
1159
1160 .aibui-toast.aibui-toast-error {
1161 background: #d63638;
1162 }
1163
1164 @keyframes slideIn {
1165 from { transform: translateY(20px); opacity: 0; }
1166 to { transform: translateY(0); opacity: 1; }
1167 }
1168
1169 /* Tool Confirmation Modal */
1170 .aibui-modal {
1171 position: fixed;
1172 top: 0;
1173 left: 0;
1174 right: 0;
1175 bottom: 0;
1176 z-index: 100001;
1177 display: flex;
1178 align-items: center;
1179 justify-content: center;
1180 }
1181
1182 .aibui-modal-backdrop {
1183 position: absolute;
1184 top: 0;
1185 left: 0;
1186 right: 0;
1187 bottom: 0;
1188 background: rgba(0, 0, 0, 0.6);
1189 }
1190
1191 .aibui-modal-content {
1192 position: relative;
1193 background: #fff;
1194 border-radius: 12px;
1195 max-width: 520px;
1196 width: 90%;
1197 max-height: 80vh;
1198 overflow: hidden;
1199 box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
1200 animation: modalSlideIn 0.2s ease;
1201 }
1202
1203 @keyframes modalSlideIn {
1204 from { transform: translateY(-20px); opacity: 0; }
1205 to { transform: translateY(0); opacity: 1; }
1206 }
1207
1208 .aibui-modal-header {
1209 padding: 20px 24px;
1210 border-bottom: 1px solid #e5e7eb;
1211 background: #fef3c7;
1212 }
1213
1214 .aibui-modal-header h3 {
1215 margin: 0;
1216 font-size: 16px;
1217 font-weight: 600;
1218 color: #92400e;
1219 display: flex;
1220 align-items: center;
1221 gap: 8px;
1222 }
1223
1224 .aibui-modal-header .dashicons {
1225 color: #f59e0b;
1226 }
1227
1228 .aibui-modal-body {
1229 padding: 20px 24px;
1230 overflow-y: auto;
1231 max-height: calc(80vh - 160px);
1232 }
1233
1234 .aibui-modal-description {
1235 margin: 0 0 16px;
1236 color: #374151;
1237 font-size: 14px;
1238 }
1239
1240 .aibui-tool-details {
1241 background: #f9fafb;
1242 border: 1px solid #e5e7eb;
1243 border-radius: 8px;
1244 padding: 16px;
1245 margin-bottom: 16px;
1246 }
1247
1248 .aibui-tool-method {
1249 display: flex;
1250 align-items: center;
1251 gap: 12px;
1252 margin-bottom: 12px;
1253 }
1254
1255 .aibui-method-badge {
1256 display: inline-block;
1257 padding: 4px 10px;
1258 border-radius: 4px;
1259 font-size: 11px;
1260 font-weight: 700;
1261 text-transform: uppercase;
1262 letter-spacing: 0.5px;
1263 }
1264
1265 .aibui-method-badge.method-get {
1266 background: #dbeafe;
1267 color: #1d4ed8;
1268 }
1269
1270 .aibui-method-badge.method-post {
1271 background: #dcfce7;
1272 color: #16a34a;
1273 }
1274
1275 .aibui-method-badge.method-put {
1276 background: #fef3c7;
1277 color: #d97706;
1278 }
1279
1280 .aibui-method-badge.method-patch {
1281 background: #fef3c7;
1282 color: #d97706;
1283 }
1284
1285 .aibui-method-badge.method-delete {
1286 background: #fee2e2;
1287 color: #dc2626;
1288 }
1289
1290 .aibui-tool-name {
1291 font-family: 'SF Mono', Monaco, Consolas, monospace;
1292 font-size: 13px;
1293 color: #374151;
1294 }
1295
1296 .aibui-tool-params-section h4 {
1297 margin: 0 0 8px;
1298 font-size: 12px;
1299 font-weight: 600;
1300 color: #6b7280;
1301 text-transform: uppercase;
1302 letter-spacing: 0.5px;
1303 }
1304
1305 .aibui-tool-params {
1306 background: #1f2937;
1307 color: #e5e7eb;
1308 padding: 12px;
1309 border-radius: 6px;
1310 font-size: 12px;
1311 font-family: 'SF Mono', Monaco, Consolas, monospace;
1312 overflow-x: auto;
1313 max-height: 200px;
1314 overflow-y: auto;
1315 margin: 0;
1316 white-space: pre-wrap;
1317 word-break: break-word;
1318 }
1319
1320 .aibui-modal-warning {
1321 display: flex;
1322 align-items: flex-start;
1323 gap: 8px;
1324 padding: 12px;
1325 background: #fef3c7;
1326 border-radius: 6px;
1327 font-size: 13px;
1328 color: #92400e;
1329 margin: 0;
1330 }
1331
1332 .aibui-modal-warning .dashicons {
1333 flex-shrink: 0;
1334 margin-top: 2px;
1335 }
1336
1337 .aibui-modal-footer {
1338 display: flex;
1339 justify-content: flex-end;
1340 gap: 12px;
1341 padding: 16px 24px;
1342 border-top: 1px solid #e5e7eb;
1343 background: #f9fafb;
1344 }
1345
1346 .aibui-modal-cancel {
1347 background: #fff !important;
1348 border-color: #d1d5db !important;
1349 color: #374151 !important;
1350 }
1351
1352 .aibui-modal-cancel:hover {
1353 background: #f3f4f6 !important;
1354 }
1355
1356 .aibui-modal-confirm {
1357 background: #2563eb !important;
1358 border-color: #2563eb !important;
1359 }
1360
1361 .aibui-modal-confirm:hover {
1362 background: #1d4ed8 !important;
1363 }
1364 </style>
1365
1366