/* Agents Page - Modern Colorful Design */
/* Following UI Style Guide principles */

/* ===== Page Header ===== */
#page-agents .page-header {
    margin-bottom: 24px;
}

#page-agents .page-title {
    background: linear-gradient(135deg, #ec4899 0%, #eab308 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Architecture Diagram ===== */
.agent-architecture {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.agent-architecture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ec4899, #eab308, #22c55e, #3b82f6, #a855f7, #06b6d4);
}

.arch-header {
    margin-bottom: 24px;
}

.arch-top-row {
    display: flex;
    justify-content: center;
    gap: 60px;
    margin-bottom: 20px;
}

/* Architecture Nodes */
.arch-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.arch-node:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.arch-node .arch-icon {
    width: 32px;
    height: 32px;
}

.arch-node span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.arch-node .arch-status {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.arch-node .arch-status.running {
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
    animation: pulse 2s infinite;
}

.arch-node .arch-status.error {
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

/* Dashboard Agent Special */
.arch-node.dashboard-agent {
    border-color: #ec4899;
    background: linear-gradient(135deg, #ec489915, var(--bg-dark));
}

.arch-node.dashboard-agent .arch-icon {
    color: #ec4899;
}

.arch-node.dashboard-agent .arch-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 8px;
    background: #ec4899;
    color: white;
    font-size: 0.55rem;
    font-weight: 700;
    border-radius: 4px;
    white-space: nowrap;
}

/* Orchestrator */
.arch-node.orchestrator {
    border-color: #eab308;
    background: linear-gradient(135deg, #eab30815, var(--bg-dark));
}

.arch-node.orchestrator .arch-icon {
    color: #eab308;
}

/* Agent Type Colors */
.arch-node.data { border-color: #3b82f6; }
.arch-node.data .arch-icon { color: #3b82f6; }

.arch-node.optimizer { border-color: #22c55e; }
.arch-node.optimizer .arch-icon { color: #22c55e; }

.arch-node.action { border-color: #f59e0b; }
.arch-node.action .arch-icon { color: #f59e0b; }

.arch-node.ml { border-color: #a855f7; }
.arch-node.ml .arch-icon { color: #a855f7; }

.arch-node.monitor { border-color: #ef4444; }
.arch-node.monitor .arch-icon { color: #ef4444; }

.arch-node.reporter { border-color: #06b6d4; }
.arch-node.reporter .arch-icon { color: #06b6d4; }

/* Message Bus */
.arch-bus {
    position: relative;
    padding: 12px 0;
    text-align: center;
}

.bus-line {
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #22c55e, #f59e0b, #a855f7, #ef4444, #06b6d4);
    border-radius: 2px;
    position: relative;
}

.bus-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, white, transparent);
    animation: busFlow 3s linear infinite;
}

@keyframes busFlow {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.bus-label {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--bg-dark);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Agent Nodes Grid */
.arch-agents {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* ===== Agent Cards Grid ===== */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* ===== Agent Card ===== */
.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.agent-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    border-color: var(--agent-color, var(--border-color));
}

/* Agent Card Header */
.agent-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
}

.agent-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.agent-icon-wrapper svg {
    width: 24px;
    height: 24px;
}

.agent-card-info {
    flex: 1;
}

.agent-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.agent-card-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.agent-card-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--bg-dark);
    color: var(--text-muted);
}

.agent-card-status.running,
.agent-card-status.active {
    background: #22c55e25;
    color: #22c55e;
}

.status-dot-small {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* Agent Card Body */
.agent-card-body {
    padding: 16px 18px;
}

.agent-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.agent-stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.agent-stat {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: var(--bg-dark);
    border-radius: 8px;
}

.agent-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.agent-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Capabilities */
.agent-capabilities {
    margin-top: 12px;
}

.agent-capabilities-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

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

.capability-tag {
    padding: 4px 10px;
    background: var(--bg-dark);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Agent Card Footer */
.agent-card-footer {
    padding: 12px 18px;
}

.agent-heartbeat {
    font-size: 0.75rem;
}

/* ===== Task Monitor ===== */
.task-monitor {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.task-monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #22c55e15 0%, transparent 50%);
}

.task-monitor-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #22c55e;
}

.task-monitor-title svg {
    width: 20px;
    height: 20px;
    color: #22c55e;
}

.task-monitor-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.task-queue-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.task-queue-info strong {
    color: #22c55e;
}

/* Task Queue */
.task-queue {
    padding: 16px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.task-item:last-child {
    margin-bottom: 0;
}

.task-item:hover {
    border-color: var(--text-muted);
}

.task-item.running {
    border-left: 3px solid #22c55e;
}

.task-item.pending {
    border-left: 3px solid #f59e0b;
}

.task-item.completed {
    border-left: 3px solid #3b82f6;
}

.task-status-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.task-status-icon.running {
    background: #22c55e20;
    color: #22c55e;
    animation: spin 2s linear infinite;
}

.task-status-icon.pending {
    background: #f59e0b20;
    color: #f59e0b;
}

.task-status-icon svg {
    width: 18px;
    height: 18px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.task-info {
    flex: 1;
}

.task-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.task-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-progress {
    width: 100px;
    text-align: right;
}

.task-progress-bar {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.task-progress-text {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ===== Animations ===== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.agent-card {
    animation: cardAppear 0.4s ease forwards;
    opacity: 0;
}

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

.agent-card:nth-child(1) { animation-delay: 0ms; }
.agent-card:nth-child(2) { animation-delay: 80ms; }
.agent-card:nth-child(3) { animation-delay: 160ms; }
.agent-card:nth-child(4) { animation-delay: 240ms; }
.agent-card:nth-child(5) { animation-delay: 320ms; }
.agent-card:nth-child(6) { animation-delay: 400ms; }
.agent-card:nth-child(7) { animation-delay: 480ms; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .arch-top-row {
        flex-direction: column;
        gap: 16px;
    }

    .arch-agents {
        flex-direction: column;
    }

    .agents-grid {
        grid-template-columns: 1fr;
    }

    .agent-stats-row {
        flex-wrap: wrap;
    }

    .agent-stat {
        min-width: calc(50% - 8px);
    }
}
