/* Группы - основные стили */
.groups-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.groups-panel {
    flex: 1;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.groups-panel h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

/* Список групп */
.groups-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #3498db;
}

.group-info {
    flex: 1;
}

.group-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.group-id {
    font-size: 12px;
    color: #7f8c8d;
    font-family: monospace;
}

.group-actions {
    display: flex;
    gap: 8px;
}

/* База знаний */
.knowledge-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
}

.knowledge-item {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 15px;
    border-left: 3px solid #2ecc71;
}

.knowledge-keyword {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.knowledge-answer {
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.knowledge-actions {
    display: flex;
    gap: 8px;
}

/* Формы добавления */
.add-form {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
    color: white;
}

.add-form h4 {
    margin: 0 0 20px 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 10px;
}

.add-form .form-group {
    margin-bottom: 15px;
}

.add-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: white;
    font-size: 14px;
}

.add-form input,
.add-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.3s ease;
}

.add-form input:focus,
.add-form textarea:focus {
    outline: none;
    border-color: white;
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.add-form textarea {
    min-height: 100px;
    resize: vertical;
}

.add-form small {
    display: block;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
}

.add-form button {
    width: 100%;
    padding: 12px;
    background: white;
    color: #667eea;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.add-form button:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.add-form button[style*="background: #95a5a6"] {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.add-form button[style*="background: #95a5a6"]:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* Стандартный ответ */
.default-response-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 20px;
}

.default-response-section h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    border-bottom: 2px solid #e74c3c;
    padding-bottom: 10px;
}

.default-response-section .form-group {
    margin-bottom: 15px;
}

.default-response-section .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.default-response-section .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

.default-response-section .form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Кнопки */
.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit {
    background: #f39c12;
    color: white;
}

.btn-edit:hover {
    background: #e67e22;
}

.btn-delete {
    background: #e74c3c;
    color: white;
}

.btn-delete:hover {
    background: #c0392b;
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #95a5a6;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}


/* ==================== ГОТОВЫЕ ОТВЕТЫ ==================== */

.quick-response-item {
    background: linear-gradient(135deg, rgba(66, 165, 245, 0.08) 0%, rgba(33, 150, 243, 0.05) 100%);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(33, 150, 243, 0.2);
    transition: all 0.3s ease;
}

.quick-response-item:hover {
    border-color: rgba(33, 150, 243, 0.4);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.1);
}

.quick-response-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 10px;
}

.priority-badge {
    background: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
    color: #1a1a1a;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.priority-badge::before {
    content: "⚡";
    font-size: 12px;
}

.status-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.active {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: white;
}

.status-badge.active::before {
    content: "✓ ";
}

.status-badge.inactive {
    background: linear-gradient(135deg, #ef5350 0%, #e53935 100%);
    color: white;
}

.status-badge.inactive::before {
    content: "✗ ";
}

.quick-response-keywords {
    margin-bottom: 10px;
}

.quick-response-keywords label,
.quick-response-text label {
    display: inline-block;
    color: rgba(0, 0, 0, 0.7);
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 6px;
    margin-right: 8px;
}

.keywords-tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword-tag {
    background: linear-gradient(135deg, #42a5f5 0%, #2196f3 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: all 0.2s ease;
}

.keyword-tag::before {
    content: "#";
    opacity: 0.7;
    font-weight: bold;
    font-size: 10px;
}

.keyword-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(33, 150, 243, 0.4);
}

.quick-response-text {
    margin-bottom: 10px;
}

.quick-response-text label {
    display: block;
    margin-bottom: 6px;
}

.response-preview {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.response-preview::-webkit-scrollbar {
    width: 4px;
}

.response-preview::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.response-preview::-webkit-scrollbar-thumb {
    background: rgba(33, 150, 243, 0.5);
    border-radius: 2px;
}

.quick-response-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}

.quick-response-actions .btn-small {
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-size: 11px;
}

.quick-response-actions .btn-small:first-child {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: white;
}

.quick-response-actions .btn-small:first-child:hover {
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.quick-response-actions .btn-small.btn-delete {
    background: linear-gradient(135deg, #ef5350 0%, #e53935 100%);
    color: white;
}

.quick-response-actions .btn-small.btn-delete:hover {
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

#keywordsDuplicateWarning {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.4);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

#keywordsDuplicateWarning::before {
    content: "⚠️";
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    font-size: 13px;
}

.empty-state::before {
    content: "📭";
    display: block;
    font-size: 36px;
    margin-bottom: 12px;
}

.keyword-block {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.keyword-tag {
    display: inline-block;
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.knowledge-keyword {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
}

.knowledge-actions {
    flex-shrink: 0;
}

/* Контролы базы знаний */
.knowledge-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--gray-200, #e5e7eb);
}

.language-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-switcher label {
    color: var(--gray-700, #374151);
    font-size: 14px;
    font-weight: 500;
}

.language-switcher select {
    padding: 10px 14px;
    background: white;
    color: var(--gray-900, #111827);
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    min-width: 140px;
    transition: all 0.2s;
}

.language-switcher select:focus {
    outline: none;
    border-color: var(--primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.keyword-search {
    flex: 1;
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 8px;
    color: var(--gray-900, #111827);
    font-size: 14px;
    transition: all 0.2s;
}

.keyword-search::placeholder {
    color: var(--gray-600, #4b5563);
}

.keyword-search:focus {
    outline: none;
    border-color: var(--primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.import-export-buttons {
    display: flex;
    gap: 8px;
}

/* Модальное окно импорта */
.import-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.import-modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.import-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

.import-modal-header h4 {
    margin: 0;
    color: var(--gray-900, #111827);
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: var(--gray-100, #f3f4f6);
    border: none;
    color: var(--gray-600, #4b5563);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-900, #111827);
}

.import-modal-body {
    padding: 24px;
}

.import-modal-body label {
    display: block;
    color: var(--gray-700, #374151);
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 500;
}

.import-modal-body textarea {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 8px;
    color: var(--gray-900, #111827);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s;
}

.import-modal-body textarea:focus {
    outline: none;
    border-color: var(--primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.import-modal-body small {
    display: block;
    margin-top: 8px;
    color: var(--gray-600, #4b5563);
}

.import-modal-footer {
    padding: 24px;
    border-top: 1px solid var(--gray-200, #e5e7eb);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Игнорируемые слова */
.ignore-tag {
    background: rgba(255, 107, 107, 0.3) !important;
    border-color: #ff6b6b !important;
}

.ignore-keywords-container {
    padding: 10px;
}

.ignore-keywords-container .keyword-block {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}



/* ── Trigger mode section (Smart RAG) ───────────────────────────────────── */

.trigger-mode-section {
    background: #fff;
    border: 1px solid #e0e6ed;
    border-radius: 12px;
    padding: 18px 22px;
    margin: 0 0 20px 0;
}

.trigger-mode-section h4 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 600;
}

.trigger-mode-hint {
    margin: 0 0 14px 0;
    color: #666;
    font-size: 13px;
    line-height: 1.4;
}

.trigger-mode-radios {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trigger-mode-radio {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    grid-column-gap: 10px;
    align-items: start;
    padding: 12px 14px;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.trigger-mode-radio:hover {
    border-color: #6c5ce7;
    background: #faf9ff;
}

.trigger-mode-radio input[type="radio"] {
    grid-row: 1 / 3;
    margin-top: 4px;
    cursor: pointer;
}

.trigger-mode-radio input[type="radio"]:checked ~ .trigger-mode-title {
    color: #6c5ce7;
}

.trigger-mode-radio:has(input[type="radio"]:checked) {
    border-color: #6c5ce7;
    background: #f5f3ff;
}

.trigger-mode-title {
    font-weight: 600;
    font-size: 14px;
}

.trigger-mode-title small {
    color: #888;
    font-weight: 400;
}

.trigger-mode-desc {
    color: #666;
    font-size: 12.5px;
    line-height: 1.4;
    margin-top: 2px;
}

#triggerModeSliders {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed #e0e6ed;
}

.trigger-mode-slider {
    margin-bottom: 14px;
}

.trigger-mode-slider:last-child {
    margin-bottom: 0;
}

.trigger-mode-slider label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    color: #333;
}

.trigger-mode-slider label b {
    color: #6c5ce7;
    margin-left: 4px;
}

.trigger-mode-slider input[type="range"] {
    width: 100%;
    margin: 0;
}

.trigger-mode-slider small {
    display: block;
    color: #888;
    font-size: 11.5px;
    margin-top: 4px;
}
