/**
 * AGENTS MODULE - ISOLATED CSS
 * Follows CSS naming conventions from CSS_NAMING.md
 * Prefix: .module-isolated-agents-*
 */

/* ============================= WRAPPER ============================= */
.module-isolated-agents-wrapper {
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================= HEADER WITH ACTIONS ============================= */
.module-isolated-agents-wrapper .module-header-premium {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    color: white;
}

.module-isolated-agents-wrapper .module-header-premium .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.module-isolated-agents-wrapper .module-header-premium .header-title-section h1 {
    color: white;
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 600;
}

.module-isolated-agents-wrapper .module-header-premium .breadcrumb {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

.module-isolated-agents-wrapper .module-header-premium .header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.module-isolated-agents-wrapper .module-header-premium .header-actions .btn-form {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.module-isolated-agents-wrapper .module-header-premium .header-actions .btn-primary-form {
    background: white;
    color: #667eea;
}

.module-isolated-agents-wrapper .module-header-premium .header-actions .btn-success-form {
    background: #10b981;
    color: white;
}

.module-isolated-agents-wrapper .module-header-premium .header-actions .btn-form:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Responsive header */
@media (max-width: 768px) {
    .module-isolated-agents-wrapper .module-header-premium .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .module-isolated-agents-wrapper .module-header-premium .header-actions {
        width: 100%;
    }
    
    .module-isolated-agents-wrapper .module-header-premium .header-actions .btn-form {
        flex: 1;
    }
}

/* ============================= STATS GRID ============================= */
.module-isolated-agents-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ============================= ACTION BUTTONS ============================= */
.module-isolated-agents-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.module-isolated-agents-actions .btn-lg {
    padding: 20px;
    height: auto;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
}

.module-isolated-agents-actions .btn-lg:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
}

.module-isolated-agents-actions .button-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}

.module-isolated-agents-actions .button-content strong {
    font-size: 16px;
    font-weight: 600;
}

.module-isolated-agents-actions .button-content small {
    font-size: 12px;
    opacity: 0.9;
}

/* ============================= AGENTS LIST ============================= */
.module-isolated-agents-list {
    margin-bottom: 30px;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* ============================= AGENT CARD ============================= */
.agent-card {
    background: white;
    border: 1px solid var(--border-color, #e1e4e8);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.agent-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
    border-color: var(--primary-color, #667eea);
}

.agent-card-header {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.agent-type-icon {
    font-size: 32px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    flex-shrink: 0;
}

.agent-info {
    flex: 1;
    min-width: 0;
}

.agent-info h4 {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-type {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary, #666);
}

.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

/* ============================= AGENT CARD BODY ============================= */
.agent-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.agent-description {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary, #666);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agent-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary, #666);
}

.meta-item i {
    width: 16px;
    text-align: center;
    color: var(--primary-color, #667eea);
}

.agent-execution-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--background-light, #f8f9fa);
    border-radius: 8px;
    font-size: 13px;
}

.execution-label {
    font-weight: 500;
    color: var(--text-secondary, #666);
}

.execution-time {
    flex: 1;
    color: var(--text-primary, #1a1a1a);
}

.execution-status {
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
}

.execution-status.success {
    background: #d4edda;
    color: #155724;
}

.execution-status.error {
    background: #f8d7da;
    color: #721c24;
}

.execution-status.pending {
    background: #fff3cd;
    color: #856404;
}

/* ============================= AGENT CARD ACTIONS ============================= */
.agent-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e1e4e8);
}

.agent-card-actions .btn-sm {
    flex: 1;
    font-size: 12px;
    padding: 8px 12px;
}

/* ============================= EMPTY STATE ============================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: var(--text-primary, #1a1a1a);
}

.empty-state p {
    margin: 0 0 30px 0;
    font-size: 16px;
    color: var(--text-secondary, #666);
}

.empty-state-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================= FULLSCREEN EDITOR (REPLACES MODALS) ============================= */
.module-isolated-agents-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-background, #f8fafc);
    z-index: 10000;
    overflow-y: auto;
    padding: 2rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.module-isolated-agents-editor {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.module-isolated-agents-editor-lg {
    max-width: 1000px;
}

.module-isolated-agents-editor-xl {
    max-width: 1400px;
}

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

.module-isolated-agents-editor-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color, #e1e4e8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 12px 0 0;
    color: white;
}

.module-isolated-agents-editor-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.module-isolated-agents-editor-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 28px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.module-isolated-agents-editor-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.module-isolated-agents-editor-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.module-isolated-agents-editor-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color, #e1e4e8);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--background-light, #f8f9fa);
    border-radius: 0 0 12px 12px;
}

/* ============================= MODAL CONTENT ============================= */
.suggestions-list,
.templates-grid {
    display: grid;
    gap: 16px;
}

.templates-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.suggestion-card,
.template-card {
    padding: 16px;
    border: 1px solid var(--border-color, #e1e4e8);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.suggestion-card:hover,
.template-card:hover {
    border-color: var(--primary-color, #667eea);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.suggestion-header h4,
.template-card h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.confidence-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.template-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 16px;
}

.template-meta {
    display: flex;
    gap: 8px;
    margin: 12px 0;
    flex-wrap: wrap;
}

/* Agent Details */
.agent-details {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-section h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.detail-section .table {
    width: 100%;
    border-collapse: collapse;
}

.detail-section .table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color, #e1e4e8);
}

.detail-section .table td:first-child {
    width: 180px;
    color: var(--text-secondary, #666);
}

/* ============================= SUGGESTIONS MODAL ============================= */
.suggestion-modal {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

.suggestion-stats {
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 12px;
    border: 2px solid #667eea30;
}

.suggestion-stats h4 {
    margin: 0 0 15px 0;
    color: #667eea;
    font-size: 18px;
}

.suggestion-stats .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.suggestion-stats .stat-item {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.suggestion-stats .stat-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

.suggestion-stats .stat-label {
    display: block;
    font-size: 14px;
    color: #666;
}

.suggestions-list h4 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: #333;
}

.suggestion-card {
    background: white;
    border: 2px solid #e1e4e8;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.suggestion-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.suggestion-card .suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.suggestion-card .suggestion-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.suggestion-card .suggestion-type {
    display: inline-block;
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.suggestion-card .suggestion-description {
    font-size: 16px;
    color: #555;
    margin-bottom: 15px;
    line-height: 1.5;
}

.suggestion-card .suggestion-justification {
    font-size: 14px;
    color: #666;
    background: #f8f9fa;
    padding: 12px;
    border-left: 4px solid #667eea;
    border-radius: 4px;
    margin-bottom: 15px;
}

.suggestion-card .suggestion-justification strong {
    color: #667eea;
}

.suggestion-card .suggestion-actions {
    display: flex;
    gap: 10px;
}

.suggestion-card .suggestion-actions .btn-form {
    flex: 1;
}

/* ============================= RESPONSIVE - SUGGESTIONS ============================= */
@media (max-width: 768px) {
    .suggestion-modal {
        max-width: 95%;
        padding: 15px;
    }
    
    .suggestion-stats .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .suggestion-card .suggestion-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ============================= EXISTING STYLES BELOW ============================= */
.code-block {
    background: var(--background-dark, #f6f8fa);
    border: 1px solid var(--border-color, #e1e4e8);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.tools-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Monitoring */
.monitoring-stats {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    padding: 20px;
    background: var(--background-light, #f8f9fa);
    border-radius: 8px;
    text-align: center;
}

.stat-card h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #666);
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 600;
    color: var(--primary-color, #667eea);
}

.stat-card .text-success {
    color: #28a745;
}

.stat-card .text-danger {
    color: #dc3545;
}

/* Execution Result */
.execution-result {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.result-section h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
}

/* ============================= RESPONSIVE ============================= */
@media (max-width: 768px) {
    .module-isolated-agents-wrapper {
        padding: 15px;
    }
    
    .module-isolated-agents-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .module-isolated-agents-actions {
        grid-template-columns: 1fr;
    }
    
    .agents-grid {
        grid-template-columns: 1fr;
    }
    
    .agent-card-actions {
        flex-wrap: wrap;
    }
    
    .agent-card-actions .btn-sm {
        flex: 1 1 calc(50% - 4px);
    }
    
    .modal-dialog {
        margin: 10px;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .agents-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* ============================= EXECUTION BUTTONS ============================= */

/* Botão base para ações de item */
.item-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.item-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.item-btn:active {
    transform: translateY(0);
}

/* Executar via MCP (Roxo premium) */
.btn-execute-mcp {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.btn-execute-mcp:hover {
    background: linear-gradient(135deg, #7c8ff0 0%, #8a5bb3 100%);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Executar Task Aprovada (Verde sucesso) */
.btn-execute-task {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
}

.btn-execute-task:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Agendar Task (Azul calendário) */
.btn-schedule {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
}

.btn-schedule:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* Requer Ação Manual (Laranja atenção) */
.btn-user-action {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
}

.btn-user-action:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

/* Loading state para botões de execução */
.item-btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.item-btn.loading::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================= MCP EXECUTION FULLSCREEN ============================= */

/* MCP execution fullscreen editor */
#mcp-execution-fullscreen.module-isolated-agents-fullscreen {
    background: var(--color-background, #f8fafc);
}

#mcp-execution-fullscreen .module-isolated-agents-editor {
    max-width: 900px;
}

/* Header with gradient */
#mcp-execution-fullscreen .module-isolated-agents-editor-header.bg-gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#mcp-execution-fullscreen .module-isolated-agents-editor-header h3 {
    color: white;
}

/* Alert inside editor */
#mcp-execution-fullscreen .alert-success {
    background: #d1fae5;
    color: #065f46;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #10b981;
}

/* Code blocks */
#mcp-execution-fullscreen .code-block {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    overflow-x: auto;
    max-height: 300px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Badges */
#mcp-execution-fullscreen .badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

#mcp-execution-fullscreen .badge-primary {
    background: #ddd6fe;
    color: #5b21b6;
}

/* Responsive */
@media (max-width: 768px) {
    #mcp-execution-fullscreen {
        padding: 1rem;
    }
    
    #mcp-execution-fullscreen .module-isolated-agents-editor-header,
    #mcp-execution-fullscreen .module-isolated-agents-editor-body,
    #mcp-execution-fullscreen .module-isolated-agents-editor-footer {
        padding: 16px;
    }
}
