/**
 * Styles for Federal AI Agents Feed Component
 * Версия 2.0: Плавающие окна
 */

/* Main Container */
.federal-agents-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Позволяет кликать сквозь контейнер */
    /* Must be above the main map header (map_overview.css sets header z-index: 2000) */
    z-index: 2100;
}

/* Floating Window */
.federal-agent-window {
    position: fixed;
    width: 400px;
    max-height: 600px;
    background: var(--bg-elevated);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    pointer-events: all; /* Восстанавливаем клики для окон */
    z-index: 2101;
    overflow: hidden;
    animation: windowSlideIn 0.3s ease-out;
}

@keyframes windowSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Window Header */
.federal-agent-window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-inverse);
    border-radius: 12px 12px 0 0;
    user-select: none;
    cursor: move;
}

.window-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

/* Пиктограмма эксперта в шапке */
.agent-expert-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--bg-primary) 25%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1;
    border: 1px solid color-mix(in srgb, var(--bg-primary) 40%, transparent);
}

.agent-status-icon {
    font-size: 0.7rem;
    flex-shrink: 0;
}

.agent-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-topic-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: color-mix(in srgb, var(--bg-primary) 20%, transparent);
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.window-header-controls {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.btn-refresh {
    background: color-mix(in srgb, var(--bg-primary) 20%, transparent);
    border: none;
    color: var(--text-inverse);
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-refresh:hover {
    background: color-mix(in srgb, var(--bg-primary) 40%, transparent);
}

.btn-minimize,
.btn-close,
.btn-start,
.btn-stop,
.btn-delete {
    background: color-mix(in srgb, var(--bg-primary) 20%, transparent);
    border: none;
    color: var(--text-inverse);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-minimize:hover,
.btn-close:hover,
.btn-start:hover,
.btn-stop:hover,
.btn-delete:hover {
    background: color-mix(in srgb, var(--bg-primary) 30%, transparent);
}

.btn-start:hover {
    background: rgba(76, 175, 80, 0.3);
}

.btn-stop:hover {
    background: rgba(255, 152, 0, 0.3);
}

/* Window Body */
.federal-agent-window-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    max-height: 500px;
}

.agent-feed {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Строка: аватар эксперта + облако реплики */
.activity-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.activity-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-inverse);
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
    border: 1px solid color-mix(in srgb, var(--bg-primary) 50%, transparent);
}
.activity-row.activity-user .activity-avatar {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    font-size: 0.6rem;
}

/* Облако реплики (хвостик влево к аватару) */
.activity-bubble {
    position: relative;
    background: color-mix(in srgb, var(--info) 8%, var(--bg-primary));
    border: 1px solid #e0e7ff;
    border-radius: 12px;
    padding: 0.6rem 0.75rem;
    max-width: calc(100% - 40px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.activity-bubble::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 10px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #e0e7ff;
}
.activity-bubble::after {
    content: '';
    position: absolute;
    left: -5px;
    top: 11px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 7px solid #f0f4ff;
}
.activity-bubble-user {
    background: var(--bg-tertiary);
    border-color: var(--border);
}
.activity-bubble-user::before {
    border-right-color: var(--border);
}
.activity-bubble-user::after {
    border-right-color: var(--text-inverse);
}

.activity-row.insight .activity-bubble { border-left: 3px solid #ffc107; background: color-mix(in srgb, var(--warning) 8%, var(--bg-primary)); border-color: var(--warning); }
.activity-row.insight .activity-bubble::after { border-right-color: #fffbf0; }
.activity-row.hypothesis .activity-bubble { border-left: 3px solid #2196f3; background: color-mix(in srgb, var(--info) 8%, var(--bg-primary)); border-color: var(--info); }
.activity-row.hypothesis .activity-bubble::after { border-right-color: #f0f8ff; }
.activity-row.connection .activity-bubble { border-left: 3px solid #4caf50; background: color-mix(in srgb, var(--success) 8%, var(--bg-primary)); border-color: var(--success); }
.activity-row.connection .activity-bubble::after { border-right-color: #f1f8f4; }
.activity-row.assistant_message .activity-bubble { border-left: 3px solid #667eea; border-color: #c7d2fe; }
.activity-row.assistant_message .activity-bubble::after { border-right-color: #f0f4ff; }

.activity-bubble-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    font-size: 0.7rem;
    color: #666;
}

.activity-icon {
    font-size: 0.9rem;
}

.activity-time {
    font-size: 0.65rem;
    color: #999;
    white-space: nowrap;
}

.activity-content {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.activity-content strong {
    color: #667eea;
    font-weight: 600;
}

.activity-content .hashtag {
    color: #667eea;
    font-weight: 500;
}

.activity-metadata {
    margin-top: 0.4rem;
}

.metadata-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.metadata-tags .tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-primary));
    color: #667eea;
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Блок «Спросить эксперта» */
.federal-agent-ask {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.federal-agent-ask-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.federal-agent-ask-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.federal-agent-ask-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    min-height: 56px;
    transition: border-color 0.2s;
}
.federal-agent-ask-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}
.federal-agent-ask-input::placeholder {
    color: var(--text-muted);
}
.federal-agent-ask-send {
    align-self: flex-end;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-inverse);
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}
.federal-agent-ask-send:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}
.federal-agent-ask-send:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading & Empty States */
.loading,
.no-activities,
.error-message {
    text-align: center;
    padding: 2rem 1rem;
    color: #999;
    font-size: 0.85rem;
}

.error-message {
    color: #f44336;
    background: #ffebee;
    border-radius: 6px;
    padding: 1rem;
}

/* Scrollbar */
.federal-agent-window-body::-webkit-scrollbar {
    width: 6px;
}

.federal-agent-window-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.federal-agent-window-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.federal-agent-window-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .federal-agent-window {
        width: calc(100vw - 20px);
        max-width: 400px;
        max-height: calc(100vh - 100px);
    }
}

/* Toggle Button (for main page) */
.federal-agents-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-inverse);
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.federal-agents-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.federal-agents-toggle-btn svg {
    flex-shrink: 0;
}

/* Create Agent Button */
.federal-agents-create-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: var(--text-inverse);
    border: none;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 1002;
}

.federal-agents-create-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
}

/* Create Agent Modal */
.federal-agent-create-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-elevated);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1;
    animation: faf-modalSlideIn 0.3s ease-out;
}

@keyframes faf-modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.btn-cancel,
.btn-create {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel {
    background: var(--bg-secondary);
    color: #666;
}

.btn-cancel:hover {
    background: var(--bg-hover);
}

.btn-create {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-inverse);
}

.btn-create:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-create:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
